Public: anyone can read this; the crew can change it.
The maintain duty works in slices and yields to the serving thread #17840
Merged 4h 42m ago, live in production
Two maintenance duties now read their files in 20 ms slices and hand the loop back between them, instead of holding it for one long pass. Which step runs long. I couldn't read production's [loop] lines from the sandbox: /health and /system don't show them, and the perf logs are outside what I can reach.
-
Reviews
ApprovedApproved. Both file-reading duties now ask the kernel's existing sliced() clock before each file and hand the loop back with a timer, not a microtask. The runner's running-set guard still stops the same duty running twice at once. The tests would fail without the change: counted slices cap at 40 and the result is whole, and a timer set before the pass fires before it ends. No page or terminal door is touched, so no how-to is due. Two things I would do next: (1) the two sync glob listings (
files(root, "src/*/.ts")and the test glob) still run in one go before the first breath. Time them, and slice them if they show up in[loop]. (2) Export aSlicetype from kernel/breathe.ts soReturnType<typeof sliced>is not repeated in both duties. -
Checks
waiting merged; waiting for the forge to restart on it deploy 5fa2c54
-
History
- Counting slice in the untested-sources test needs no timer (#17823) 94bf318
- Untested-sources and dead-doc-paths read in 20 ms slices and breathe between them (#17823) 67b22bf
- Talk's Stop stays for the whole answer, with words in the box too (#17819) b51ab2e
- The changelog credits a model only when a run backs it (#17807) e780a4e
- The decider can be compared with SubQ Snap in the background, off by default, and decides nothing (#17795) c0cee92
- small: the '+ New forge' page has one primary next action, with phone and desktop looks on the pull (#17818) 6cc8e61
- GET pulls/:number runs an uncapped diff and renders it on the serving thread (#17812) 153cbb3
- Full suite red: 2 files in check run 01m8wzswcz0vr3fz25ryd619jz (#17814) 8f7dfc4
- A Talk build's version strip is in sight when its preview opens, on a phone and at 1000 px (#17810) bdc702e
- Talk says what a long turn is doing and how long since its last step, across every stream (#17808) dcfa7ed
- A Talk build starts no crew run and no review, and only a person publishes it (#17803) cd1d5b7
- Only a check writes a retry decision's outcome, and it says which one (#17796) c2d976e
- A crew run that hits the turn limit wraps up, and says so in its run and its pull (#17809) b35dca2
- app-home-batched boots one forge for the file, and each test has its own account and repositories (#17805) 4763617
- A follow-up in Talk always carries what the person asked; tool steps are what gets cut (#17804) 7af0ffd
- A crew run can spend a granted OpenAI-type account, on the OpenAI runner, per run (#17787) b43bdad
- Talk: the model is a button beside Send, with a list you can type in, and plain names (#17794) 191cbc2
- A release asks scripts/return-check.ts before it promotes (#17793) 7618050
- A fresh start or a redone Talk answer sends the history once (#17802) d184914
- The contributor's walk of Talk's tools makes the calls that can run, not a thousand refused ones (#17806) 791b76f
Two maintenance duties now read their files in 20 ms slices and hand the loop back between them, instead of holding it for one long pass.
Which step runs long. I couldn't read production's [loop] lines from the sandbox: /health and /system don't show them, and the perf logs are outside what I can reach. So I timed each duty's file-reading step on this checkout. The worst is untested-sources: one synchronous pass that globs 5,105 src/ files, then reads and regex-matches all 5,096 test files (~37 MB). It took 290–333 ms here, and on a loaded production host that fits the 0.2–1.5 s in the issue. Next is dead-doc-paths: 816 docs read in one pass, about 45 ms. The other duties do database queries or run git without blocking.
What changed.
untestedSources(src/maintain/duties/untested_sources.ts) anddeadDocPaths(src/maintain/duties/dead_doc_paths.ts) are nowasync. Before each file they ask the kernel's existingsliced()clock (src/kernel/breathe.ts) whether the current slice has used its 20 ms (SLICE_MS). When it has, they hand the loop back with a zero-delay timer, so waiting requests are answered first, and carry on with the next file.- Each takes an optional slice clock, which is how the tests drive it. Both duties'
runawait the result. - I reused
sliced()/breatherather than writing a new helper.
Choices.
- "The rest carries to the next tick" means the next turn of the event loop, within the same duty run. It does not mean the next 60 s runner tick.
- So a duty still finishes in one run and still counts as one run against its budget. Pausing, the timeout and never running the same duty twice at once all work as before.
- Saving a cursor between runner ticks would have needed a table or state kept in memory across the process, and that could leave a duty unfinished. Slicing inside the run already keeps each hold under the cap.
runner.tsis unchanged; it already yields between duties.
Tests.
test/maint-untested.test.ts: a backlog of 249 test files is read in slices capped at 40 files each ([40,40,40,40,40,40]plus a last slice of 9), and the result is still complete.test/maint-untested.test.ts: with a clock that is always past its slice, a timer set before the pass fires before the pass ends. That test fails if the pass never hands the loop back.test/maintain-dead-doc-paths.test.ts: the same timer check fordeadDocPaths.- I changed the existing tests that call these two functions only to
awaitthem, because the functions became async.
Checks. bun x tsc --noEmit and bun scripts/gate.ts --explain both pass (32 of 32 rules). The 181 test files named by scripts/fast.ts passed apart from one failure in the first run. A second run of the same set, filtered for failure lines, showed none, so I took that one as flaky; I didn't capture which test it was.
To try it: bun test test/maint-untested.test.ts test/maintain-dead-doc-paths.test.ts. On a running forge, the untested-sources and dead-doc-paths rows on /maintenance should report the same findings as before.
🤖 Generated with Claude Code
Two maintenance duties now read their files in 20 ms slices and hand the loop back between them, instead of holding it for one long pass.
Which step runs long. I couldn't read production's
[loop]lines from the sandbox:/healthand/systemdon't show them, and the perf logs are outside what I can reach. So I timed each duty's file-reading step on this checkout. The worst isuntested-sources: one synchronous pass that globs 5,105src/files, then reads and regex-matches all 5,096 test files (~37 MB). It took 290–333 ms here, and on a loaded production host that fits the 0.2–1.5 s in the issue. Next isdead-doc-paths: 816 docs read in one pass, about 45 ms. The other duties do database queries or rungitwithout blocking.What changed.
untestedSources(src/maintain/duties/untested_sources.ts) anddeadDocPaths(src/maintain/duties/dead_doc_paths.ts) are nowasync. Before each file they ask the kernel's existingsliced()clock (src/kernel/breathe.ts) whether the current slice has used its 20 ms (SLICE_MS). When it has, they hand the loop back with a zero-delay timer, so waiting requests are answered first, and carry on with the next file.runawait the result.sliced()/breatherather than writing a new helper.Choices.
runner.tsis unchanged; it already yields between duties.Tests.
test/maint-untested.test.ts: a backlog of 249 test files is read in slices capped at 40 files each ([40,40,40,40,40,40]plus a last slice of 9), and the result is still complete.test/maint-untested.test.ts: with a clock that is always past its slice, a timer set before the pass fires before the pass ends. That test fails if the pass never hands the loop back.test/maintain-dead-doc-paths.test.ts: the same timer check fordeadDocPaths.awaitthem, because the functions became async.Checks.
bun x tsc --noEmitandbun scripts/gate.ts --explainboth pass (32 of 32 rules). The 181 test files named byscripts/fast.tspassed apart from one failure in the first run. A second run of the same set, filtered for failure lines, showed none, so I took that one as flaky; I didn't capture which test it was.To try it:
bun test test/maint-untested.test.ts test/maintain-dead-doc-paths.test.ts. On a running forge, theuntested-sourcesanddead-doc-pathsrows on /maintenance should report the same findings as before.🤖 Generated with Claude Code
Closes #17823