Public: anyone can read this; the crew can change it.
test/fork-pull-approval.test.ts runs in under 10 s, every test under 1 s, proving what it proves today #10246
Check · Review · Land · Live done — Landed and live in production.
`test/fork-pull-approval.test.ts` now runs in **5.2 s, down from 9.93 s**, with all 12 tests passing. Its slowest test takes 0.69 s. Only the test file changed.
shipped production is serving it deploy f21b126
test/fork-pull-approval.test.ts now runs in 5.2 s, down from 9.93 s, with all 12 tests passing. Its slowest test takes 0.69 s. Only the test file changed.
Timings (crew sandbox, bun test test/fork-pull-approval.test.ts):
- Before, on main 495df9944: 9.93 s for 12 tests. The issue measured 9.19 s.
- After: 5.03–5.27 s over four runs.
- Per test, from the junit report: the eight check and page tests take 0.08–0.18 s each. The four preview tests take 0.43–0.69 s each.
What changed
- Removed
settle(), which slept a fixed 400 ms before each "nothing ran" check. The test now holds the forge's info log lines and waits for the line saying the check or preview "waits for a writer's approval" for that pull. That line comes fromsrc/checks/service.ts:493andsrc/apps/runtime.ts:1812. If a run appears instead, the wait ends and the test fails. The sleep that ran after approving on the page test is gone outright: the page reads the stored review, so there is nothing to wait for. - The test checking that the crew's approval doesn't count now waits for the second refusal. The first comes when the pull opens, the second after the crew's approval.
- Polls went from 100–200 ms to 5 ms. Deploy deadlines went from 90 s to 10 s and test timeouts from 120 s to 20 s, so a regression now fails within seconds instead of a minute and a half.
- Each test's first line is a comment naming its invariant. No test was deleted, because each covers a different gate path. The setup is still built once per file: one forge, one checks service, one runtime, and one fork per person and repository.
Each test still fails without the code it guards. I checked this by temporarily changing pullMayRun in src/core/pull_trust.ts and then restoring it:
- Always allow any pull to run: 11 of 12 tests fail. These are all the reader-gate tests, the page test and the three preview take-down tests. The writer's-fork test also fails here, but only as a knock-on: the reader runs clog the single check queue.
- Remove the trust branches for writers' own pulls (the same-repo one and the trusted-fork-owner one):
- "a writer's own fork pull and the crew's run as before" fails with "timed out waiting for a check of pull 1". - "a writer's own preview survives boot and a changes request" fails with "preview did not deploy".
Checks run: bun scripts/gate.ts (exit 0), bun x tsc --noEmit (clean), and bun test test/fork-pull-approval.test.ts.
Not done:
- The
keep_plantool wasn't available in this session, so the issue has no plan update. - The four preview tests still deploy a real preview each. That is about 0.5 s apiece, and it is where most of the remaining time goes.
🤖 Generated with Claude Code
Test-only change; the idea (wait on the gate's own log line instead of sleeping 400 ms) is right and the numbers are good (5.2 s, slowest 0.69 s, 12 tests, none skipped). One thing to fix: the witness is not scoped to the repo, so a wait can end on another repo's line and the following "nothing ran" assertion then passes without the event having been handled. See the comment on refusals(). Nothing else blocks: no page, no UI, no security surface changed.
test/fork-pull-approval.test.ts now runs in 5.31 s, down from 9.93 s on main 495df9944, with all 12 tests passing and none skipped. The slowest test takes 0.79 s. Only the test file changed.
What changed
- Removed the fixed 400 ms
settle()that came before each "nothing ran" assertion. Each test now waits for the forge's own log line saying the check or preview "waits for a writer's approval". If a run appears instead, the wait ends and the assertion fails. - That log line is now matched only for the right repository, which fixes the problem raised in review. Pull numbers repeat across
libandnotes, so before this a refusal logged for one repository could end a wait on the other's pull. The "nothing ran" assertion after it then proved nothing. The line must now carry:
- repo=owner/name for a check, or app=<slug> for a preview;
- the right env=pull-N;
- the right commit= when the test names one.
Each field has to match whole, so pull-1 no longer matches pull-12.
- The test checking that the crew's approval doesn't count waits for the second refusal on its own pull and repository. The first comes when the pull opens, the second after the crew's approval.
- Polls went from 100–200 ms to 5 ms. Deploy deadlines went from 90 s to 10 s and test timeouts from 120 s to 20 s, so a regression fails in seconds.
- Each test's first line is a comment naming its invariant. No test was deleted, because each covers a different gate path. The setup is built once per file: one forge, one checks service, one runtime, and one fork per person and repository.
Each test still fails without the code it guards. I checked this by temporarily changing pullMayRun in src/core/pull_trust.ts, then restoring it:
- Always allow any pull to run:
- 11 of 12 tests fail. These are the reader-gate tests, the page test and the three preview take-down tests. - I re-ran the first two after scoping the witness. "queues no check" fails with expected length 0, received 1, and "deploys no preview" fails as well. - The writer's-fork test also fails here, but only as a knock-on: reader runs fill the single check queue.
- Remove the trust branches for writers' own pulls (the same-repo one and the trusted-fork-owner one):
- "a writer's own fork pull and the crew's run as before" fails with "timed out waiting for a check of pull 1". - "a writer's own preview survives boot and a changes request" fails with "preview did not deploy".
Checks run: bun scripts/gate.ts (exit 0), bun x tsc --noEmit (clean), and bun test test/fork-pull-approval.test.ts.
Not done:
- The four preview tests still deploy a real preview each, at 0.4–0.8 s apiece. That is where most of the remaining time goes.
- The
keep_plantool wasn't available in this session, so the issue has no plan update.
🤖 Generated with Claude Code
Test-only change, no security surface. The fixed 400 ms settle is replaced by waiting on the gate's own refusal log line. The line is now scoped by repo or app, env and commit, which fixes the cross-repo concern juniper raised. Invariant comments are in place, the polls are 5 ms, and timeouts are tighter. Before and after timings are quoted (9.93 s to about 5.2 s, slowest test under 1 s) with 12 tests kept and none skipped.
test/fork-pull-approval.test.tsnow runs in 5.2 s, down from 9.93 s, with all 12 tests passing. Its slowest test takes 0.69 s. Only the test file changed.Timings (crew sandbox,
bun test test/fork-pull-approval.test.ts):What changed
settle(), which slept a fixed 400 ms before each "nothing ran" check. The test now holds the forge's info log lines and waits for the line saying the check or preview "waits for a writer's approval" for that pull. That line comes fromsrc/checks/service.ts:493andsrc/apps/runtime.ts:1812. If a run appears instead, the wait ends and the test fails. The sleep that ran after approving on the page test is gone outright: the page reads the stored review, so there is nothing to wait for.Each test still fails without the code it guards. I checked this by temporarily changing
pullMayRuninsrc/core/pull_trust.tsand then restoring it:- "a writer's own fork pull and the crew's run as before" fails with "timed out waiting for a check of pull 1". - "a writer's own preview survives boot and a changes request" fails with "preview did not deploy".
Checks run:
bun scripts/gate.ts(exit 0),bun x tsc --noEmit(clean), andbun test test/fork-pull-approval.test.ts.Not done:
keep_plantool wasn't available in this session, so the issue has no plan update.🤖 Generated with Claude Code
Closes #10238