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

test/credentials.test.ts runs in under 10 s, every test under 1 s, proving what it proves today #10232

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`test/credentials.test.ts` now runs in about 2.2 s instead of 7.25 s, and its slowest test takes 0.63 s instead of 5.58 s. The same 6 tests and 54 assertions still pass, and none are skipped or deleted.

shipped production is serving it deploy a5a2512

opened this

test/credentials.test.ts now runs in about 2.2 s instead of 7.25 s, and its slowest test takes 0.63 s instead of 5.58 s. The same 6 tests and 54 assertions still pass, and none are skipped or deleted.

Before and after (bun test test/credentials.test.ts, crew sandbox):

  • Before, on main 821389cdc: 6 pass, 7.25 s for the file. The slow test was "a crew run on the platform's token > is counted under platform (env), moving while it runs", at 5.58 s when #1335 measured it.
  • After: 6 pass, 2.11 s, 2.19 s and 2.21 s over three runs. Per-test times from the junit report were 0.63 s for that test, 0.06 s for the board test, and under 5 ms for each of the rest.

Why the slow test was slow: after the issue was assigned, the run sat in the queue until the crew pump's next tick, which is 5 s by default. Nothing in the test needed that wait.

What changed (only test/credentials.test.ts):

  • startCrew is given tickMs: 20, so the queued run starts at once. test/usage.test.ts does the same since #10230.
  • The until poll sleeps 10 ms instead of 50 ms.
  • The fake claude's hold loop sleeps 20 ms instead of 100 ms, so no sleep over 50 ms remains.
  • Each test now opens with a one-line // Invariant: comment. All six prove different things, so none was removed.
  • Setup was already built once per file: one forge, one crew, one fake binary, all in beforeAll.

Shown to fail without the code it guards: the only test whose behaviour changed is the platform-token run. With the usage.delta append in src/crew/runner.ts disabled, it fails in 318 ms (Expected - 3 / Received + 1 on the mid-run outbox check). It passes again with the code restored.

bun scripts/gate.ts and bun x tsc --noEmit both pass.

🤖 Generated with Claude Code

Closes #10228

commented

test/credentials.test.ts now runs in about 2.2 s instead of 7.25 s, and its slowest test takes 0.63 s instead of 5.58 s. The same 6 tests and 54 assertions still pass, and none are skipped or deleted.

Before and after (bun test test/credentials.test.ts, crew sandbox):

  • Before, on main 821389cdc: 6 pass, 7.25 s for the file. The slow test was "a crew run on the platform's token > is counted under platform (env), moving while it runs", at 5.58 s when #1335 measured it.
  • After: 6 pass, 2.11 s, 2.19 s and 2.21 s over three runs. Per-test times from the junit report were 0.63 s for that test, 0.06 s for the board test, and under 5 ms for each of the rest.

Why the slow test was slow: after the issue was assigned, the run sat in the queue until the crew pump's next tick, which is 5 s by default. Nothing in the test needed that wait.

What changed (only test/credentials.test.ts):

  • startCrew is given tickMs: 20, so the queued run starts at once. test/usage.test.ts does the same since #10230.
  • The until poll sleeps 10 ms instead of 50 ms.
  • The fake claude's hold loop sleeps 20 ms instead of 100 ms, so no sleep over 50 ms remains.
  • Each test now opens with a one-line // Invariant: comment. All six prove different things, so none was removed.
  • Setup was already built once per file: one forge, one crew, one fake binary, all in beforeAll.

Shown to fail without the code it guards: the only test whose behaviour changed is the platform-token run. With the usage.delta append in src/crew/runner.ts disabled, it fails in 318 ms (Expected - 3 / Received + 1 on the mid-run outbox check). It passes again with the code restored.

bun scripts/gate.ts and bun x tsc --noEmit both pass.

🤖 Generated with Claude Code

Approved

Test-only change, matches the pattern #10230 set in usage.test.ts: tickMs 20 so the queued run starts at once, shorter polls, the fake binary hold loop at 20 ms, and a one-line invariant atop each of the six tests. The option exists (src/crew/runner.ts tickMs). No behaviour or product code is touched; no README, dependency or security surface involved. I could not check out the head in my sandbox (the base runs 7.2 s here), so the 2.2 s figure is the builder's, not mine. Next: (1) the Bun.sleep(10) poll in until() could be event-driven rather than polled; (2) keep an eye on the 20 ms tick under a loaded gate, since the file only has a 10 s budget and no margin test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs