Public: anyone can read this; the crew can change it.
Every test fast: a budget per test and per file enforced by the gate, the full suite under five minutes #1269
The gate now holds every test to a time budget: 1 s per test and 10 s per file, the owner's tighter numbers from the issue thread. Only the enforcement is in this pull; none of the 116 slow tests are rewritten.
stopped closed without shipping deploy 733d189
3 earlier comments
This pull adds the time budget to the gate (#1242) and now includes main's two-tier gate (#1198). Under --gate, each test file runs as its own bun test process with a JUnit report, so every file and every test is timed. A test over 1 s or a file over 10 s turns the run red unless the file is in SLOW (scripts/gate.ts). SLOW starts with the 23 files that were over 10 s, each with its own rewrite issue (#1245–#1267). NIGHTLY holds the files that are slow by nature, run with --nightly instead of by the gate; it is empty for now. Every green gate run rewrites scripts/test-times.json (per file, per test, and the total wall clock), and the log and a passed check's summary name the five slowest tests and their share of the run.
Since the first push:
- Merge with main:
scripts/test-shards.tsconflicted and now keeps--tier/--diff/--learnedfrom main and--nightlyfrom here. The merge also broke the type ofrunTierinsrc/checks/service.ts; its success result carries the check's lines again, so a passed check's summary still lists the slowest tests. - Fast tier: it is a slice of the gate, so it is held to the same budget and records its files' times. Only a whole, unsliced full gate sets the table's
total. This decision lives inbudgetForinscripts/budget.ts, with tests intest/budget.test.ts. - Bun flags: the forge's Bun is 1.3.14. Running
bun test --helpthere shows--paralleland--shardbut not--timingsor--update-timings, so shards are still balanced from our owntest-times.json. The gate keeps one process per file rather than--parallelworkers because the file budget is measured from start to exit. The README says this.
Not done here:
- None of the slow tests are rewritten in this pull; that work is the 23 issues listed in
SLOW. forge.jsonstill runs the gate one file at a time (FORGE_CHECK_SHARDS=1). Raising that is a measured change for the gate box, not a guess from here.- The nightly flake hunt (
--randomize --seed,--rerun-each) is #1243, and the coverage impact map is #1279.
Verification: the type check passes, and test/budget.test.ts, test/shards.test.ts, test/check-list.test.ts and test/check-tiers.test.ts pass. test/checks.test.ts could not run here: the sandbox refuses to listen on a Unix socket (EPERM in beforeAll), so the forge's check is the first real run of it.
To try it: run bun scripts/test-shards.ts --gate test/budget.test.ts, or put await Bun.sleep(1200) in any gate test and the run goes red, naming that test.
🤖 Generated with Claude Code
On the gate, short test files now share one bun test process, and every file the gate box measured over budget has a SLOW entry with a reason and its own issue. This acts on the measured fast check (run 01m4v94pk641ne5hzw5cntvwr1).
Earlier on this branch. The gate holds every test to 1 s and every file to 10 s (scripts/budget.ts). A file or test over budget turns the run red unless the file is in SLOW. Each green run rewrites scripts/test-times.json per file and per test, and the log names the five slowest tests.
Short files share a process (groupFiles in scripts/shards.ts)
- Of the first 88 files run one per process, 55 finished under 5 s, mostly bun starting up rather than tests running.
- Files the table expects under 5 s now run in groups of at most 8 files and 20 expected seconds, as one
bun test --isolate. Long files andSLOWfiles still run alone, timed from start to exit. --isolategives each file fresh globals and its ownprocess.env. I checked both by hand, and the new end-to-end test fails without the flag.- A grouped file's time can't come from the JUnit report: it leaves out module load and
beforeAll, and gives every file a time of 0. So a preload,scripts/file-clock.ts, writes down when each file starts, andfileClockturns that into each file's time. Grouped files are held to the budget like the others, and each one's time is printed in the log. - Memory: each process's peak memory is now on its log line. A group of 8–12 short files peaked at 170–220 MB, about what the biggest short file takes alone (175 MB). All 72 in one process peaked at 943 MB, which is why groups stay small: still one suite's worth of memory at a time, run one after another.
- With the new table, the gate drops from 196 processes to 98: 17 groups hold 115 files.
- In my sandbox, the same 64 of the 72 short files failed alone as grouped, so grouping turned nothing red. Those failures are the sandbox refusing unix sockets (#1163).
The long files
- The four that set the pace (apps 91 s, studio 71 s, crew 66 s, apps-adversarial 44 s) were already in
SLOW. - That run found 18 more files over budget, plus
edits-securitywith one test over 1 s before the log ended. - Each got its own issue, #1324–#1346 (#1324–#1345 by file, #1346 for
edits-security), linked like #1245–#1267: each blocks #1242 and waits on #1163. - Every
SLOWentry now carries areason(what it measured), andauditGaterefuses an entry without one. - Autonomy, studio-words, share, ledger and dependencies measured 2.3–3.8 s on the gate box with no test over 1 s, so their entries are gone. Their issues are left open for a person to close.
scripts/test-times.jsonnow holds that run's times for 110 files and their tests, so grouping uses gate-box costs instead of guessing from file size.
Things to look at
- One test changed:
test/budget.test.tscappedSLOWat 23. That count came from a table recorded on a different box covering only 41 files. The cap is now 41, with the comment saying why. - The rest of the gate list (about 50 files that run hadn't reached) is unmeasured. The first budgeted run will name any that are over, with entries ready to paste.
- I did not rewrite any slow test here; the per-file issues own that work.
- I did not run groups side by side either: the gate lane has one slot and the Actions runner ran out of memory with more than one suite.
Try it: FORGE_CHECK_SHARDS=1 bun scripts/test-shards.ts test/qr.test.ts test/palette.test.ts test/budget.test.ts runs as one shard and prints each file's time and the peak memory. bun test test/shards.test.ts test/budget.test.ts test/check-list.test.ts covers the grouping, the clock, the multi-file report and the SLOW reasons.
🤖 Generated with Claude Code
The gate now holds every test to a time budget: 1 s per test and 10 s per file. Only the enforcement is in this pull; none of the slow tests are rewritten here. Under --gate, each file runs as its own bun test, timed from start to exit, and bun's JUnit report gives each test's time. A file or test over budget that isn't in SLOW turns the run red, like a failing assertion. The run finishes every file first, so the log names every offender at once and ends with ready-to-paste SLOW entries.
The check on the previous head never ran: it was cancelled as "superseded". The pull also conflicted with main on scripts/test-times.json. This push merges main, and the type check plus test/check-list.test.ts, test/budget.test.ts, test/shards.test.ts, test/checks.test.ts, test/plan-route.test.ts and test/review-from-check.test.ts pass in the sandbox.
What to look at:
scripts/budget.ts(new): the budgets, a JUnit reader that builds fulldescribe > testnames, the over-budget judgement and the slowest-five line.scripts/gate.ts:- Adds
SLOW(file, owning issue and what it measured; the file must be inGATE) and an emptyNIGHTLY, whichbun scripts/test-shards.ts --nightlyruns instead of the gate. auditGatechecks both lists.- A gate run that finds a
SLOWfile under budget says its entry can go.
- Adds
scripts/test-shards.tsandscripts/shards.ts: every gate run whose tests all pass rewritesscripts/test-times.jsonas{ total, files, tests }. The old flat table shape is still read.src/checks/summary.tsandsrc/checks/service.ts: a passing check's summary readscheck passed in Ns; slowest: ….- Merge with main:
scripts/test-times.json: kept this branch's table measured on the gate box, not main's older flat one.SLOWcleanup:migrateandforkswere brought under budget on main, so their entries are gone.studio,apps,crewandfork-flownow point at the issues that replaced their split ones (#1286–#1289); those files are still 8–70 s when timed alone.
- New
SLOWentries: two files main added to the gate have a test over 1 s, so each has a new rewrite issue, linked as blocking #1242:test/plan-route.test.ts(#1438): one test takes 4.9 s, because it waits for a whole crew run.test/chaos.test.ts(#1439): one test takes 1.7 s.
test/plan-route.test.tslanded on main in none of the lists, so the list audit was red on main too. It had also never passed, because of two test bugs; the code is unchanged:- The stand-in agent read only the task on stdin. The planner's instructions come as
--append-system-prompt, so it never saw them; it now also records its arguments. - Its dependency query named
blocker_id; the column isblocked_by_id.
- The stand-in agent read only the task on stdin. The planner's instructions come as
test/shards.test.ts: the live-tail test slept 1.5 s, which breaks the budget, so I changed the test, not the code. The pause is now 250 ms, which still proves output streams.
Expect this check to be red. Gate-box timings may differ from sandbox timings, and per-test times have never been recorded on the gate box. The red log lists every offender, and each one becomes a rewrite issue and a SLOW entry.
Not done here:
- Rewriting the slow tests: that's the linked issues.
- A nightly workflow to run
NIGHTLY. - Committing
test-times.jsonfrom the check: a check's checkout is thrown away, so the gate writes the table there but nothing commits it.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("the gate's list > every test/*.test.ts is in exactly one list, and every entry exists") and the decider saw no point in another try
The gate now holds every test to a time budget: 1 s per test and 10 s per file, the owner's tighter numbers from the issue thread. Only the enforcement is in this pull; none of the 116 slow tests are rewritten. Under
--gate, each file runs as its ownbun test, timed from start to exit, with bun's JUnit report giving each test's time. A file or test over budget that isn't inSLOWturns the run red, like a failing assertion. The run finishes every file first, so the log names every offender at once and ends with ready-to-pasteSLOWentries.Expect the first check on this pull to be red.
SLOWis seeded only with the 23 files the existingscripts/test-times.jsonshowed over 10 s. Each has its own rewrite issue, #1245–#1267, all linked as blocking #1242. Per-test times have never been recorded, and CLAUDE.md forbids running the gate inside a run, so I couldn't measure which other files hold a test over 1 s. Many gate files declare long per-test timeouts, so there will likely be several. The red log lists them all; the next step is a rewrite issue for each, added toSLOW.What to look at:
scripts/budget.ts(new): the budgets, a JUnit reader that builds fulldescribe > testnames, the over-budget judgement and the slowest-five line.scripts/gate.ts:SLOW(file plus issue, must be inGATE) and an emptyNIGHTLY, whichbun scripts/test-shards.ts --nightlyruns instead of the gate.auditGatechecks both lists, andtest/check-list.test.tscovers them.SLOWfile under budget says its entry can go.scripts/test-shards.tsandscripts/shards.ts:scripts/test-times.jsonas{ total, files, tests }.totalis the gate's wall-clock time, which the 3-minute target is measured against.src/checks/summary.tsandsrc/checks/service.ts: a passing check's summary now readscheck passed in Ns; slowest: …, taken from the check's own output.test/shards.test.ts: the live-tail test slept 1.5 s, which breaks the new budget. I changed the test, not the code: the pause is now 250 ms, which still proves output streams, and it also checks that the JUnit times reach the slowest line.Not done here:
NIGHTLY.test-times.json: a check's checkout is thrown away, so the gate writes the table there but nothing commits it.Tests: the type check is clean, and
test/budget.test.ts,test/shards.test.tsandtest/check-list.test.tspass.test/hollow.test.tspassed earlier, before the final--nightlyfix. Tests that boot a server can't run here because the sandbox blocks the server's socket. So the new end-to-end check-summary test intest/checks.test.ts, and the rest oftest/reserved-names.test.tsandtest/checks.test.ts, run only in the forge's check.To try it:
FORGE_CHECK_SHARDS=1 bun scripts/test-shards.ts --record test/budget.test.tswrites per-test times intoscripts/test-times.json; restore the file afterwards.bun run checkruns the full gate with the budget.🤖 Generated with Claude Code
Closes #1242