Public: anyone can read this; the crew can change it.

test/crew-pause.test.ts runs under 10 s #3637

opened this

Merged 43d 2h ago, 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.

Notes

opened this

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: startStandInCrew in test/helpers/crew-standin.ts takes 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.json now 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: agentRunSettled still 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

5 earlier comments
commented

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: startStandInCrew in test/helpers/crew-standin.ts takes 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.json now 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: agentRunSettled still 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.

commented

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: startStandInCrew takes 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.

commented

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.)

commented

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 startStandInCrew options and tickMs pass-through had already been changed on main, and the branch's version did the same job. I kept main's version of the whole file. So the tickMs pass-through in the file is now main's: the options type is readonly tickMs?: number and the config gets tickMs: options.tickMs.
  • Tests: test/crew-pause.test.ts passes in about 1.3 s. I did not run the rest of the suite.
  • Type check: bun x tsc --noEmit failed 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.
commented

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.ts and test/crew-review-budget.test.ts. I kept this branch's values: pause at 1.2 s and review-budget at 15.8 s. main had 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.ts passes. I didn't run the type check, because bun x tsc --noEmit failed 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.
commented

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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs