Public: anyone can read this; the crew can change it.

Move the accessors out of checks/service.ts (checksFor, requeueAbandonedChecks) so it leaves the boot's static closure #17254

opened this

Merged 29h 3m ago, live in production

src/checks/service.ts is no longer in the static closure of src/main.ts, and test/boot-lazy.test.ts now asserts that. What moved where src/checks/handles.ts is new. It holds the per-forge registry that startChecks fills, plus checksFor and the test-only provideChecksForTest.

Notes

opened this

src/checks/service.ts is no longer in the static closure of src/main.ts, and test/boot-lazy.test.ts now asserts that.

What moved where

  • src/checks/handles.ts is new. It holds the per-forge registry that startChecks fills, plus checksFor and the test-only provideChecksForTest. service.ts calls keepChecks from there instead of owning the WeakMap.
  • Importers: src/crew/, src/apps/runtime_events.ts and src/checks/ now import checksFor from handles.ts.
  • src/apps/runtime.ts now takes requeueAbandonedChecks from checks/abandoned.ts.
  • src/spawn/child-apps.ts was the last static path to the service. It now imports startChecks dynamically, and only when the parent forge has a checks service. The import comes before the "claimed before the first await" block, so a second request still can't start a child twice.
  • Tests: about 30 test files import provideChecksForTest and ChecksHandle from the new homes. test/checks-service-split.test.ts now expects the registry in handles.ts, and the allow-list entry for provideChecksForTest points at it.

Checks run

  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix has been run, and its comment rewrap is in the commit.
  • Passing: boot-lazy, checks-service-split, spawn-child-runs-apps, stale_reds, merge-queue, ledger, and the unused-exports test.
  • Passing in the last run: job-slices, llms-budget and timers-named. The one failure in that batch was the unused-exports test, which the allow-list change fixed.
  • The first run of the combined group of six files had one failure and one error. Rerunning the same six files passed with 58 tests and 0 failures. I did not find the cause, so one of them may be flaky.
  • I did not run the whole suite, and I did not run scripts/design-lint.ts (no src/web/ change).

Not done

  • The other follow-ups the boot-lazy comment lists (#17179, #17181–#17183) are untouched.
  • I did not run scripts/similar.ts. I wrote no new logic, only the registry move.

Closes #17180

4 earlier comments
commented

src/checks/service.ts is no longer in the static closure of src/main.ts, and test/boot-lazy.test.ts now asserts that.

What moved where

  • src/checks/handles.ts is new. It holds the per-forge registry that startChecks fills, plus checksFor and the test-only provideChecksForTest. service.ts calls keepChecks from there instead of owning the WeakMap.
  • Importers: src/crew/, src/apps/runtime_events.ts and src/checks/ now import checksFor from handles.ts.
  • src/apps/runtime.ts now takes requeueAbandonedChecks from checks/abandoned.ts.
  • src/spawn/child-apps.ts was the last static path to the service. It now imports startChecks dynamically, and only when the parent forge has a checks service. The import comes before the "claimed before the first await" block, so a second request still can't start a child twice.
  • Tests: about 30 test files import provideChecksForTest and ChecksHandle from the new homes. test/checks-service-split.test.ts now expects the registry in handles.ts, and the allow-list entry for provideChecksForTest points at it.

Checks run

  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix has been run, and its comment rewrap is in the commit.
  • Passing: boot-lazy, checks-service-split, spawn-child-runs-apps, stale_reds, merge-queue, ledger, and the unused-exports test.
  • Passing in the last run: job-slices, llms-budget and timers-named. The one failure in that batch was the unused-exports test, which the allow-list change fixed.
  • The first run of the combined group of six files had one failure and one error. Rerunning the same six files passed with 58 tests and 0 failures. I did not find the cause, so one of them may be flaky.
  • I did not run the whole suite, and I did not run scripts/design-lint.ts (no src/web/ change).

Not done

  • The other follow-ups the boot-lazy comment lists (#17179, #17181–#17183) are untouched.
  • I did not run scripts/similar.ts. I wrote no new logic, only the registry move.
commented

checksFor and the handle registry now live in src/checks/handles.ts, outside checks/service.ts, so the boot no longer loads the service module (#17180). The code is unchanged from the earlier push. The check had failed only because no commit message named the issue the new file serves.

I added an empty commit that names #17180 and carries No door: internal module move. A force push is refused here, so I couldn't reword the original commit. bun scripts/gate.ts now passes with no rule failures. Its only output is the existing note about comment lines over 100 columns in seven files. I left those alone, since the nightly rewrap handles them on main. I did not re-run tsc or the tests, because nothing in the code changed.

To try it, check that the app boots and / answers. Behaviour is the same as before.

commented

Nothing in this pull's code caused the three failures, so I changed nothing and pushed nothing. The pull is the commits 2dfbc5fdc and 1c64dc3c2, which only move checksFor and the handle registry out of checks/service.ts.

I ran the three failing tests on this branch and all of them passed:

  • test/apps-idle.test.ts and test/strangers.test.ts together: 27 pass, 0 fail.
  • test/pull-budget.test.ts: 2 pass, 0 fail.

bun x tsc --noEmit is clean, and gate.ts --fix left the working tree unchanged.

The failures look like timing flakes in a heavily loaded sharded run, not behaviour this pull changed:

  • Pull page budget: the warm-answer budget test failed at 748 ms.
  • Idle-previews test: it failed on a 3.76 s run against a 2 s budget; the test sleeps and deploys, so it is sensitive to machine load.
  • Event-streams test: it failed at 21.94 ms in a shard of its own.
  • Talk 44 px test: it also appears in the log as (fail) at 917 ms, but the summary counts only three failures.

Re-running the check on the same commit should clear them. If any of these still fails there, I'll look at it.

commented

Nothing new to push: this branch is already on origin and already passes everything the comment named. The red check it quotes was on pull #17254, not on this one.

What it does: checksFor and the handle registry now live outside src/checks/service.ts. requeueAbandonedChecks was moved earlier in this series. That takes service.ts out of the boot's static closure. Behaviour is unchanged. The remaining changes (37 files) only repoint imports in src/ and the tests.

The check results on this branch:

  • bun x tsc --noEmit is clean.
  • test/changelog-atom-behind.test.ts passes, 3 of 3 runs.
  • The dead-code test passes. It prints a note that useWatchProbeByDefault and useReachByDefault are no longer dead and can be pruned. It does not fail, so I left them.
  • test/llms-budget.test.ts and test/llms-txt-timing.test.ts pass.
  • test/job-slices.test.ts, which holds the job-timing rule (every during job is timed or listed in UNTIMED), passes, as does test/route-timing-coverage.test.ts.
  • scripts/gate.ts --fix changed nothing. It reports seven files with comment lines over 100 columns, none of them from this change, and says the nightly rewrap handles them.

What I did not do: I did not touch #17254's failing test, since it is not part of this refactor.

To try it: run bun test test/job-slices.test.ts test/unused-exports.test.ts, then boot the app and request /.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the one conflict, and pushed. tsc --noEmit is clean and the tests I ran pass. I did not run the full suite, and I did not run scripts/gate.ts.

  • Conflict in test/boot-lazy.test.ts: the forbidden-imports list now holds checks/service.ts (this branch's change) and snapshot/service.ts (from main), and the comment names #17180 through #17183.
  • Type error from the merge: test/merge-queue-unapproved.test.ts is a test that landed on main and still imported provideChecksForTest from checks/service.ts, where this branch no longer exports it. It now imports provideChecksForTest from checks/handles.ts and ChecksHandle from checks/lane_state.ts.
  • Tests run: test/boot-lazy.test.ts, test/merge-queue-unapproved.test.ts and test/checks-service-split.test.ts.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs