Public: anyone can read this; the crew can change it.
test/crew-pause.test.ts runs under 10 s #3637
Check · Review · Land · Live done — Landed and live in production.
`test/crew-pause.test.ts` now runs in about 1.2 s, down from 10.9 s locally (12.5 s in `scripts/test-times.json`). I pushed the change. I couldn't type-check it: `tsc` wasn't installed in this sandbox, and `bun x tsc` failed on a read-only temp dir.
shipped production is serving it deploy fc82d1a
test/crew-pause.test.ts now runs in about 1.2 s, down from 10.9 s locally (12.5 s in scripts/test-times.json). I pushed the change. I couldn't type-check it: tsc wasn't installed in this sandbox, and bun x tsc failed on a read-only temp dir.
The time was the crew's 5 s pump tick (TICK_MS in src/crew/dispatch.ts). The paused run and the resumed run each waited a tick before starting. startCrew already takes a tickMs option, so no production code changed.
- Helper:
startStandInCrewintest/helpers/crew-standin.tstakes an optional{ tickMs }and passes it through. The other callers pass nothing, so their behaviour is unchanged. - This file: it passes
tickMs: 50. - Time record:
scripts/test-times.jsonnow records 1.2 s for the file. - Coverage: no test was deleted. The file's single test still makes the same 19 assertions about the pause, the queued retry, the kept clone, and the resume with its prompt and log.
- Stability: I ran it 10 times in a row, all green, between 1.15 and 1.34 s.
What I chose not to do:
- Test body timing: I did not measure the single test's body apart from the file. The file total of about 1.2 s includes forge setup, so the test body itself is under 1.2 s but I can't say it's under 1 s.
- Fake harness and clock: I kept the stand-in shell script as the harness rather than swapping in a fake clock. The only wait that mattered was the tick.
- Shared forge fixture: the file has one test, so a per-file fixture changes nothing.
- Poll interval:
agentRunSettledstill polls every 100 ms. Lowering it would save at most about 0.1 s per wait and would touch every other crew test.
To try it: bun test test/crew-pause.test.ts.
The title says the test runs under 10 s. At this head, bun test test/crew-pause.test.ts passes but takes 10.91 s and 10.89 s on two runs, so the goal is not met. The tickMs option is real (src/crew/dispatch.ts:219) and the helper change is tidy. First fix: find where the remaining ~10 s goes. About 5 s passes before the pause log line, so start with startStandInCrew setup and the stand-in script. Cut that until the test measures well under 10 s here. Second: scripts/test-times.json now says 1.2, which is not what the test takes. Record the measured time (about 10 or less) so the shard balancing stays honest.
I haven't changed anything, because at this head I can't reproduce the 10.9 s. 76c9bc95 is both my local head and the pushed head (the branch is in sync with origin). I just ran bun test test/crew-pause.test.ts on it again: it passes in 1.195 s, with the pause log line 0.34 s after "crew is up". Ten runs on the earlier pass gave 1.15–1.34 s.
The reported "5 s before the pause log line" is exactly what TICK_MS (5 s, src/crew/dispatch.ts) costs, and the 10.9 s matches the original two ticks. That suggests the review ran a build without tickMs: 50. At this head the test passes { tickMs: 50 } at test/crew-pause.test.ts:40, and test/helpers/crew-standin.ts:181 forwards it to startCrew.
Because of that, I left scripts/test-times.json at the measured 1.2 s for test/crew-pause.test.ts. Recording about 10 s would be the stale figure the change removes.
What changed (same as before):
- Cause: the file's time was the crew's 5 s pump tick, waited twice, once for the paused run and once for the resumed one. No production code changed.
- Helper:
startStandInCrewtakes an optional{ tickMs }, and the other crew test files pass nothing, so they are unchanged. - Test file: it passes
tickMs: 50. - Coverage: its single test makes the same 19 assertions as before, and none were deleted.
What I left out:
- Fake clock and fixture: I did not add a fake clock or per-file fixture, since the stand-in script has no real waits left in this path and the file has one test.
- Poll interval: I did not touch the 100 ms poll in
agentRunSettled.
If the 10.9 s shows up again at 76c9bc95, please send the output with the pause log line's timestamps. That would point to something environment-specific that I can't see from here.
Handed to a person by the crew: two follow-up runs on the review's changes ended without a push, so no more start here until you say what to try. (The forge posts this under the reviewer's name; the reviewer did not write it.)
I merged main into the branch and pushed it. The only conflict was in test/helpers/crew-standin.ts, and the merge commit is 7207167b.
- Conflict: the
startStandInCrewoptions andtickMspass-through had already been changed onmain, and the branch's version did the same job. I keptmain's version of the whole file. So thetickMspass-through in the file is nowmain's: the options type isreadonly tickMs?: numberand the config getstickMs: options.tickMs. - Tests:
test/crew-pause.test.tspasses in about 1.3 s. I did not run the rest of the suite. - Type check:
bun x tsc --noEmitfailed here because bun couldn't write to its temp directory (read-only filesystem), so it didn't actually check anything. The forge's check will run it on this push.
Approved. The change is two lines: the pause test starts its stand-in crew with tickMs: 50, and scripts/test-times.json records 1.2 s for the file. No production code changes, and the helper already forwards tickMs (test/helpers/crew-standin.ts:181). The other crew tests pass nothing, so they are unchanged. I did not run the head: my checkout was at the base, where the file took 10.97 s, which matches the reported cause (the 5 s pump tick, waited twice). The test file and the helper changed nothing a user sees, so there is no preview behaviour to check.
Next, if you want them: (1) have the other crew-*.test.ts files that wait on the pump tick pass a short tickMs too, then update their entries in test-times.json (crew-continues, crew-declines and crew-review are 11-12 s each); (2) make the 100 ms poll in agentRunSettled a shared constant, so a faster poll is one change.
I merged main into the branch and pushed it. The only conflict was scripts/test-times.json.
- Conflict: both sides had changed the recorded times for
test/crew-pause.test.tsandtest/crew-review-budget.test.ts. I kept this branch's values: pause at 1.2 s and review-budget at 15.8 s.mainhad them the other way round (12.5 s and 1.5 s). The 1.2 s figure matches the pause test now running in about 1.4 s. - Checks:
bun test test/crew-pause.test.tspasses. I didn't run the type check, becausebun x tsc --noEmitfailed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem". The forge's check will run the full suite and type check on this push.
The tickMs fix in test/crew-pause.test.ts is right and the helper already forwards it on main. One thing to fix first: scripts/test-times.json also changes test/crew-review-budget.test.ts from 1.5 to 15.8. That file was brought under 10 s by #3606 (aa516edf), main records 1.5, and this pull is not about it. The 15.8 is the stale pre-#3606 figure that came in with a bad conflict resolution, and it would make the shard scheduler treat a fast file as slow. Restore 1.5 for crew-review-budget and keep only the crew-pause 12.5 to 1.2 change. I did not run the suite or the preview for this review; the diff is the only evidence.
I restored test/crew-review-budget.test.ts to 1.5 in scripts/test-times.json, as you asked. That 15.8 was the stale pre-#3606 figure, and I kept it by mistake when I resolved the merge conflict.
Against main, the file now differs in one line: test/crew-pause.test.ts goes from 12.5 to 1.2. I didn't re-run the tests for this change, which only touches that JSON file.
Approved. The change is one option: the pause test passes tickMs: 50 to startStandInCrew, which already forwards it to startCrew on main (test/helpers/crew-standin.ts:46,181). No production code changed, the single test keeps all its assertions, and the recorded time in scripts/test-times.json drops from 12.5 to 1.2. The diff touches no input, output, auth or UI surface, so the security, terminal and both-doors items do not apply. I could not load the preview from my sandbox (network denied), and my checkout is the base, so I judged the diff as given. Next: (1) the 100 ms agentRunSettled poll is now the largest wait in the crew tests, so make it a shared option for all of them. (2) Confirm the 1.2 s figure in test-times.json against the forge check log, not only a local run.
test/crew-pause.test.tsnow runs in about 1.2 s, down from 10.9 s locally (12.5 s inscripts/test-times.json). I pushed the change. I couldn't type-check it:tscwasn't installed in this sandbox, andbun x tscfailed on a read-only temp dir.The time was the crew's 5 s pump tick (
TICK_MSinsrc/crew/dispatch.ts). The paused run and the resumed run each waited a tick before starting.startCrewalready takes atickMsoption, so no production code changed.startStandInCrewintest/helpers/crew-standin.tstakes an optional{ tickMs }and passes it through. The other callers pass nothing, so their behaviour is unchanged.tickMs: 50.scripts/test-times.jsonnow records 1.2 s for the file.What I chose not to do:
agentRunSettledstill polls every 100 ms. Lowering it would save at most about 0.1 s per wait and would touch every other crew test.To try it:
bun test test/crew-pause.test.ts.Closes #3593