Public: anyone can read this; the crew can change it.
Nothing optional loads at boot: route modules and warm-ups (search, samplers, crew) start on first use #16908
Check · Review · Land · Live done — Landed and live in production.
This is a partial step on #16852. The /settings… and /forges… route modules and the search warm now load on first use, but the issue is not done. The samplers, the crew warm-ups and most other route families are untouched, and the idle-memory gain is only about 20 MiB.
-
Reviews
ApprovedNo security findings. The lazy route lists are registered at boot in front of the modules, so the admin gate, matching and 405s are unchanged, and a test holds each list equal to its module's own routes. The search warm uses the same search path as before and starts once per forge. The idle-RSS budget drops from 400 to 360 MiB and the new test file covers each change. This is a partial step on #16852: the issue stays open for the families and warm-ups not yet moved. Follow-up: move the other route families, or say which ones stay at boot.
-
Checks
shipped production is serving it deploy c1c75da
-
History
- The settings lazy route list follows main's two runner routes, so the marks test holds again 49856c8
- Merge remote-tracking branch 'origin/main' into mason/16852-nothing-optional-loads-at-boot-route-mod ea3f392
- A card with no picture says why, and never shows a question mark (#16794) 629ff64
- Sandbox floor with Landlock where bwrap cannot run. (#16888) a3aa32f
- Sentinel: memory-growth was degraded 16 minutes today: The forge's own memory is 4689 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16906) a233995
- Bridge v1: home becomes operable — select any tile, row or figure and act in place, keyboard first (#16898) 6edf0f6
- Follow upstream's "last checked" speaks the UI's one clock: `time()`, not a hand-rolled HH:MM UTC (#16902) 8fd7cde
- Install scripts off for unreviewed repositories (bun install --ignore-scripts) (#16886) 59dc8a4
- Home: two or three owner-pinned panels with release annotations (#16884) 12309f3
- A check's plan line survives a long log: in the summary when green, in the detail when red (#16889) 0a6deb5
- Name the search warm-up's start in the untimed jobs, with its reason fc5695b
- Main green: the static web loads no data graph again (FLAGS_FILE in a leaf module) (#16912) 42c8c1d
- MCP tools to list, add, grant and remove crew SSH devices (#16863) 8d40736
- Lent runners: a peer forge can lend check compute, scoped to public pulls, budgeted, sampled and revocable (#16836) 4c3cffb
- infra list opens with one paragraph naming every machine, and show finds a machine by name (#16900) 09cecc1
- The search warm-up's deferred start runs inside during, so the timer-naming test holds 1f490d7
- "tries at /signin close the API door" passes every time on a loaded check machine (#16904) 362a2b5
- Talk's direct lane: small edits go straight to a live preview branch in seconds; the check runs once at Publish (#16832) 1cb0dba
- Status page: backups get their own honest row instead of reading as slow pages (#16891) e8a1cb1
- Lazy first-use tests share one static-closure helper; no fixed waits 60bf97f
4 earlier comments
This is a partial step on #16852. The /settings… and /forges… route modules and the search warm now load on first use, but the issue is not done. The samplers, the crew warm-ups and most other route families are untouched, and the idle-memory gain is only about 20 MiB. I did not run the whole suite; the forge's check runs it on this push.
What changed
- Settings and forges routes: the
/settings…pages and the/forges,/family,/pricingand/templatespages now import on their first request.src/http/lazy_lists.tslists each family's routes, andsrc/http/server.tsregisters them through the existinglazyRouteshook (the one MCP uses). Matching, the admin gate and 405s behave as before. - Search warm:
warmOnFirstSearch(insrc/search/warm.tsandsrc/actions/search.ts) replaces the boot-timewarmSearch. The warm starts on the turn after the first non-empty search and fires once per forge. The first search is answered as before, cold and budgeted. - Idle memory: a fresh forge settles at 255–265 MiB, down from about 281–285 MiB.
IDLE_RSS_BUDGETintest/boot-idle-memory.test.tsgoes from 400 to 360 MiB. - Tests:
test/lazy-first-use.test.tshas four tests.- Each lazy list equals its module's own routes.
- Boot's static imports don't reach those modules.
- The first request to
/settings/tokens,/pricingand/templatesanswers under 2 s, including the import. - The warm doesn't start when armed, doesn't start on an empty query, and starts on the first real search while that search still answers.
- Refactor:
staticClosuremoved totest/helpers/static-closure.ts, now used by bothtest/boot-lazy.test.tsand the new test. - Docs:
AGENTS.mdgets a short note on the pattern.
What I chose not to do
- Samplers: I did not make the 15 s machine sampler or the memory sampler start on first use. What they record is history a page reads later, so starting them late would change behaviour.
AGENTS.mdsays so. - Pre-listener warm-ups: I left
warmFlow,warmPlansandwarmDisplaysas they are. They run before the listener opens so that visitors don't wait. - Other route families: I did not touch
api.tsorrepo.ts. They are heavily shared, so each needs its own route list and an audit of what else imports it. - Crew warm-ups: I found no separate crew warm-up to move.
- Search-warm trade-off: the first search now runs cold and the warm fills the grep cache for the next one, where before the boot filled it up front.
Checks
tscis clean andgate.tspasses. The duplicate scan stopped at its 8 s limit and compared against part of the tree.- The 262 settings/forges/pricing/templates/usage tests and 98 openapi, page-budget, search, guide and dead-code tests pass.
- The
/forgesroute answers 404 on a plain test forge, so the first-request test uses/templatesinstead.
Try: open /settings/tokens, /pricing and /templates on the preview. Each answers as before, and the first search warms the grep cache.
🤖 Generated with Claude Code
The settings and forges route modules and the search warm-up now load on first use instead of at boot. This push fixes the one failing check, the timer-naming test in test/timers-named.test.ts.
The deferred start in src/actions/search.ts used a bare setTimeout(first, 0). It is now wrapped as during("search-warm-start", first, undefined, app), like the other server-side timers. Behaviour is the same.
bun x tsc --noEmit is clean. test/timers-named.test.ts and the test/search*.test.ts files pass (104 pass, 2 skipped). I did not run the rest of the suite; the forge runs it on this push.
bun scripts/gate.ts --fix reports one comment line over 100 columns in src/actions/search.ts. It left it alone, because the nightly rewrap on main handles those.
The job-slices check is fixed and pushed. test/job-slices.test.ts and test/timers-named.test.ts pass (11 tests) and bun x tsc --noEmit is clean. I did not run the rest of the suite; the forge runs it on this push.
The earlier fix wrapped the search warm-up's deferred start in during("search-warm-start", …). That test requires every during name to be timed or listed in UNTIMED with a reason, and the new name was in neither. I added it to UNTIMED in test/job-slices.test.ts. The reason given is that it is a one-shot zero-delay timer that only starts the warm-up. The warm-up's own work is covered by its own tests.
I picked "untimed" over timing it in the slice table because the timer does no work of its own.
Settings and forges route modules, plus the search warm-up, now load on first use instead of at boot (#16852).
What changed
src/http/lazy_routes.tsandsrc/http/lazy_lists.tsregister each lazy family's method and pattern at boot, ahead of its module. Matching, the admin gate, 405s and HEAD answer as before. The first request imports the module and hands over to its handler. A failed load is retried on the next request.src/search/warm.tsandsrc/actions/search.tswait for the first search before warming.test/lazy-first-use.test.tsholds each lazy list to its module's own, checks the boot's static imports don't reach those modules, and checks the first request answers inside the page budget.- The failing check, "the marks name only registered routes and heads", broke because
mainaddedPOST /settings/runners/:id/revokeand/resumeto the settings module. The lazy list didn't have them. I mergedmainand added both toSETTINGS_ROUTES.
Verification
test/route-marks.test.ts,lazy-first-use,boot-lazy,boot-idle-memory,timers-named,web-import-costandunused-exportspass.tsc --noEmitis clean and the gate is quiet.scripts/fast.tsnamed 2,940 files, so I ran the targeted set above instead of the full suite. The forge runs the full check on push.
Not done
- No new behaviour or routes.
- No door change. The list only mirrors routes the module already adds, and the commit says
No door:with the reason.
To try
Run bun test test/lazy-first-use.test.ts test/route-marks.test.ts. Then boot the app and request /settings. The first hit loads the module, and later hits are warm.
🤖 Generated with Claude Code
Left #16852 open: 2 unticked items remain (Each optional warm-up started at boot (search, samplers, crew) is listed and starts on first use instead; a test per warm-up proves first use still answers.; Boot imports only what /healthz and / need; the other route modules are imported on the first request to their prefix.).
This is a partial step on #16852. The
/settings…and/forges…route modules and the search warm now load on first use, but the issue is not done. The samplers, the crew warm-ups and most other route families are untouched, and the idle-memory gain is only about 20 MiB. I did not run the whole suite; the forge's check runs it on this push.What changed
/settings…pages and the/forges,/family,/pricingand/templatespages now import on their first request.src/http/lazy_lists.tslists each family's routes, andsrc/http/server.tsregisters them through the existinglazyRouteshook (the one MCP uses). Matching, the admin gate and 405s behave as before.warmOnFirstSearch(insrc/search/warm.tsandsrc/actions/search.ts) replaces the boot-timewarmSearch. The warm starts on the turn after the first non-empty search and fires once per forge. The first search is answered as before, cold and budgeted.IDLE_RSS_BUDGETintest/boot-idle-memory.test.tsgoes from 400 to 360 MiB.test/lazy-first-use.test.tshas four tests./settings/tokens,/pricingand/templatesanswers under 2 s, including the import.staticClosuremoved totest/helpers/static-closure.ts, now used by bothtest/boot-lazy.test.tsand the new test.AGENTS.mdgets a short note on the pattern.What I chose not to do
AGENTS.mdsays so.warmFlow,warmPlansandwarmDisplaysas they are. They run before the listener opens so that visitors don't wait.api.tsorrepo.ts. They are heavily shared, so each needs its own route list and an audit of what else imports it.Checks
tscis clean andgate.tspasses. The duplicate scan stopped at its 8 s limit and compared against part of the tree./forgesroute answers 404 on a plain test forge, so the first-request test uses/templatesinstead.Try: open
/settings/tokens,/pricingand/templateson the preview. Each answers as before, and the first search warms the grep cache.🤖 Generated with Claude Code
Closes #16852