Files
PaperClipAI/scripts
9ba5569030 ci: refresh the general-server shard durations (#15826)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Pull requests to this repository run a large CI matrix. The slowest
check sets the time a contributor waits for a green run.
> - The general-server vitest lane runs with one worker per job, so it
can only go faster across runners. Twelve shards share its suites, and a
recorded duration manifest decides which suite goes to which shard.
> - That manifest was recorded on 2026-09-15 from 646 suites. The lane
now has 871 suites and about 5031s of serial vitest time. 230 suites
have no record and get the median weight, so the shards drifted apart.
In run 38076972444 (2026-10-10) they ran 313s to 554s of tests, and
`General tests (server (2/12))` at 618s was the slowest check of the
whole run.
> - An unbalanced lane wastes the runner time it already spends. The
total work does not change, but one shard holds the run.
> - This pull request records the current duration of every suite from
two recent PR runs and keeps the same twelve shards.
> - The benefit is that the twelve shards level to about 415s of tests
each. The slowest server shard should drop from about 618s to about
480s, and this lane leaves the critical path.

## Linked Issues or Issue Description

**Describe the enhancement**

The general-server PR test lane is out of balance. Its shard manifest,
`scripts/general-server-shard-durations.json`, is three and a half weeks
old and misses 230 of the 871 current suites. The heaviest shard runs
554s of tests while the lightest runs 313s.

**Why is this needed**

The slowest check decides the wall-clock time of every PR run. In the
last fully green runs the slowest check was a general-server shard
(618s, 562s, 585s, 646s in runs 38076972444, 38076844891, 38076844368
and 38073555316). A balanced lane removes about 135s from that shard at
no extra runner cost.

**Proposed solution**

Re-record the per-suite durations from two recent PR runs (38076844891
and 38076972444) with the method that the manifest's `$comment`
documents: diff consecutive per-suite completion timestamps in each
shard log, and measure the first suite from the Vitest `RUN` banner.
Average the two runs. Keep the chat and native-runner entries from the
old manifest, because those suites run in their own lanes and do not
appear in the shard logs. Drop the two suites that no longer exist.

**Alternatives considered**

More shards would also shorten the lane (fourteen shards level at about
355s, sixteen at about 311s). They are not needed now: `Build`
(489-592s) and `General tests (workspaces-b)` (513-618s) already sit
above the balanced twelve-shard level, so extra runners would not
shorten the run. Those two checks are the next targets.

## What Changed

- `scripts/general-server-shard-durations.json`: 873 recorded suites
(was 646). 870 come from the two 2026-10-10 runs, 3 carry over (chat and
native-runner suites), 2 obsolete entries are gone. The `$comment` names
the source runs, the fleet, and the carry-over rule.
- `.github/workflows/pr-trusted.yml`: a comment on the general tests
matrix records the 2026-10-10 measurements and why the shard count stays
at twelve. No workflow behavior changes.

## Verification

- `node --test scripts/__tests__/run-vitest-stable-shard.test.mjs`: 29
pass. This covers the manifest coverage check, the duration-balance
check (spread must stay under the heaviest suite), and the complete
non-overlapping partition.
- `node --test .github/scripts/tests/pr-dependency-cache.test.mjs
.github/scripts/tests/pr-runner-rust-cache.test.mjs
.github/scripts/tests/lockfile-refresh-workflows.test.mjs`: 17 pass.
- Measurement check: the per-shard sum of the recorded durations matches
Vitest's own `Duration` line within 1s on all 24 shard logs.
- Simulation with the real planner (`scripts/run-vitest-stable.mjs
--dry-run`, `GITHUB_WORKFLOW=PR`) on the current suite list: with the
old manifest the twelve shards carry 321s to 510s of recorded tests;
with this manifest they carry 413s to 415s.
- Expected result on the first PR run after merge: every `General tests
(server (n/12))` job finishes in about 480s (415s of tests plus about
65s of setup) instead of 374s to 618s.

## Risks

- Low risk. The file only sets weights for the shard planner. A wrong
weight moves a suite to a different shard; it cannot drop or duplicate a
suite, because the guard tests assert the partition is complete and
non-overlapping.
- The durations come from the `runs-on` public PR fleet. GitHub-hosted
runners are faster in absolute terms, but the relative weights, which
are all the planner uses, are the same.
- The manifest will go stale again as suites grow. The guard test fails
when coverage drops under 50%, and the matrix comment records how to
refresh it.

## Model Used

- Claude (Anthropic), model ID `claude-fable-5-1`, running as a
Paperclip agent through the Claude local adapter with tool use (shell,
file edits, GitHub CLI). The agent collected the CI data, built the
manifest, ran the tests, and wrote this description.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 13:52:05 -07:00
..