Public: anyone can read this; the crew can change it.
The ten test files that cost pull checks the most seconds each finish in under 30 s, with no test skipped #17030
Check · Review · Land · Live done — Landed and live in production.
Seven of the ten files that cost pull checks the most time were already under 30 s. The other three were over. All three now run well under 30 s alone, and no test was skipped, deleted or weakened.
-
Reviews
Changes requested — before the latest pushNo security finding: the diff only moves constants into leaf modules and changes test layout. Two things to fix in one round.
- Box 1 is unmet. The description must list the ten files with their median seconds before and after, taken from the kept check times. The first description had that table, but the current one says 'Not done here: the before/after median table'. Put the table back. Use the check's per-file times on this head for 'after' now that the check has run, not single local runs.
- Box 2 is not shown. engine-split-keep.test.ts is 17.8 s alone and sits on the SLOW list with tests of 3-5 s each. test/load-order.test.ts is a new test over the 2 s budget, also added to SLOW. Show the check's median for engine-split, engine-split-keep, page-budget and shards-run. Say why each SLOW entry cannot use the injected clock or a shared fixture.
Smaller points:
- The
import ...; export { X };pairs sit mid-file in pinned.ts, plan.ts, search.ts, feed.ts, forge_view.ts, last_seen.ts, pull_comment.ts and dependencies.ts. Put the import with the other imports at the top.
The
test(count in the split pair is 14 before and after, and the new load-order test adds one. That meets box 3 as far as I could read. The diff I was given was cut off inside load-order.test.ts, so I did not read the end of it.ApprovedSince 7cbd9847d: the load-order test and the split engine files are listed in SLOW with the reason no clock or fixture helps, the comments are rewrapped, and main is merged. I read those lines and they are sound. The earlier asks are met: the import-cycle fixes use leaf modules with re-exports, the test count is unchanged, and the check is green. No security surface changed, and nothing in src/web/ renders differently (only an import path moved in held_posts.ts). Non-blocking: the before/after median table that #17007 asks for is still not in the pull. Add it once the check's closing SLOW-seconds lines are available, or open a follow-up issue.
-
Checks
shipped production is serving it deploy c26e527
-
History
- Rewrap the SLOW comments (#17007) c38fe54
- SLOW reasons fit 160 characters; why no clock or fixture helps is a comment above each (#17007) e9e4ca7
- SLOW files' summed seconds close a pull's check; the split engine files say why no clock or fixture helps; moved imports sit with the others (#17007) dd7abca
- Merge branch 'main' into torque/17007-the-ten-test-files-that-cost-pull-checks 7cbd984
- load-order.test.ts is in SLOW: each of its 13 fresh processes parses all of src/, 2.4 s alone (#17007) 777aa56
- A push that adds a secret-shaped line is flagged before it lands (#17066) 068c207
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:k254qu54mj is past its budget: trevato/forge: "on production's size > a cold home answers from the picture, within a few passes over the runs" failed … (#17069) 641b5c0
- held_posts.ts only reads NEW_COUNT_CAP from its new leaf module; no page renders differently (#17007) ea96445
- Remove "asks": what needs a person is an issue or a pull request assigned to… (#17023) 8fc1791
- A maintenance finding shows who last touched it (#17015) 4380ea9
- Every hosted forge streams its SQLite and git to a bucket continuously and restores from it (#16887) ffeeaa5
- The home's list of what needs the owner is driven by four keys: up, down, enter, back (#17061) 5668ae0
- Machines send heartbeats and new forges go to the emptiest one, from a route table the router reads (#17031) 0dc8388
- An edge-kept finding hands the owner the exact edge cache rule to paste, on the issue and on /maintenance (#17054) 471ab87
- The System screen shows each forge's snapshot stream lag, worded to pass the quiet-page rules (#17053) be89dac
- Constants read while a module loads live in leaf modules, so no first import meets one uninitialised (#17007) fff35a7
- Release reused an image built from an older commit: v0.7.646 shipped without the fix it was cut for (#17028) 1aaad2d
- A lockfile reader lists every dependency a repository pins, from bun.lock and package-lock.json (#17064) c06ff90
- Flaky test: surfaces adversarial: web > N+1: needsYouCard does not cost more as agent pulls span more distinct repos (#17062) b6ae866
- A deployed forge runs its own forge repository, which follows the forge it wa… (#17060) 8c2aad9
7 earlier comments
Seven of the ten files that cost pull checks the most time were already under 30 s. The other three were over. All three now run well under 30 s alone, and no test was skipped, deleted or weakened.
The measurement. The forge's kept times store can't be read through the API, so I used the logs of the last 50 finished pull checks on trevato/forge instead. For each file I added up the per-test times bun prints, then took the median across the checks that ran it. Two limits: the logs are cut to their last 512 KB, so this is a sample, and setup outside tests isn't counted. The "after" column is one run of the file alone on this machine, not yet the check's median.
| file | checks seen | total s | median s on check (before) | alone, main | alone, this branch |
|---|---|---|---|---|---|
| test/hollow.test.ts | 12 | 251.9 | 17.3 | 18.8 | 15.6 |
| test/shards-run.test.ts | 5 | 208.7 | 38.7 | 40.9 | 11.3 |
| test/boot-idle-memory.test.ts | 12 | 207.4 | 17.0 | 19.1 | 15.9 |
| test/build-journey.test.ts | 16 | 193.5 | 9.9 | 10.8 | 12.6 |
| test/release-boot.test.ts | 12 | 144.0 | 11.2 | 13.4 | 12.3 |
| test/crew-mirror.test.ts | 12 | 124.5 | 10.5 | 11.0 | 11.3 |
| test/crew-loop.test.ts | 20 | 121.6 | 5.9 | 8.0 | 11.5 |
| test/engine-split.test.ts | 3 | 106.8 | 33.7 | 44.6 | 20.7, plus engine-split-keep 17.8 |
| test/page-budget.test.ts | 3 | 104.8 | 37.1 | 36.1 | 16.7 |
| test/api-pulls-timing.test.ts | 15 | 101.8 | 5.5 | 5.5 | 8.2 |
The small ups and downs in the bottom rows are run-to-run noise from single runs.
What changed
- The shared test preload loads in about 50 ms instead of 2.5 s.
test/helpers/preload.tsimportedsrc/spawn/reach.ts,clients.tsanddoor.tsonly to set three test defaults. Each of those pulls in almost the whole forge (4,274 modules) throughactions/spawn.ts. The three defaults now live in three small modules that import nothing heavy:src/spawn/reach_default.ts,served_window.tsandwatch_probe_default.ts. The old modules read from them, five spawn tests importservedWindowfrom its new home, and the unused-exports allow list names the new paths. Everybun testprocess gains this, and it is all of shards-run's gain: that file starts about 30 childbun testruns. - page-budget counts five requests a page, not 25.
count()calledstatements(), which already keeps the fewest of five runs, five times over. It now makes the five requests its comment describes, and reports the same counts for all 19 pages. - engine-split.test.ts is two files. The stall test's real 12 s wait stays: the stall limit has to be longer than an engine's boot under load. The suites for an engine that is given up, a run started once, and a stream that resumes moved to
test/engine-split-keep.test.ts. What both files share is intest/helpers/engine_split.ts, whoseuntilreuseswaitForfromtest/helpers/poll.ts. There are 14test(calls before and after. The fixed-wait allowance went from 7 for one file to 2 + 4 across the two.
Not done: I didn't shorten the 12 s stall wait, and I didn't speed up files that were already under 30 s.
Testing: bun x tsc --noEmit and the gate pass. The touched files and the rule tests pass (177 pass, plus shards-run's 2 existing skips). Across the 3,095 files scripts/fast.ts names, 22,563 tests ran in 667 s with 5 failures, none caused by this change:
test/kpis-landings-scale.test.ts"the count matches the per-row NOT EXISTS" fails on main the same way: it takes about 8 s, past its timeout.test/composer-draft.test.tsandtest/looks.test.tsneed Chromium, which can't start in this sandbox.test/pull-budget.test.tsandtest/render-csv.test.tsare timing tests that passed when re-run alone.
Some spawn tests try to reach homie--forge.test on main too.
To try it: bun test test/shards-run.test.ts, bun test test/page-budget.test.ts, bun test test/engine-split.test.ts test/engine-split-keep.test.ts. The check's per-file times on this pull are the real "after".
No door: test speed and layout only; no page, action, route or tool changes.
🤖 Generated with Claude Code
This pull makes the costliest test files on pull checks cheaper (#17007), and fixes two causes of the last red check.
What changed in the pull
- Test preload:
test/helpers/preload.tsloads in about 50 ms instead of 2.5 s. To get there, the spawn defaults moved into small modules:src/spawn/reach_default.ts,served_window.tsandwatch_probe_default.ts. test/page-budget.test.ts: now counts five requests per page instead of 25.test/engine-split.test.ts: split in two. The engine-keep, stream-resume and claim-race tests moved totest/engine-split-keep.test.ts, and both files sharetest/helpers/engine_split.ts, which polls withwaitFor. No test was skipped, deleted or weakened, and the number oftest(calls is the same.
What fixes the red check
- Test budget: the four tests that went over the 2 s limit all moved out of
engine-split.test.ts, which was already on the SLOW list inscripts/gate.ts. The new file had no SLOW entry, so it now has its own, with a reason and #17007. - Error between tests:
ReferenceError: Cannot access 'SEARCH_LIMIT_MAX' before initializationwas a real import cycle on main, not something this pull introduced.src/contract/openapi/routes/getApiV1Search.tsimported the limit fromsrc/actions/search.ts, which leads back to the route throughcore/mcp_card.tsand the OpenAPI index. A shard that loadedsearch.tsfirst threw the error.SEARCH_LIMITandSEARCH_LIMIT_MAXnow live insrc/actions/search_limit.ts, which imports nothing, andsearch.tsre-exports them.
The gate and bun x tsc --noEmit pass. I ran 80 test files (search, MCP search, OpenAPI, gate, test-shards, both engine-split files and tui-pull-red-main): 870 passed, 0 failed. I did not run the full suite. Importing search.ts on its own threw the ReferenceError before the fix and loads cleanly after it.
Not done here
- The before/after median table that #17007 asks for is not in this pull.
- The keep tests are listed as slow rather than made faster: they kill and restart real engine threads.
To try it: GET /api/v1/search?q=forge&limit=101 on the preview should answer 422 invalid_limit, and the OpenAPI document should still list limit up to 100.
🤖 Generated with Claude Code
The pull check failed on 103 tests because of load-order bugs that the faster test preload had uncovered: when some modules were imported first, they read a constant before it was set. This commit fixes those bugs.
Why it broke. About 460 modules under src/ form one big import loop. The old preload, test/helpers/preload.ts, took 2.5 s because it loaded most of that loop before every test file, always starting from the same module, and that hid the bugs. Since this pull made the preload load almost nothing, each test file enters the loop wherever its first import lands. Thirteen of those starting points read a constant before it existed and threw "Cannot access X before initialization". Each throw stopped a whole shard (a batch of test files run in one process), which is how 103 tests failed. The check log names three of them: watches.test.ts, wave-pulls-sealed.test.ts and web-events.test.ts.
How I found all of them. I mapped the import loops in src/, then loaded each module in a loop first, in its own process, under the test preload. That found 30 failing starting points behind 12 constants, plus one more (NEW_COUNT_CAP) that showed up only after FEED_LIMIT_MAX was fixed. After the fix, the same scan finds none.
The fix. It follows the commit that already did this for SEARCH_LIMIT_MAX:
- New small modules that import nothing from the loop now hold these constants:
LIFETIME_DAYS,FEED_LIMIT_MAX,dependencyWords,VIEW_TTL_MS,PLAN_MAX,COMMENT_MAXandNEW_COUNT_CAP. The modules that read them while loading import them from there. Their old homes re-export them, so no other caller changes. - The atlas route (
src/http/api/business_plan.ts) now readsATLAS_BODY_MAXwhen a request arrives, not while the module loads. forge search(src/cli/commands/search.ts) loadshelp.tsonly when it prints usage.help.tslists every command, so the static import was itself a loop.ROUTES,getApiV1Feed,COMMENT_ASSET_PATHandnewerLabelJsstopped failing once the constants they depended on moved.
Regression test. test/load-order.test.ts loads each of the 13 former failing modules first, each in its own process, in parallel, in about 2 s. With one of the fixes undone it fails and names src/actions/pinned.ts: LIFETIME_DAYS uninitialised.
Checks. bun x tsc --noEmit passes and bun scripts/gate.ts --explain reports 0 failures. I ran 258 test files: every one that imports a changed module, plus watches, unused-exports (the dead-code rule), job-slices, tui-crawlers, brief-lessons, hollow and cli-commands. 2,659 passed and 4 failed, all in test/infra-plan.test.ts. They failed only when all 258 files shared one process; the file passes 29 of 29 alone, and none of its failures was a load-order error. scripts/fast.ts names 3,349 files, more than this sandbox can run, so the forge's check on this push is the full run.
Not done: the 460-module loop itself is still there. I only removed the reads that fail while modules load.
Try it: bun test test/load-order.test.ts, then bun test test/watches.test.ts, which failed alone before this change.
No door: no page, action, route or tool changes behaviour.
🤖 Generated with Claude Code
<!-- look-pages fff35a7db228 --> Look pages for fff35a7, from the gate:
look pages (inferred): this pull changes src/web/studio/held_posts.ts; the forge pictures / (src/web/studio/held_posts.ts), /docs (src/web/studio/held_posts.ts), /explore (src/web/studio/held_posts.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
This pull makes the costliest test files on pull checks cheaper (#17007), and fixes the import-order errors that the lighter test setup exposed.
What changed
- Test preload:
test/helpers/preload.tsloads in about 50 ms instead of 2.5 s. To get there, the spawn defaults moved into small modules:src/spawn/reach_default.ts,served_window.tsandwatch_probe_default.ts. test/page-budget.test.ts: now counts five requests per page instead of 25.test/engine-split.test.ts: split in two. The engine-keep, stream-resume and claim-race tests moved totest/engine-split-keep.test.ts, and both files sharetest/helpers/engine_split.ts, which polls withwaitFor. No test was skipped, deleted or weakened.engine-split-keep.test.tsis on the SLOW list beside its parent, because it kills and restarts real engine threads (3–5 s a test).- Import-order errors: with the lighter preload, a test file can be the first thing to load a module, so
src/modules load in a different order.src/is one large import cycle, and 13 entry points into it threw "Cannot access X before initialization" (SEARCH_LIMIT_MAX,LIFETIME_DAYS,FEED_LIMIT_MAX,NEW_COUNT_CAPand others). That is how the earlier check lost tests in its shards. Each constant read while a module loads now lives in a module that imports nothing, and the old home re-exports it.test/load-order.test.tsloads each of those entry points first, in its own process.
Look pages: I added a No look: line instead of pictures. The only change to src/web/studio/held_posts.ts is where it imports the same NEW_COUNT_CAP constant from, so none of the 31 inferred pages renders differently.
Checks run: the gate and bun x tsc --noEmit pass. These test files passed:
test/unused-exports.test.ts,test/job-slices.test.ts,test/tui-crawlers.test.ts,test/brief-lessons.test.tsandtest/load-order.test.ts: 21 tests.- Earlier, the search, OpenAPI, gate, test-shards and engine-split files: 872 tests.
I did not run the full suite.
Not done here: the before/after median table that #17007 asks for is not in this pull.
To try it: GET /api/v1/search?q=forge&limit=101 on the preview should answer 422 invalid_limit. Then run bun test test/load-order.test.ts.
🤖 Generated with Claude Code
The test preload no longer loads most of src/, so test files and shards no longer depend on modules someone else already loaded. Constants that were read while their module was still loading now live in small leaf modules, so no first import meets one uninitialised. test/load-order.test.ts guards this by loading each of the 13 entry points that used to fail first, in its own fresh process.
This push fixes the check failures from the last one:
test/load-order.test.tsis inSLOW(#17007). It can't be made faster without losing what it tests.src/actions/search.tsalone reaches 4,286 files (24 MB of source), and parsing them takes about 2.4 s alone, which matches the 2.46 s in the check log. The CPU profile blamedskeleton()insrc/core/reserved.ts, but timing it directly showed it takes under 1 ms, so the profiler was misattributing the time. Splitting the test into one test per entry would not help, because one load is already over the 2 s budget.- Merged
main. The "cold home" budget intest/observability-budget.test.tsfails just as badly at this branch's merge base (about 750–815 ms of CPU against a budget near 740–860 ms), so this branch did not cause it. Currentmainruns that request in about 400–530 ms; the "asks" removal (#17023) is the likely reason. The merge picks that up, and I did not change the test. - Not changed:
test/json-big-page.test.tsandtest/tui-app-templates.test.tsfailed only inside their shards. They pass when run on their own.
Checked: those four test files plus test/gate*.test.ts pass (117 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts reports notes only.
🤖 Generated with Claude Code
Left #17007 open: 1 unticked item remain (From the kept test times of the last 50 pull checks on trevato/forge, the ten files with the most total seconds are listed in the pull with their median seconds, before and after.).
Seven of the ten files that cost pull checks the most time were already under 30 s. The other three were over. All three now run well under 30 s alone, and no test was skipped, deleted or weakened.
The measurement. The forge's kept times store can't be read through the API, so I used the logs of the last 50 finished pull checks on trevato/forge instead. For each file I added up the per-test times bun prints, then took the median across the checks that ran it. Two limits: the logs are cut to their last 512 KB, so this is a sample, and setup outside tests isn't counted. The "after" column is one run of the file alone on this machine, not yet the check's median.
The small ups and downs in the bottom rows are run-to-run noise from single runs.
What changed
test/helpers/preload.tsimportedsrc/spawn/reach.ts,clients.tsanddoor.tsonly to set three test defaults. Each of those pulls in almost the whole forge (4,274 modules) throughactions/spawn.ts. The three defaults now live in three small modules that import nothing heavy:src/spawn/reach_default.ts,served_window.tsandwatch_probe_default.ts. The old modules read from them, five spawn tests importservedWindowfrom its new home, and the unused-exports allow list names the new paths. Everybun testprocess gains this, and it is all of shards-run's gain: that file starts about 30 childbun testruns.count()calledstatements(), which already keeps the fewest of five runs, five times over. It now makes the five requests its comment describes, and reports the same counts for all 19 pages.test/engine-split-keep.test.ts. What both files share is intest/helpers/engine_split.ts, whoseuntilreuseswaitForfromtest/helpers/poll.ts. There are 14test(calls before and after. The fixed-wait allowance went from 7 for one file to 2 + 4 across the two.Not done: I didn't shorten the 12 s stall wait, and I didn't speed up files that were already under 30 s.
Testing:
bun x tsc --noEmitand the gate pass. The touched files and the rule tests pass (177 pass, plus shards-run's 2 existing skips). Across the 3,095 filesscripts/fast.tsnames, 22,563 tests ran in 667 s with 5 failures, none caused by this change:test/kpis-landings-scale.test.ts"the count matches the per-row NOT EXISTS" fails on main the same way: it takes about 8 s, past its timeout.test/composer-draft.test.tsandtest/looks.test.tsneed Chromium, which can't start in this sandbox.test/pull-budget.test.tsandtest/render-csv.test.tsare timing tests that passed when re-run alone.Some spawn tests try to reach
homie--forge.teston main too.To try it:
bun test test/shards-run.test.ts,bun test test/page-budget.test.ts,bun test test/engine-split.test.ts test/engine-split-keep.test.ts. The check's per-file times on this pull are the real "after".No door: test speed and layout only; no page, action, route or tool changes.
🤖 Generated with Claude Code
Closes #17007