Public: anyone can read this; the crew can change it.
src/checks/service.ts is split into small modules named for one concept, with no behaviour change #14019
Check · Review · Land · Live done — Landed and live in production.
src/checks/service.ts is now 180 lines, down from 2,240, and every module it was cut into is under 600 lines. bun x tsc --noEmit and scripts/gate.ts --fix are clean. 142 test files covering the change pass, except test/timers-named.test.ts, which needed one edit (below).
shipped production is serving it deploy 4adf612
src/checks/service.ts is now 180 lines, down from 2,240, and every module it was cut into is under 600 lines. bun x tsc --noEmit and scripts/gate.ts --fix are clean. 142 test files covering the change pass, except test/timers-named.test.ts, which needed one edit (below). The full suite was not run here, because the forge runs it on the push.
What moved where
- Module-level helpers: the queue pick is in
pick.ts, the checkout sweep andremoveRunDirinsweep.ts, andrequeueAbandonedChecksinabandoned.ts.makeLocalRunnerandExecutionare inlocal_runner.ts. - Shared state: the locals
startCheckskept in its closure are now oneLaneStaterecord inlane_state.ts, along withChecksOptionsandChecksHandle. Each inner function became a module-level function that takeslanefirst:request.tsstart.tsscheduler.tsverify_lane.tsexecute.tsrecheck_base.tsevent_handler.tsgate_run.ts
runTier: it went from about 680 lines torun_tier.tsat 376, plus five steps:tier_source.ts,tier_manifest.ts,tier_runner.ts,tier_install.tsandtier_flake.ts.service.ts: it still holdshandles,checksFor,provideChecksForTestandstartChecks. It re-exports every name it exported before, so no importer changed.
Other edits
src/kernel/destroy_reach.tsnow allowssrc/checks/run_tier.ts:runTierandsrc/checks/sweep.ts:removeRunDir. These are the units that actually remove;startChecksno longer does.test/billing-never-deletes.test.tspasses.test/timers-named.test.tslists the budget timer by file. That one path changed fromservice.tstoexecute.ts; no other existing test was edited.- New
test/checks-service-split.test.tschecks that the old exports still resolve, thathandlesis held in exactly one module, and that the lane modules stay under 600 lines. It also exerciseschecksFor. AGENTS.mddescribes the new layout and points its twostartreferences atstart.ts.
Behaviour: I did not intentionally change behaviour; the passing tests above are the evidence.
Left alone: queue.ts (1,665 lines) is outside this issue.
To try it: bun test test/checks-service-split.test.ts test/billing-never-deletes.test.ts test/timers-named.test.ts. A pull's check on the preview exercises the rest.
I could not call keep_plan (not available in this session) and did not estimate a time for this pull.
🤖 Generated with Claude Code
Approved. The preview answers 200 and this is a pure move: service.ts drops to the re-exporting shell, LaneState is one plain record handed first to each function, and destroy_reach points at the units that now remove. I could only read the diff as cut (run_tier.ts, start.ts, scheduler.ts and the tier_* modules were cut off in my copy), so the 600-line ceiling and the handles test rest on the green check. Next, two things: (1) every new file opens with a blank first line, as if a module header comment was stripped; give each module its one-line header, as the neighbours in src/checks have. (2) The AGENTS.md shared-state paragraph is one very long line; put the new checks-service paragraph's rules where the next person will find them, and keep the paragraph you added short. No UI changed, so the screenshots show no regression.
src/checks/service.tsis now 180 lines, down from 2,240, and every module it was cut into is under 600 lines.bun x tsc --noEmitandscripts/gate.ts --fixare clean. 142 test files covering the change pass, excepttest/timers-named.test.ts, which needed one edit (below). The full suite was not run here, because the forge runs it on the push.What moved where
pick.ts, the checkout sweep andremoveRunDirinsweep.ts, andrequeueAbandonedChecksinabandoned.ts.makeLocalRunnerandExecutionare inlocal_runner.ts.startCheckskept in its closure are now oneLaneStaterecord inlane_state.ts, along withChecksOptionsandChecksHandle. Each inner function became a module-level function that takeslanefirst:request.tsstart.tsscheduler.tsverify_lane.tsexecute.tsrecheck_base.tsevent_handler.tsgate_run.tsrunTier: it went from about 680 lines torun_tier.tsat 376, plus five steps:tier_source.ts,tier_manifest.ts,tier_runner.ts,tier_install.tsandtier_flake.ts.service.ts: it still holdshandles,checksFor,provideChecksForTestandstartChecks. It re-exports every name it exported before, so no importer changed.Other edits
src/kernel/destroy_reach.tsnow allowssrc/checks/run_tier.ts:runTierandsrc/checks/sweep.ts:removeRunDir. These are the units that actually remove;startChecksno longer does.test/billing-never-deletes.test.tspasses.test/timers-named.test.tslists the budget timer by file. That one path changed fromservice.tstoexecute.ts; no other existing test was edited.test/checks-service-split.test.tschecks that the old exports still resolve, thathandlesis held in exactly one module, and that the lane modules stay under 600 lines. It also exerciseschecksFor.AGENTS.mddescribes the new layout and points its twostartreferences atstart.ts.Behaviour: I did not intentionally change behaviour; the passing tests above are the evidence.
Left alone:
queue.ts(1,665 lines) is outside this issue.To try it:
bun test test/checks-service-split.test.ts test/billing-never-deletes.test.ts test/timers-named.test.ts. A pull's check on the preview exercises the rest.I could not call
keep_plan(not available in this session) and did not estimate a time for this pull.🤖 Generated with Claude Code
Closes #14018