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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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).

Notes

shipped production is serving it deploy 4adf612

opened this

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 and removeRunDir in sweep.ts, and requeueAbandonedChecks in abandoned.ts. makeLocalRunner and Execution are in local_runner.ts.
  • Shared state: the locals startChecks kept in its closure are now one LaneState record in lane_state.ts, along with ChecksOptions and ChecksHandle. Each inner function became a module-level function that takes lane first:
    • request.ts
    • start.ts
    • scheduler.ts
    • verify_lane.ts
    • execute.ts
    • recheck_base.ts
    • event_handler.ts
    • gate_run.ts
  • runTier: it went from about 680 lines to run_tier.ts at 376, plus five steps: tier_source.ts, tier_manifest.ts, tier_runner.ts, tier_install.ts and tier_flake.ts.
  • service.ts: it still holds handles, checksFor, provideChecksForTest and startChecks. It re-exports every name it exported before, so no importer changed.

Other edits

  • src/kernel/destroy_reach.ts now allows src/checks/run_tier.ts:runTier and src/checks/sweep.ts:removeRunDir. These are the units that actually remove; startChecks no longer does. test/billing-never-deletes.test.ts passes.
  • test/timers-named.test.ts lists the budget timer by file. That one path changed from service.ts to execute.ts; no other existing test was edited.
  • New test/checks-service-split.test.ts checks that the old exports still resolve, that handles is held in exactly one module, and that the lane modules stay under 600 lines. It also exercises checksFor.
  • AGENTS.md describes the new layout and points its two start references at start.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

commented

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 and removeRunDir in sweep.ts, and requeueAbandonedChecks in abandoned.ts. makeLocalRunner and Execution are in local_runner.ts.
  • Shared state: the locals startChecks kept in its closure are now one LaneState record in lane_state.ts, along with ChecksOptions and ChecksHandle. Each inner function became a module-level function that takes lane first:
    • request.ts
    • start.ts
    • scheduler.ts
    • verify_lane.ts
    • execute.ts
    • recheck_base.ts
    • event_handler.ts
    • gate_run.ts
  • runTier: it went from about 680 lines to run_tier.ts at 376, plus five steps: tier_source.ts, tier_manifest.ts, tier_runner.ts, tier_install.ts and tier_flake.ts.
  • service.ts: it still holds handles, checksFor, provideChecksForTest and startChecks. It re-exports every name it exported before, so no importer changed.

Other edits

  • src/kernel/destroy_reach.ts now allows src/checks/run_tier.ts:runTier and src/checks/sweep.ts:removeRunDir. These are the units that actually remove; startChecks no longer does. test/billing-never-deletes.test.ts passes.
  • test/timers-named.test.ts lists the budget timer by file. That one path changed from service.ts to execute.ts; no other existing test was edited.
  • New test/checks-service-split.test.ts checks that the old exports still resolve, that handles is held in exactly one module, and that the lane modules stay under 600 lines. It also exercises checksFor.
  • AGENTS.md describes the new layout and points its two start references at start.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

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs