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

Move the accessors out of apps/runtime.ts (appsRuntime, envsFor) so it leaves the boot's static closure #17252

opened this

Merged 31h 41m ago, live in production

apps/runtime.ts is no longer in staticClosure(src/main.ts), and test/boot-lazy.test.ts now asserts that. I did not run the full suite (the forge's check does that on push). tsc is clean.

Notes

opened this

apps/runtime.ts is no longer in staticClosure(src/main.ts), and test/boot-lazy.test.ts now asserts that. I did not run the full suite (the forge's check does that on push). tsc is clean. I ran boot-lazy, apps-runtime-split, private-app, probe, llms-budget, jobs-doors, deadends, unused-exports, boundary-secrets-process and the child-apps tests, and they pass.

What moved where

  • New src/apps/runtime_registry.ts: it holds appsRuntime, envsFor and the WeakMap that was inside runtime.ts. It also adds registerRuntime and unregisterRuntime. The service's constructor calls registerRuntime and stop() calls unregisterRuntime, so the service fills the registry when it starts. The registry imports runtime.ts for types only.
  • Callers: about 85 files (src and tests) now import appsRuntime and envsFor from the registry. Type-only imports of runtime.ts are written import type.
  • Constants: web/studio/words.ts and decisions.ts take NO_TESTS_TAIL and TESTS_PASSED_TAIL from runtime_env.ts instead of runtime.ts.
  • Child apps: spawn/child-apps.ts imports AppsRuntime dynamically in startChildApps, before the once-per-child check, so two starts can't interleave.
  • Tests: boot-lazy.test.ts adds apps/runtime.ts to the list of services the boot doesn't reach statically. apps-runtime-split.test.ts now expects runtime_registry.ts as the one module with module-level state.

What I chose not to do

  • I left #17180–#17183 alone. They are separate follow-ups.
  • I added no new function, so there was nothing for similar.ts to reuse. I moved the existing ones as they were.
  • I did not touch the four recurring check failures (the as never test inputs, the dead-code test, the /llms.txt budget, the during timing rule). The change is code motion and trips none of them. The dead-code test and the /llms.txt budget test pass locally.

Hook and gate

  • The pre-push hook asked for a Try: commit, so the last commit is an empty one carrying it, plus No door: since no page, action, route or tool changed. gate.ts --fix rewrapped one file's comments before I committed.
  • The sandbox denied network access to alpha--localhost and parent.example during the test runs. I did not look into whether any test depends on those hosts.

Try it: bun test test/boot-lazy.test.ts test/apps-runtime-split.test.ts.

🤖 Generated with Claude Code

Closes #17179

Show 1 earlier items

7 earlier comments
commented

<!-- look-pages 4fab893039e4 --> Look pages for 4fab893, from the gate:

  • look pages (inferred): this pull changes src/web/layout.ts, src/web/page_tag.ts, src/web/pages/api.ts and 21 more; the forge pictures / (src/web/layout.ts), /docs (src/web/layout.ts), /explore (src/web/layout.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

I moved appsRuntime and envsFor into apps/runtime_registry.ts, so apps/runtime.ts no longer loads at boot (#17179). This push only re-runs the check. It contains no code change, because I found nothing in this pull to fix.

  • Pull-page timing test: "the pull page answers warm in under 12.5 ms" passed 3 of 3 runs locally. My diff only moves imports and doesn't touch the pull page's work, so I treat the check failure as timing noise on a loaded machine. The check log itself says this test was green on main in 3 runs, so I can't rule out an effect of this change.
  • Phone-targets test: "Talk: every control is 44 px each way under a finger" fails the same way on main at 7e3dfba. The check log says it isn't counted against this pull.
  • Verification: bun x tsc --noEmit is clean. I didn't run the gate or bun test over the whole suite again.

If test/pull-budget.test.ts fails again on the re-run, it needs a person to look at it.

🤖 Generated with Claude Code

commented

<!-- look-pages 87e5579d6468 --> Look pages for 87e5579, from the gate:

  • look pages (inferred): this pull changes src/web/layout.ts, src/web/page_tag.ts, src/web/pages/api.ts and 21 more; the forge pictures / (src/web/layout.ts), /docs (src/web/layout.ts), /explore (src/web/layout.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

I added no look pages. The gate's inference is wrong for this pull, so I pushed an empty commit with a No look: line, which the gate's note says overrides the inference. This pull only moves appsRuntime and envsFor into apps/runtime_registry.ts and updates the imports. No page's markup, route or behaviour changes, so the 31 pages it listed (/, /docs, /explore and the rest) render as before.

Checks run before the push:

  • Gate: bun scripts/gate.ts --explain reports 0 failures. The "name the issue" rule is satisfied.
  • Dead-code test: the "every export under src/ has a caller" test passes.
  • /llms.txt byte budget: the llms-budget test passes.
  • Real-input tests: nothing in this change adds an as never input.

I didn't run the full suite again.

🤖 Generated with Claude Code

commented

The type error is fixed and pushed. bun x tsc --noEmit is clean after the fix, and test/boot-lazy.test.ts and test/apps-runtime-split.test.ts pass (10 tests). I haven't run the full suite, so I don't know how the check will judge the earlier pull-budget and phone-targets failures.

Cause: main added two new importers of appsRuntime after this branch was cut: src/apps/dev_launch.ts and src/http/routes/operations.ts. Both still imported it from apps/runtime.ts, which no longer exports it.

Fix: I merged origin/main into the branch and pointed those two imports at apps/runtime_registry.ts. Nothing else changed.

What moved: appsRuntime and envsFor now live in apps/runtime_registry.ts, so apps/runtime.ts is no longer loaded at boot (#17179). Importers across src/ and test/ now import them from the registry.

Left alone: the 11 one-off classes the drift check lists are in files this pull doesn't touch. The long-comment note is one the gate says the nightly rewrap handles.

No look pages: this pull only moves imports, so no page's markup, route or behaviour changes.

To try it, run bun test test/boot-lazy.test.ts test/apps-runtime-split.test.ts.

🤖 Generated with Claude Code

commented

I merged main into this branch, resolved the one conflict, and pushed. test/boot-lazy.test.ts now type-checks and its 7 tests pass. I did not run the rest of the suite, so the forge's check on this push is the full run.

Conflict: in test/boot-lazy.test.ts, main had taken snapshot/service.ts out of the follow-up comment and added it to the list of services the boot must not import statically. This branch does the same for apps/runtime.ts. I kept both: the only list now ends with snapshot/service.ts and apps/runtime.ts. The comment keeps main's follow-ups (#17180, #17181, #17182) and this branch's note that the accessors now live in apps/runtime_registry.ts.

The change itself is unchanged: the accessors move out of apps/runtime.ts into apps/runtime_registry.ts, and the importers point at the new module.

commented

The reviewer's feedback describes a different change (#17180), not this branch. I'll state that and not make changes.

DECLINED: The feedback doesn't match this branch, so I changed nothing and pushed nothing.

  • Head matches the issue. The head of mason/17179-move-the-accessors-out-of-apps-runtime-t is the #17252 change. It adds src/apps/runtime_registry.ts, which holds appsRuntime, envsFor and the WeakMap. About 85 importers now point at it, and apps/runtime.ts is imported as a type only. test/boot-lazy.test.ts has the apps/runtime.ts entry, and apps-runtime-split.test.ts expects the registry as the one module with module-level state.
  • Wrong diff reviewed. The review describes a checksFor/provideChecksForTest move out of checks/service.ts, which is #17180. That change is not on this branch: src/checks/handles.ts does not exist, and src/checks/ is untouched. provideChecksForTest still lives in checks/service.ts on main, so there is no second name for keepChecks to remove.
  • Child-apps test. The only src/spawn/child-apps.ts change here is the dynamic import("../apps/runtime.ts") in startChildApps, plus the registry import. It does not branch on whether the parent has checks. A "no checks gives checks: undefined, checks gives a handle" test would belong to #17180.

Please re-review the diff against origin/main, or point the feedback at the pull for #17180.

commented

I merged main into the branch and pushed it. The merge commit is 06befc403.

The merge conflicted in two files, and I kept both sides in each:

  • src/spawn/child-apps.ts: startChildApps now has both the dynamic import of AppsRuntime from this pull and main's lazy import of checks/service.ts (only when the parent has checks).
  • test/boot-lazy.test.ts: the list of modules the boot must not reach now holds main's checks/service.ts and snapshot/service.ts plus this pull's apps/runtime.ts.

bun x tsc --noEmit is clean. I ran boot-lazy, apps-runtime-split and the child-apps tests, and all 10 tests pass. I did not run the full suite, so the forge's check on this push is the first full run after the merge.

bun scripts/gate.ts --fix rewrapped nothing. It notes 17 files with comment lines over 100 columns, which the nightly rewrap handles on main, and none of them are files this pull changed.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs