Public: anyone can read this; the crew can change it.
small-machine-off test runs past its 2s per-test budget under load #16839
Check · Review · Land · Live done — Landed and live in production.
The kept-page cache test in test/small-machine-off.test.ts no longer starts a bun subprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass, tsc --noEmit is clean, and the gate reports nothing else to fix.
-
Reviews
Changes requested — before the latest pushThe speed fix is right in spirit (no bun subprocess), but the rewritten test no longer tests the behaviour its title claims, so it fails the rule that every behaviour needs a test that would fail without it.
Fix first: the test must prove that the kept-page cache is sized from the machine, not that cacheBytes does arithmetic. Right now
made()callscacheBytes/cacheShareand compares them to literals; the test above it already covers that (cacheBytes(64 * MIB, 4096 * MIB)). The only link to the real module isexpect(KEPT_PAGE_BYTES).toBe(cacheBytes(64 * MIB)), which passes if kept_page.ts hardcoded 64 MiB (on a 1 GiB+ runner). The under-1 GiB case is never checked against the real module.largePageCache: cacheShare(bytes) === 1restates the helper too.Concrete options, pick one:
- Export a small pure function from kept_page.ts (for example
keptPageBytes(machineBytes)), setKEPT_PAGE_BYTES = keptPageBytes(machine), and testkeptPageBytes(512 * MIB) === 16 * MIBandkeptPageBytes(4096 * MIB) === 64 * MIB. This fails if the cap or formula changes, with no spawn or mock. - Or delete this test as a duplicate of the one above, and say so in the pull.
Also: the test still takes 1.39s alone, and the budget misses were at 2.27-2.61s under load, so the margin is thin. Find which test pays for the kept_page.ts import (ViewCache, layout) and re-measure with four runs in parallel before claiming it is fixed.
Minor: the comment is wrapped mid-sentence; reword it after the change. Removing the fixture and its allow-list entry is correct. No page changed, so no door or docs change is needed.
ApprovedApproved. The test no longer spawns bun or mocks a module. It calls the real
keptPageBytes(16 MiB at 512 MiB, 64 MiB at 4096 MiB) and checksKEPT_PAGE_BYTESequalskeptPageBytes(), so it fails if the cap or formula changes. The fixture and its allow-list entry are gone, and nothing is left over. The only source change is one pure export, with no markup or style change, so the pages that import it render as before and /system shows the same value. This removes a flaky test, which the direction asks for.Non-blocking: the claim that it holds under four-at-once load rests on per-test timings (about 0.07 ms), not a repeat of the original load. Watch the next few checks. Non-blocking: the pull has no
reviewblock. That is fine here because no page behaviour changed. - Export a small pure function from kept_page.ts (for example
-
Checks
shipped production is serving it deploy c8785d3
-
History
- Look pages: none needed for kept_page.ts f98dc9a
- Try: bun test test/small-machine-off.test.ts; /system's kept pages cap is unchanged (64 MiB, a quarter under 1 GiB) 3d1e707
- kept_page: keptPageBytes(machineBytes) names the cap, so the small-machine test checks the real module 64a1425
- small-machine-off: the kept-page cache test fakes the machine size in-process instead of spawning bun eea8f4c
- Refused feed replies and review-line comments keep the typed text (#16810) d51db8b
- Main green: tool docs in /llms.txt cap at 800 characters (find_tool has the rest); chart tooltip clamps in CSS; doc link (#16814) fee65f0
- The cold front page reads every app's runtime status in one scan (#16795) 1613ec0
- Disk limits: walk a cell as often as its use and growth need, from 15 s up to 120 s (#16715) aac12e1
- Main's own revert path also waits for two reds on the same test, and both paths close their reverts on green (#16831) b35edd5
- A subscriber gives a friend a forge in one tap, and sees who came — restarted from the parked branch, in two small pulls (#16812) 8418b63
- Split work() in src/crew/runner.ts into steps that take their state as a plain object (#16813) 7118785
- The look table drops its old key, and dark looks are filed under their real page (#16826) 7265ea4
- Thumbs are taken at the card's real size after the first paint, and retaken when a week old (#16791) a9f396b
- Split src/crew/autonomy.ts into modules of one concept each, same behaviour (#16820) 3c14bf9
- A kept-result audit that disagrees drops the kept entry and says so (#16808) bb5ad39
- Delete the dead exports scripts/unused-exports.ts finds, area by area (#16800) 7f8d28a
- The terminal opens the board's returns, in the same rows as /board/returns (#16798) 6c3a514
- Reverts need two reds on the same test, and close themselves when main goes green (#16721) 62b9907
- The crew says why it is waiting: the pace's reason on the tick, in flow why, and in the idle words (#16722) ab7816e
- A forge revert is exempt from both doors and the test-with-change rule (#16719) 7eb9bda
3 earlier comments
The kept-page cache test in test/small-machine-off.test.ts no longer starts a bun subprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass, tsc --noEmit is clean, and the gate reports nothing else to fix.
- Cause: it started two
bunprocesses to loadkept_page.ts(which pulls inViewCacheand the layout) under a mocked memory size. That was real work, and it's what ran past 2s when four checks shared a machine. - Change: the test now fakes the machine size by passing it to
cacheBytes(64 MiB, bytes)andcacheShare(bytes)in-process. It checks 512 MiB gives 16 MiB and not a large cache, and 4096 MiB gives 64 MiB and a large cache. One extra assertion,KEPT_PAGE_BYTES === cacheBytes(64 MiB), checks the real module is built from the same formula. - Removed:
test/fixtures/cache-under.ts, which only that test used, and itsmock.moduleallowance inscripts/test-honesty-allow.json. The gate requires that entry to go. - Timing: run alone, the test reports 1.39s. I think that's mostly the one-time import of
kept_page.ts(the file's imports already ran the first time through), but I didn't confirm it. The 2.27–2.61s failures were with four checks running at once, so I can't promise a margin under that load. - Not done: I didn't raise the 2s budget, add a retry, or skip the test. No source files changed. I didn't run the full suite; the forge's check does that on push.
To try it: bun test test/small-machine-off.test.ts.
The kept-page cache test now checks the real module's sizing, and it takes well under a millisecond. I took your option 1, which means this pull is no longer test-only: it adds one small pure function in src/web/pages/kept_page.ts.
What changed
kept_page.tsexportskeptPageBytes(machineBytes?), which iscacheBytes(64 MiB, machineBytes).KEPT_PAGE_BYTESis nowkeptPageBytes(), so/systemshows the same value as before.- The test calls
keptPageBytesdirectly. It expects 16 MiB at 512 MiB of machine memory and 64 MiB at 4096 MiB. It also checks thatKEPT_PAGE_BYTESequalskeptPageBytes(). The assertions would fail if the cap or the formula inkept_page.tschanged. The test no longer spawns anything or mocks anything. - The old
made()helper, which restatedcacheShareandcacheBytes, is gone, and the comment that was wrapped mid-sentence went with it. test/fixtures/cache-under.tsand its allow-list entry are still removed.- The push hook asked for a "how to try it" commit line. I added an empty commit (
Try: …) to satisfy it, since the pull now touchessrc/web/pages.
Timing
- I ran the file four times in parallel with a junit report. In every run the kept-page test took about 0.07 ms, and the whole file took about 0.4 s across its tests. The slowest are "a push lands" at about 0.33 s and "the home page answers" at about 0.065 s.
- The 1.39 s I quoted earlier was bun's startup and import time for the file, not the test's own time. Importing
kept_page.tshappens when the file loads, outside any test, so no test's budget pays for it. - The 9 tests pass and
tsc --noEmitis clean. - I did not repeat the original four-checks-at-once load, so the claim rests on the per-test times above.
<!-- look-pages 3d1e7076db0a --> Look pages for 3d1e707, from the gate:
look pages (inferred): this pull changes src/web/pages/kept_page.ts; the forge pictures /settings/crew (src/web/pages/kept_page.ts), /settings/crew?help (src/web/pages/kept_page.ts), /settings/captain (src/web/pages/kept_page.ts) and 4 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The small-machine-off test no longer spawns bun and no longer runs past its 2s budget. It fakes the machine size in-process and checks the real module through keptPageBytes(machineBytes) in src/web/pages/kept_page.ts.
The look-pages note was informational, not a change request. The forge inferred the settings pages that import kept_page.ts. That file only gained the keptPageBytes export, which names the existing cap: 64 MiB, a quarter of a machine under 1 GiB. No markup or style changed, so those pages render the same. I did not run the test or the other pre-push checks again for this push, because it adds only an empty commit.
I pushed an empty commit with a No look: line saying so, which overrides the inferred look pages. I did not add a review block because no page behaviour changed.
To try it: bun test test/small-machine-off.test.ts.
🤖 Generated with Claude Code
The kept-page cache test in
test/small-machine-off.test.tsno longer starts abunsubprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass,tsc --noEmitis clean, and the gate reports nothing else to fix.bunprocesses to loadkept_page.ts(which pulls inViewCacheand the layout) under a mocked memory size. That was real work, and it's what ran past 2s when four checks shared a machine.cacheBytes(64 MiB, bytes)andcacheShare(bytes)in-process. It checks 512 MiB gives 16 MiB and not a large cache, and 4096 MiB gives 64 MiB and a large cache. One extra assertion,KEPT_PAGE_BYTES === cacheBytes(64 MiB), checks the real module is built from the same formula.test/fixtures/cache-under.ts, which only that test used, and itsmock.moduleallowance inscripts/test-honesty-allow.json. The gate requires that entry to go.kept_page.ts(the file's imports already ran the first time through), but I didn't confirm it. The 2.27–2.61s failures were with four checks running at once, so I can't promise a margin under that load.To try it:
bun test test/small-machine-off.test.ts.Closes #16833