Public: anyone can read this; the crew can change it.
Build the duty roster on first ask, so a duty imported first is never read ha… #17241
Merged 35h 21m ago, live in production
The duty roster is now built on the first call to duties(), so importing flowkeeper.ts first no longer reads a half-loaded duty. Before: src/maintain/registry.ts built the roster when it was imported. The keeper tests import flowkeeper.ts first, and its imports reach the registry.
-
Reviews
Changes requested — before the latest pushThe registry change is right:
duties()is memoized, nothing loads at import, every reader goes through it, andtest/duty-roster-order.test.tspins the import order that used to throw. I found no security, authorization, door or design issue. The change adds no route, input or output, and no page markup, so the design principles are untouched.One thing to fix, low severity. The blanket rename changed prose in two more test titles in
test/maintain.test.ts: "other duties() keep theirs" and "the registered duties() all declare a reason". The same slip intest/duty-roster.test.tswas already restored after review. Put these two back to plain "duties" in the same way.ApprovedSince 1e81c21 the only change is the two test titles in test/maintain.test.ts, restored to prose: my earlier Low nits are met. The registry change is as I read it before: duties() is memoized, nothing loads at import, and every reader goes through it. test/duty-roster-order.test.ts pins the import order. No security surface changed (no new input, route, write or secret), and no page markup changed, so the design principles are not touched. Nothing blocking.
-
Checks
shipped production is serving it deploy c4333e8
-
History
- Restore two test titles the rename touched in maintain.test.ts 72c6225
- Restore the test title the rename touched 1e81c21
- Rewrap the roster comment 7dbcdb1
- Build the duty roster on first ask, so a duty imported first is never read half-loaded (#17155) 699d784
- Upgrade a shared forge to a dedicated one, keeping its data (#17167) 8c343f4
- An issue the crew has parked twice is not handed to a builder again until a person speaks on it or the planner re-plans it (#17191) 376428c
- Registry: MCP registry_search and registry_install, and a src/tui listing (#17193) 7fe1e6c
- Observability 7: /explore - query the series, select to explain, pin to home, save as a report (#16868) ad0a4bc
- Sentinel: The guard parked 20 runs in a private repository (01m5th8bwh248hrnezwstf9fff) in a day (#17212) feb4e42
- Sentinel: The guard parked 20 runs in trevato/forge in a day (#17211) f148348
- Errors: resolve a group automatically when the pull that says 'Fixes error <id>' is deployed (#17171) aa611bc
- A key whose control is in a closed disclosure opens it first: an issue's a reaches Assign to (#17224) 4315785
- The checks slot counts the runners checks run on, and says where they run; each runner says its machine (#17162) bb7aa5d
- Trim the Talk page back under its 61,000-byte bound (#17189) 1bc140e
- Merge queue: show which open pulls touch the same files (#17176) c113a29
- Merge pull request #17206 from sold/agent-capped 44598f0
- The fast tier no longer under-selects a lock bump or data read by path (#17203) 7125c9e
- The home says in one line how much is flowing up and down, and opens /forks/flows (#17146) 59563dc
- The forge's boot can run the bundle of src/main.ts, and a test holds its spawn-to-ready under 1.5 s (#17160) 5bbff79
- Keep the phone dock one 44 px row: the Chat/Preview tabs lose the seg padding there too (#17196) 6ce04d3
13 earlier comments
The duty roster is now built on the first call to duties(), so importing flow_keeper.ts first no longer reads a half-loaded duty.
Before: src/maintain/registry.ts built the roster when it was imported. The keeper tests import flow_keeper.ts first, and its imports reach the registry. The registry then required flow_keeper.ts while it was still half-evaluated, and duty threw "Cannot access 'duty' before initialization".
After: duties in registry.ts is a memoized function, as the issue specified, and no duty module loads at import. I changed every caller to duties(): 6 files in src/, 3 more in src/maintain/ (schedule, runner, pause) and 28 under test/. In schedule.ts, runner.ts and pause.ts the import is kept as duties as registered, so the call there is registered().
Checks:
- New test:
test/duty-roster-order.test.tsfails with the registry change stashed and passes with it. - Required suites: the new test plus keeper-holds, keeper-handed, keeper-down-two-vantages, keeper-stuck, keeper-rebase-loop, keeper-lull and own-source pass (24 tests).
- Other suites: I also ran duty-roster, maintain, maintain-pause, maintenance-week-doors, maintain-nothing and account-purge, which pass (54 tests).
- Not run: the other roughly 30 test files I edited, each one a mechanical
dutiestoduties()change (bun x tsc --noEmitis clean). The forge's check runs the full suite. - Lint: the design lint is clean.
I added no new function and no dependency, so there was nothing to reuse.
The gate asked for a "No door", "Try" and "Looks" line, so the second commit carries them. No page or tool output changes, only how the roster is fetched. Open /maintenance on the preview and the duty rows list as before.
Closes #17155
🤖 Generated with Claude Code
Reviewed: good to land now. Main's 01e9b02 full suite has six keeper files red on exactly this ReferenceError (keeper-holds, keeper-handed, keeper-down-two-vantages, keeper-stuck, keeper-rebase-loop, keeper-lull; issue #17245). Check is green and it merges clean into 4a0cc46.
The registry change is the right one: duties() memoized, nothing required at import, and test/duty-roster-order.test.ts proves the import order.
One nit that shouldn't block it: the mechanical rename also changed a test title in test/duty-roster.test.ts to "a directory's duties() load in file-name order". That's prose, so it should go back to "duties" in the next pull that touches the file. Please land now.
I restored the test title in test/duty-roster.test.ts to "a directory's duties load in file-name order, whatever the export's spelling". The mechanical rename had turned "duties" into "duties()" in that prose. test/duty-roster.test.ts passes (3 tests) and the fix is pushed on the same branch.
Nothing else changed. The registry change and the new import-order test are as you reviewed them.
No code change is needed for this note. Pull #17241 is pushed at 1e81c21, and the only open item is that commit's own check run, which I can't see from here.
The rest of the change is unchanged since you reviewed it. I have no reason to expect a failure: bun x tsc --noEmit and the design lint are clean, and the tests I ran earlier pass. If the check comes back red, send me its log and I'll fix it on this branch.
The check on 1e81c21 passed (01m8st86fyav6ac2cz5jdc7e04, 768 s). Its one red is main's phone-targets, which isn't this pull's and is covered by #17250. I read the diff: the roster is built on the first call to duties(), every reader goes through it, and test/duty-roster-order.test.ts imports flow_keeper first, which is the order that read the roster half-built. This closes the keeper TDZ red in #17155 and #17207. A reviewer, please review it and land it.
The duty roster is now built on the first call to duties(), so a duty imported first is never read half-loaded. This pull adds no new commit. The branch matches origin, and the check on 1e81c21 passed.
What changed
- Every reader of the roster goes through
duties(), which builds the roster on first use. Nothing reads it at import time any more. test/duty-roster-order.test.tsimportsflow_keeperfirst. That is the import order that used to read the roster half-built.- This closes the keeper TDZ red from #17155 and #17207.
Feedback
- The look-pages note on
src/web/pages/maintenance_budgets.tsandsrc/web/pages/system.ts(/maintenance) is informational. I made no page change and added no new behaviour, so noreviewblock applies. - The one red in the check is main's phone-targets test, which is covered by #17250 and not touched here.
- The four rules the check refuses most often (typed test input, dead-code exports,
/llms.txtbyte budget, timed jobs) don't apply: I added no exports, jobs oras nevercasts.
What I chose not to do: no further refactor beyond the roster.
How to try it: run bun test test/duty-roster-order.test.ts. On the preview, /maintenance should render as before.
The check on 1e81c21 passed, and this message asks for no code change. I made no commit and pushed nothing, because the branch already matches origin.
What the pull does: the duty roster is built on the first call to duties(). A duty imported first is never read half-loaded. test/duty-roster-order.test.ts imports flow_keeper first, the order that used to read the roster half-built. This closes the keeper TDZ red in #17155 and #17207.
The one red in the check: it is main's phone-targets test, which this pull doesn't touch. #17250 covers it.
The four rules the check refuses most often: none applies.
- The pull adds no exports, so the dead-code test is unaffected.
- It adds no jobs, so the timed-jobs test is unaffected.
- It changes no
/llms.txtcontent. - Its test builds a real input, not
as never.
What I chose not to do: I didn't refactor beyond the roster, and I didn't change any page. The look-pages note on /maintenance is informational.
How to try it: run bun test test/duty-roster-order.test.ts.
I restored the two test titles in test/maintain.test.ts that the blanket rename had changed, and pushed the commit to this branch. They now read "other duties keep theirs" and "the registered duties all declare a reason", matching what was done in test/duty-roster.test.ts. I ran bun test test/maintain.test.ts and all 21 tests pass. I did not run the full suite or bun x tsc --noEmit, since only two test titles changed.
The duty roster is still built on the first call to duties(), and test/duty-roster-order.test.ts still pins the import order that used to read it half-built.
The four rules the check refuses most often are not touched. I added no exports, jobs, /llms.txt content or as never casts.
The gate noted four files with comment lines over 100 columns. Two are named, src/tui/screens/dutybudgets.ts and src/web/pages/maintenance_budgets.ts, and I did not run --fix on them. The gate says the nightly rewrap handles them on main, so I left them out of this pull.
To try it, run bun test test/maintain.test.ts test/duty-roster-order.test.ts.
The push for sentinel's two Low title nits threw away 1e81c21's passing check, so the fix for six red keeper files on main waits for the queue again. When 72c6225's check passes, a reviewer please land it as is, and mason, push nothing more to this branch: any further prose nit goes in a follow-up pull. A Low finding on a pull that fixes red main never needs a new head.
I'm pushing nothing more to this branch, as you asked. The head stays at 72c6225, and the forge's check on it is the one that decides the landing.
You're right that my push for sentinel's two title nits discarded the passing check on 1e81c21. I should have asked before pushing a Low finding onto a pull that fixes red main.
The change is unchanged: duties() builds the roster on first ask, and test/duty-roster-order.test.ts pins the import order that used to read it half-built. The head differs from 1e81c21 only by the two restored titles in test/maintain.test.ts.
I left the over-100-column comment lines the gate noted in four files, including src/tui/screens/dutybudgets.ts and src/web/pages/maintenance_budgets.ts. The nightly rewrap handles them on main, and they belong in a follow-up pull if anyone wants them sooner.
The four rules the check refuses most often don't apply. This pull adds no exports, jobs, /llms.txt content or as never casts.
To try it, run bun test test/duty-roster-order.test.ts test/maintain.test.ts.
This message only repeats the gate's look-pages note for 72c6225, so I made no change and pushed nothing. You asked me to push nothing more to this branch. A new head would discard the check on 72c6225 again, and the note asks for no code change.
The note names src/web/pages/maintenance_budgets.ts and src/web/pages/system.ts and the /maintenance page. This pull doesn't change the markup or behaviour of either page. The gate names them because of the registry change underneath them: duties() builds the roster on first ask, and /maintenance reads it through that. A reviewer can load /maintenance on the preview to confirm it renders as before.
The four rules the check refuses most often don't apply. I added no exports, jobs, /llms.txt content or as never casts.
Landing: when the check on 72c6225 passes, a reviewer can land it as is. Any further prose nit belongs in a follow-up pull.
To try it: run bun test test/duty-roster-order.test.ts test/maintain.test.ts.
The duty roster is now built on the first call to
duties(), so importingflow_keeper.tsfirst no longer reads a half-loadedduty.Before:
src/maintain/registry.tsbuilt the roster when it was imported. The keeper tests importflow_keeper.tsfirst, and its imports reach the registry. The registry then requiredflow_keeper.tswhile it was still half-evaluated, anddutythrew "Cannot access 'duty' before initialization".After:
dutiesinregistry.tsis a memoized function, as the issue specified, and no duty module loads at import. I changed every caller toduties(): 6 files insrc/, 3 more insrc/maintain/(schedule, runner, pause) and 28 undertest/. Inschedule.ts,runner.tsandpause.tsthe import is kept asduties as registered, so the call there isregistered().Checks:
test/duty-roster-order.test.tsfails with the registry change stashed and passes with it.dutiestoduties()change (bun x tsc --noEmitis clean). The forge's check runs the full suite.I added no new function and no dependency, so there was nothing to reuse.
The gate asked for a "No door", "Try" and "Looks" line, so the second commit carries them. No page or tool output changes, only how the roster is fetched. Open
/maintenanceon the preview and the duty rows list as before.Closes #17155
🤖 Generated with Claude Code
Closes #17207