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

Every gate run times each test and names those over the budget (20 s a file, 2 s a test); a breach is red on the fast tier for files the pull changed #12091

Parked opened this
Closed without merging

Every gate run now times each test from Bun's JUnit report and checks it against a budget: 20 s per file, 2 s per test. The run's log ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach by file and test.

Notes

opened this

Every gate run now times each test from Bun's JUnit report and checks it against a budget: 20 s per file, 2 s per test. The run's log ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach by file and test. A breach fails the run only on the fast tier, and only in a test file the pull changed. On the full tier it is reported and the run stays green.

What changed

  • scripts/test-budget.ts (new): plain data in and out.
    • breaches({files, tests}, slow) returns what is over the budget, what is set aside, and the five slowest tests with their share of the run.
    • budgetBinds(tier, changed, file) decides whether a breach fails the run.
    • budgetLines writes the summary block, and parseJunit reads Bun's report.
    • Three more functions read, merge and write the per-test table.
  • scripts/test-shards.ts:
    • Each verdict run adds --reporter=junit --reporter-outfile=<shard home>/junit.xml; that covers the first run, the crash re-run and the keep-going re-run.
    • A file alone in its shard is timed from start to exit. A file sharing a shard is timed as the sum of its tests.
    • After the base-red check, the run prints the budget block. If a breach counts against the pull, a last line names it, so the check's summary names it too.
    • A green run of the gate's files writes .forge-cache/test-times-tests.json. Hand-picked runs don't write it, so the end-to-end tests' fixture runs stay out of the forge's cache.
  • scripts/gate.ts: SLOW uses the same shape as EXCLUDED (file, reason, issue). It starts with the three files scripts/test-times.json already puts over 20 s: fork-flow (48 s), studio (35 s) and crew-wrapup (24 s), all under #1242. Without them, any pull that touched one of those files would fail on its first fast run.
  • test/test-budget-run.test.ts: covers the rules from fixture times with no real test run:
    • a run under the budget passes;
    • a file over 20 s and a test over 2 s are named;
    • a SLOW file is set aside;
    • the five slowest tests and their share;
    • a full-tier breach doesn't count against the pull;
    • JUnit parsing, including nested describe blocks, escaped names and testcases with no time;
    • the per-test table merge;
    • every SLOW entry exists.

Checked against the forge's Bun: the Dockerfile pins oven/bun:1.3.14, the same version as here. With the JUnit flags, Bun's console output is byte-identical apart from the timing figures, (fail) lines included, so the output the check already parses is unchanged. JUnit and --coverage-reporter=lcov also work together, which the measuring run needs.

Not done here:

  • Making a breach fail the full tier; that is the next issue in this plan.
  • Checking SLOW inside gateRefusal; only the new test checks it.
  • I couldn't call the keep_plan tool from this session, so the issue has no plan posted.

Verified: bun scripts/gate.ts, bun x tsc --noEmit, the new test, and the runner and gate suites all pass: shards-run, shards-keep-going, shards, check-list, check-tiers, checks-failure-summary, gate-summary, tree-scans, review-rules, rule-tests-always, red-on-main, flake, check-steps. scripts/fast.ts exited 2 because scripts/gate.ts changed, so I picked those suites myself.

To try it: bun scripts/test-shards.ts --timeout 60000 test/test-budget-run.test.ts test/shards.test.ts and read the last lines. A fast-tier run (--tier fast --diff main..HEAD) whose changed test has a test over 2 s exits 1 and names it on its last line.

🤖 Generated with Claude Code

Closes #12087

2 earlier comments · 2 events
commented

Every gate run now times each test from Bun's JUnit report and checks it against a budget: 20 s per file, 2 s per test. The run's log ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach by file and test. A breach fails the run only on the fast tier, and only in a test file the pull changed. On the full tier it is reported and the run stays green.

What changed

  • scripts/test-budget.ts (new): plain data in and out.
    • breaches({files, tests}, slow) returns what is over the budget, what is set aside, and the five slowest tests with their share of the run.
    • budgetBinds(tier, changed, file) decides whether a breach fails the run.
    • budgetLines writes the summary block, and parseJunit reads Bun's report.
    • Three more functions read, merge and write the per-test table.
  • scripts/test-shards.ts:
    • Each verdict run adds --reporter=junit --reporter-outfile=<shard home>/junit.xml; that covers the first run, the crash re-run and the keep-going re-run.
    • A file alone in its shard is timed from start to exit. A file sharing a shard is timed as the sum of its tests.
    • After the base-red check, the run prints the budget block. If a breach counts against the pull, a last line names it, so the check's summary names it too.
    • A green run of the gate's files writes .forge-cache/test-times-tests.json. Hand-picked runs don't write it, so the end-to-end tests' fixture runs stay out of the forge's cache.
  • scripts/gate.ts: SLOW uses the same shape as EXCLUDED (file, reason, issue). It starts with the three files scripts/test-times.json already puts over 20 s: fork-flow (48 s), studio (35 s) and crew-wrapup (24 s), all under #1242. Without them, any pull that touched one of those files would fail on its first fast run.
  • test/test-budget-run.test.ts: covers the rules from fixture times with no real test run:
    • a run under the budget passes;
    • a file over 20 s and a test over 2 s are named;
    • a SLOW file is set aside;
    • the five slowest tests and their share;
    • a full-tier breach doesn't count against the pull;
    • JUnit parsing, including nested describe blocks, escaped names and testcases with no time;
    • the per-test table merge;
    • every SLOW entry exists.

Checked against the forge's Bun: the Dockerfile pins oven/bun:1.3.14, the same version as here. With the JUnit flags, Bun's console output is byte-identical apart from the timing figures, (fail) lines included, so the output the check already parses is unchanged. JUnit and --coverage-reporter=lcov also work together, which the measuring run needs.

Not done here:

  • Making a breach fail the full tier; that is the next issue in this plan.
  • Checking SLOW inside gateRefusal; only the new test checks it.
  • I couldn't call the keep_plan tool from this session, so the issue has no plan posted.

Verified: bun scripts/gate.ts, bun x tsc --noEmit, the new test, and the runner and gate suites all pass: shards-run, shards-keep-going, shards, check-list, check-tiers, checks-failure-summary, gate-summary, tree-scans, review-rules, rule-tests-always, red-on-main, flake, check-steps. scripts/fast.ts exited 2 because scripts/gate.ts changed, so I picked those suites myself.

To try it: bun scripts/test-shards.ts --timeout 60000 test/test-budget-run.test.ts test/shards.test.ts and read the last lines. A fast-tier run (--tier fast --diff main..HEAD) whose changed test has a test over 2 s exits 1 and names it on its last line.

🤖 Generated with Claude Code

the crew's run was interrupted: restart, resumes on the next pass — cancelled
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Every gate run now times each test from Bun's JUnit report and checks it against a budget: 20 s per test file, 2 s per test. The log ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach by file and test. A breach fails the run only on the fast tier, and only in a test file this pull changed. On the full tier it is only reported.

What changed

  • scripts/test-budget.ts (new), plain data in and out:
    • breaches finds what is over the budget, what is set aside as SLOW, and the five slowest tests with their share of the run.
    • budgetBinds decides whether a breach fails the run.
    • budgetLines writes the summary block, and parseJunit reads Bun's report.
    • Three helpers read, merge and write the per-test timing table.
  • scripts/test-shards.ts: every verdict run, including the two re-runs, writes a JUnit report to its shard's home.
    • A file alone in its shard is timed from start to exit; a file sharing a shard is timed as the sum of its tests.
    • The budget block is printed after the base-red check.
  • scripts/gate.ts: wires the budget into the gate.
  • test/test-budget-run.test.ts: covers the above.

Main's reds fixed here. These were failing on main itself, mostly from its new /home (8379e4d6f, b70fabdfe), and this pull's check would not pass without them:

  • Deleted src/crew/week_burn.ts and its test: nothing has imported it since 9589ec61d.
  • Regenerated docs/MCP.md.
  • Kpi fixtures: they now create the index that readKpis names.
  • Test expectations that follow intended changes on main: the stall-scans index, batched VALUES placeholders, deploy-pull retention, and the ssh fingerprint.
  • docs/design/size-budget.json: every first page's CSS ceiling rises by 1280 B gzip. The shared stylesheet now carries homeFlowCss, about 389 B gzip on every page.
  • docs/design/attention-budget.json: the home page's word budget goes from 95 to 100 words, for main's "Try the new home" link.
  • test/forge-looks.test.ts: /home is listed as not pictured, because the 24-look cap is spent; test/home-flow.test.ts covers the page.
  • Card heading: 16px instead of 17px, so it is on the type scale.
  • Comment wrapping: comments this pull touches are rewrapped to 100 columns, and week_read.ts leaves the header-width allow list.

Chosen not to do: I raised only the home page's attention budget. Rewriting the whole file in this sandbox would also have tightened unrelated pages; /search dropped from 42 words to 2, which looks like the sandbox rendering differently, not a real change. I also left homeFlowCss in the shared bundle rather than loading it only on /home. Moving it is a separate change.

Checks run before pushing: bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass. The 18 test files covering the failures and these changes pass, 227 tests. The full suite was not run here; the forge's check runs it.

Try it: the check log of this pull ends with the budget block. To check main's fixes, open / and /home on the preview as the owner.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs