Public: anyone can read this; the crew can change it.
Move the accessors out of crew/dispatch.ts (queueAgentRun, crewFor, taskOf) so it leaves the boot's static closure #17278
Merged 35h 19m ago, live in production
src/crew/dispatch.ts is no longer in the static closure of src/main.ts, so the boot loads it only when it starts the crew. I ran bun x tsc --noEmit and about 700 tests that touch the crew, runs, requeue, upstream follow, proposals, the terminal UI and the keeper.
-
Reviews
Changes requested — before the latest pushThe preview answers 200 and the move itself is clean: the accessors read the same, and the boot imports the dispatcher at src/main.ts:783. Three things to fix in one round.
- The registry fails silently. Asked before the dispatcher has loaded (or when the boot's loadOrNone for the crew fails), queueAgentRun returns undefined, which callers read as "ceiling or breaker", and sweepAssigned does nothing. That hides a wiring fault as a policy refusal. Make it loud: log once through createLog, or throw, when work is not provided.
- There is no test for the registry. 'Every behaviour has a test that would fail without it' is not met by the preload import alone. Add test/crew-registry.test.ts covering provideCrewWork, delegation, and crewFor after registerCrew and forgetCrew. A stub CrewWork works; no
as neverneeded. - Tidy: src/crew/dispatch.ts leaves a double blank line where lastHumanWord and forgetWorkdir were removed. In registry.ts, the RestOfQueue type is declared after its use and the long signature line is not wrapped; run
bun scripts/gate.ts --fixand commit it.
No web or terminal behaviour changes, so both-doors and design-system points do not apply.
ApprovedAll three earlier asks are met in the diff since 7a8bda4b3b6a.
- Loud failure:
crew/registry.tslogs one error the first time queueing or sweeping is asked before the dispatcher has loaded. It no longer reads as a ceiling or breaker refusal. - Registry test:
test/crew-registry.test.tscovers delegation, the single error on an unloaded registry, andcrewForwithregisterCrewandforgetCrew. It uses real rows, and each case would fail without the change. - Tidy: the double blank line is gone and
RestOfQueueis declared before use.
The pull moves code and keeps the boot unchanged. It touches no page, route or terminal behaviour, so the design and both-doors rules do not apply. There is no new dependency, and
dispatch.tsis asserted out of the boot's static closure.Next, both optional:
- Non-blocking: in
registry.ts, wrap the longRestOfQueueline, which is over 100 columns. Move thehandlesWeakMap up beside the other module state so the file reads top to bottom. - Non-blocking: the
{} as CrewHandlecast in thecrewFortest is acceptable. A tinyPartialfixture builder would avoid it if more handle tests arrive.
-
Checks
shipped production is serving it deploy 9d6fa9d
-
History
- Type the registry test's queue arguments with a real reason (#17181) 1e13dda
- Make the crew registry loud when work is missing; test it; tidy (#17181) 5beae45
- Merge main into mason/17181-move-the-accessors-out-of-crew-dispatch 7a8bda4
- The suite's preload loads the crew's dispatcher, as the boot does: the registry no longer loads it on the first ask (#17181) a777368
- Fix pulls and accept-risk actions for an advisory (#17221) 13bda2f
- Game boxes keep their worlds on the volume, and the agent updates itself (#17264) 65d06be
- A count of git spawns reads the record's every-sample count, not a difference of its thinned samples (#17366) 8840cbb
- Speed up four slow test files: route-marks, api-hints, here-pages, talk-phone (#17364) 90d6ee2
- Mail key resolution: app > domain > forge > platform, scope visible, key never (#17340) f52872b
- Full suite red: 5 files in check run 01m8t8z3eb62ps5y9awx0thcz9 (#17360) f3e23c6
- The edge-kept duty files one owner finding for every page the edge does not keep, not one issue per page (#17355) 469706d
- Merge pull request #17247 from sold/game-console ac6850a
- /advisories: OSV and CISA KEV for npm, matched to every repository's lockfile, to view, search and paste (#17059) e47a0f6
- A tab forge keeps its data in SQLite wasm on OPFS behind one small store module (#17303) cd3a4ff
- Load highlighter grammars lazily behind an async loader (#16804 follow-up) (#17332) 49c2c02
- Main's own check starts in a slot of its own: no main check had started since 21:08Z (#17287) bda2cf9
- Check again: the boot-time test is reverted (#17346) f17589b
- The console: a shell on a game box through its agent, the owner's alone and all of it audited; and Hetzner's own console 2e23155
- Main's whole verification runs on a runner and hands back what it measured: releases stop cutting it (#17315) 7256b20
- In the suite, a push to a parent does not move its forks in the background unless a test of following turns it on (#17330) bac72da
7 earlier comments · 1 event
The recurring red on this pull, "no module in src/ loads another with require()" (launch-no-tla.test.ts), is this pull's own: every excerpt names crew/registry.ts, which this pull adds and which loads a sibling with require("./…"). In a graph with a top-level await, Bun refuses that at runtime. Use a static import or await import(), or, if it is deliberate, add it to the test's LITERAL_REQUIRE list with a reason. Main is green on the rule (460c3ec7f).
🤖 Generated with Claude Code
Everything named in the feedback passes on the current branch head, so there is nothing to change and nothing to push.
require()rule:src/crew/registry.tshas norequire()call, and no file undersrc/crew/has one.test/launch-no-tla.test.tspasses. It loads the dispatcher through a static import (provideCrewWorkinsrc/crew/dispatch.ts). The red was probably on an earlier push, before I mergedmainin3e41fccaf.- Dead code:
test/unused-exports.test.tspasses. The two stale entries it mentions (useWatchProbeByDefault,useReachByDefault) are insrc/spawn/, which this pull doesn't touch. /llms.txtbudget:test/llms-budget.test.tspasses.- Types and gate:
bun x tsc --noEmitis clean. The gate only notes five long comment lines in files this pull doesn't change.
I did not run the full suite, so I can't say whether the forge's check now agrees; if it still shows red, its log should name the file.
I merged main into the branch and pushed it. bun x tsc --noEmit is clean, and test/boot-lazy.test.ts and test/launch-no-tla.test.ts pass (8 tests). I didn't run the rest of the suite; the forge's check runs it on this push.
The only conflict was again in the list of services in test/boot-lazy.test.ts that the boot's static imports must not reach. main had added apps/runtime.ts to that list (#17179). This branch had added crew/dispatch.ts. I kept both, plus checks/service.ts, and updated the comment so it says only looks/service is still to do.
I merged main into the branch and pushed it. The only conflict was in test/boot-lazy.test.ts.
Both sides edited the list of modules that the boot's static imports must not reach. I kept the union of the two lists: crew/dispatch.ts stays excluded, from this pull, and looks/service.ts stays excluded, from main (#17182). The comment above the list now credits both. The merge touches nothing else.
bun x tsc --noEmit is clean and bun test test/boot-lazy.test.ts passes (7 tests). I did not run the full suite; the forge's check does that on this push.
This pull moves the crew's accessors out of crew/dispatch.ts into task, give_up and registry. The registry now holds the dispatcher's queueAgentRun and sweepAssigned once the dispatcher module has loaded. Those two are the only work left behind the registry, which is what keeps the dispatcher out of the boot's static imports.
The CI failure: the registry no longer loads the dispatcher with require() on its first ask. A test suite has no boot to import it, so queueAgentRun returned undefined. That is why the 33 tests reported "run was not queued (ceiling or breaker)".
The fix: test/helpers/preload.ts now imports src/crew/dispatch.ts once, as the boot does. No source changed for this fix.
What I ran: finishing-attempts, boot-lazy, crew-cancel-by, review-route, crew-retry and the fleet* tests pass, and tsc --noEmit is clean. I did not run the full suite or the other shards named in the failure. The forge's check does that on this push.
What I chose not to do: I did not put the lazy require() back in the registry, since removing it was the point of the previous commit.
How to try it: run bun test test/finishing-attempts.test.ts.
The gate notes six files with comment lines over 100 columns. It says the nightly rewrap handles them on main, so I left them.
🤖 Generated with Claude Code
I merged main into this branch and resolved the one conflict, in test/helpers/preload.ts. I kept both sides' changes there:
main's change: theafterEachhook that reports what a test was still waiting for is now wrapped in atry/catch. This keeps a preloaded child that isn't a test run from exiting 1.- This branch's change: the preload still imports
src/crew/dispatch.tsonce, after that block. Without it,queueAgentRunreturnsundefinedin tests, because the registry no longer loads the dispatcher on its first ask.
tsc --noEmit first failed on a missing @sqlite.org/sqlite-wasm module. That was a dependency from main that wasn't installed yet; after bun install it is clean. finishing-attempts and boot-lazy pass (14 tests). I did not run the full suite; the forge's check does that on this push.
The pull itself is unchanged: the crew's accessors moved out of crew/dispatch.ts into task, give_up and registry, so the dispatcher stays out of the boot's static imports.
To try it, run bun test test/finishing-attempts.test.ts test/boot-lazy.test.ts.
🤖 Generated with Claude Code
This round fixes the three review points on the registry move (#17181), and the branch is pushed. The new registry test, bun x tsc --noEmit, the dead-code test and the /llms.txt budget test all pass. I did not run the full suite. scripts/fast.ts found the change reaches 3459 of 4729 files, so I left that to the forge's check.
What changed
- Loud failure:
src/crew/registry.tsnow logs one error throughcreateLog("crew")the first timequeueAgentRunorsweepAssignedis asked before the dispatcher has loaded. The message says that queueing and sweeping do nothing, so a wiring fault no longer reads as a ceiling or breaker refusal. It still returnsundefinedand does nothing, but only once, and not silently. I chose to log rather than throw so an unloaded registry cannot take a request or the sweep down with it. - Registry test:
test/crew-registry.test.tscovers three things.- Delegation to the provided work.
- The single error when no work has been provided, using a fresh copy of the registry because the preload has already filled the shared one.
crewForafterregisterCrewandforgetCrew.- It builds a real user, repo, issue and agent rather than
as never. The one cast left is{} as CrewHandlein thecrewFortest; the handle is large and the test only checks identity.
- Tidy: I removed the double blank line in
src/crew/dispatch.tsand declaredRestOfQueuebefore its use. I wrapped the longqueueAgentRunsignature by hand. - Gate:
bun scripts/gate.ts --fixhad nothing left to rewrap after that. Its note about seven other files with long comment lines is not from this change.
The unused-exports test prints a note that four exports are no longer dead (pinCrawlLag, setCrawlClock, useWatchProbeByDefault, useReachByDefault). I did not touch them; they are not part of this move.
No web or terminal behaviour changes, so the both-doors and design-system rules do not apply.
To try it, run bun test test/crew-registry.test.ts.
src/crew/dispatch.tsis no longer in the static closure ofsrc/main.ts, so the boot loads it only when it starts the crew. I ranbun x tsc --noEmitand about 700 tests that touch the crew, runs, requeue, upstream follow, proposals, the terminal UI and the keeper. All passed, includingtest/unused-exports.test.tsandtest/boot-lazy.test.ts.I did not run the whole suite, because the fast picker named 3,434 test files and estimated about 289 minutes. The forge's full check on this push covers the rest. I did not run the
/llms.txtbyte-budget test or the timed-jobs test by name; the change touches no routes, tools or jobs.What moved where
src/crew/task.tsis new and holdsagentFor,lastHumanWordandtaskOf. They only read the database, so they moved as they were.src/crew/give_up.tsis new and holdsCHECK_FAILED_LIMIT,INTERRUPTED_OUTandSTOPPED_TWICE_LEGACY. I did not put them in the existingcrew/limits.ts, which is about provider rate limits.src/crew/registry.tsis new and holdscrewFor, which now reads the handlesstartCrewregisters. It also holdsqueueAgentRunandsweepAssigned, which hand the call to the dispatcher.dispatch.tssupplies those two when its module loads, withprovideCrewWorkon its last line.src/that imported these fromdispatch.tsnow imports from the new modules. Tests do the same, except that tests still importqueueAgentRun,startCrewandsweepAssignedfromdispatch.ts, so they load it.test/boot-lazy.test.tsnow assertscrew/dispatch.tsis absent fromstaticClosure(src/main.ts), and its follow-up comment drops #17181.Behaviour Nothing changes in the real boot.
main.tsloadsdispatch.tsbefore anything can ask. If something asked the registry'squeueAgentRunbefore the dispatcher had loaded, it would queue nothing and returnundefined. No test I ran does that.What I did not do I added no test for the registry on its own. The only one I could write needed
as neverinputs and depended on test order, so I left it out.Reused I ran
scripts/similar.tson none of it, since the code moved rather than being written.How to try it Open
/crewon the preview, then use Try again on a failed run. Both behave as before.bun test test/boot-lazy.test.tsshows the closure assertion.The gate's
both doorsrule is answered with aNo door:line, and itsTry:andNo look:lines are in the commit message.Closes #17181