Public: anyone can read this; the crew can change it.
Memory held, not hit: slow or refuse new processes in a Small child near its limit before any stop #11982
This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and tsc are clean.
stopped parked by the crew deploy d9f0fa0
3 earlier comments
This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and tsc are clean. I ran only the new tests and the neighbouring dispatch, checks and vitals suites (all green). I did not run the full suite, because scripts/fast.ts reported 2494 of 2992 files, so I picked the covering ones. I did not run it in a real cell, so nothing here shows the 2 GiB journey fits.
What changed
- New
src/spawn/memory_guard.tsreads the forge's own cgroup throughselfUse. At 70% of its size's memory limit (MEMORY_HOLD), a child refuses to start new work. A forge that is not a cell child is never refused. runStep(src/apps/process.ts) will not start a check cell when held. It logs one line and fails with the refusal, as the 80%-disk guard does.- The check pick (
startableinsrc/checks/service.ts) leaves checks queued while held. A step refused for memory is queued again withMEMORY_HELD_SUMMARYand never goes red. - The dispatcher (
src/crew/dispatch.ts) leaves queued crew runs queued, one log line each. It records them under a new hold causememory, which vitals names as "the forge being near its memory limit". - Tests are in
test/memory-held.test.ts; the how-to isdocs/features/memory-held.md.
Not done (stays open on #11975)
- Smaller heap (
--smol) for the child's Bun processes. - Test shards one at a time.
- Reclaiming idle app cells.
- A stop that takes the largest process instead of the whole forge. The host-side stop in
src/apps/contain.tsis unchanged. - An agent's own shell commands are not gated, because they are not started through
runStep. A single builder run can still push the forge past the limit. Fault 1 (a first ask makes a new app) is what should keep that run small. - Faults 1 and 4 are separate pulls.
- Not proven for a real Small forge: 70% is a threshold I chose, not a measured one.
Try it: there is no page change. In a child forge with FORGE_CELL_SIZE=small, push a check while it uses 70% or more of 2 GiB. The check log shows queued, not started: this forge is using … and the run stays queued until memory drops.
🤖 Generated with Claude Code
Nothing needs fixing and I pushed nothing new. The preview deploy didn't fail on anything in my change.
- Deploy log: it shows the app starting,
ready:,servinganddone:, with no error. The preview answers 200 at/. - "No tests declared, none run": this is the state of the preview deploy, not a failure.
forge.jsonhas no app-leveltestfor it. The tests run through thecheckblock, and that check readsgreenon #11982 at headf89250b. - Possible tooling issue: if that "no tests declared" line is what marked the deploy failed, that looks like a deploy-tooling issue. A repo whose tests all run in
checkwould hit it on every pull.
Pull #11982 is otherwise unchanged and its description still applies.
This push fixes the gate failure: two comment lines were over 100 columns, and I rewrapped them. The gate and bun x tsc --noEmit now pass locally. I did not rerun the tests, because the change only moves line breaks inside comments.
- Changed: the comment at
src/crew/dispatch.ts:1706and the one atsrc/checks/service.ts:932. No code changed. - Why the gate stayed red at first: it reads the lines the pull adds from the commit, so it only went green once I committed the rewrap.
The pull still holds new work in a child near its memory limit (#11980). Checks and crew runs stay queued instead of failing or being refused.
This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and
tscare clean. I ran only the new tests and the neighbouring dispatch, checks and vitals suites (all green). I did not run the full suite, becausescripts/fast.tsreported 2494 of 2992 files, so I picked the covering ones. I did not run it in a real cell, so nothing here shows the 2 GiB journey fits.What changed
src/spawn/memory_guard.tsreads the forge's own cgroup throughselfUse. At 70% of its size's memory limit (MEMORY_HOLD), a child refuses to start new work. A forge that is not a cell child is never refused.runStep(src/apps/process.ts) will not start a check cell when held. It logs one line and fails with the refusal, as the 80%-disk guard does.startableinsrc/checks/service.ts) leaves checks queued while held. A step refused for memory is queued again withMEMORY_HELD_SUMMARYand never goes red.src/crew/dispatch.ts) leaves queued crew runs queued, one log line each. It records them under a new hold causememory, which vitals names as "the forge being near its memory limit".test/memory-held.test.ts; the how-to isdocs/features/memory-held.md.Not done (stays open on #11975)
--smol) for the child's Bun processes.src/apps/contain.tsis unchanged.runStep. A single builder run can still push the forge past the limit. Fault 1 (a first ask makes a new app) is what should keep that run small.Try it: there is no page change. In a child forge with
FORGE_CELL_SIZE=small, push a check while it uses 70% or more of 2 GiB. The check log showsqueued, not started: this forge is using …and the run stays queued until memory drops.🤖 Generated with Claude Code
Closes #11980