Correctness, and what makes sleep slow. Two things, one place.
A child forge does not leave on SIGTERM.stopGently sends SIGTERM and waits STOP_GRACE_MS = 15 s before killing the cell (src/spawn/cell.ts:43, :51-65). Measured: 37 of 37 stops and removals of an awake probe took 15.1 to 15.9 s (POST /forges/:name/stop, /remove); a sleeping one is removed in 0.5 s. The child logs forge draining: /readyz answers 503 from now why=SIGTERM at once and is still there 15 s later, so every sleep is a kill: the next start logs restarts=1 unclean=1, and the database is left with a 4 MB WAL.
stop forgets the cell before it is gone.stop(bodyId) deletes the body from held and then awaits stopGently (src/spawn/cell.ts:461-467). For those 15 s cells.get(bodyId) is undefined, so any request for that forge reads as "asleep" and answerFromCell starts it again (src/spawn/host.ts:933, settleCell). Measured, from the children's own lines in the parent's log:
forge
first forge is up
forge draining ... SIGTERM
second forge is up (same data directory, another port)
scale-12
01:21:39.179 (port 42421)
01:21:40.100
01:21:48.435 (port 41131), restarts=1 unclean=1
scale-14
01:22:07.843
01:22:10.374
01:22:25.012
scale-13
01:21:45.718
01:24:42.325
01:24:46.106
Also scale-16, -17, -18. For up to 15 s two forge processes hold one forge.db (rule: one writer per forge), and the stop does not hold: the forge is awake again seconds after "Forge stopped". In the same runs four stops (scale-13, -15, -19, -20) answered "was already asleep" in 0.2 s for a forge that had answered a request a second before and kept running; the same bookkeeping, not understood further.
Who asks during the grace: the parent's own proving of a new forge (settleChild, every 3 s for up to 3 minutes, src/spawn/reach.ts:269-289), and for scale-13 something 3 minutes after birth that I did not identify.
Wanted
A body that is stopping stays known (a stopping map): a request in that window waits for the exit, then starts it, never beside it.
A child forge with nothing in flight exits on SIGTERM in well under a second, and marks its start clean.
A test: stop a real cell child and ask for it at once; exactly one process holds the directory at any time.
Measured on production 0.7.613 (vxrail, one container, 72 CPUs, 180 GiB) on 2026-11-16 01:03-01:28Z with 20 probe forges scale-1...scale-20 (size small), all removed since. Full table: scratchpad/scale-hosting.md in the mitosis repository. Line numbers are at 9fae75f15.
Correctness, and what makes sleep slow. Two things, one place.
stopGentlysends SIGTERM and waitsSTOP_GRACE_MS= 15 s before killing the cell (src/spawn/cell.ts:43,:51-65). Measured: 37 of 37 stops and removals of an awake probe took 15.1 to 15.9 s (POST /forges/:name/stop,/remove); a sleeping one is removed in 0.5 s. The child logsforge draining: /readyz answers 503 from now why=SIGTERMat once and is still there 15 s later, so every sleep is a kill: the next start logsrestarts=1 unclean=1, and the database is left with a 4 MB WAL.stopforgets the cell before it is gone.stop(bodyId)deletes the body fromheldand then awaitsstopGently(src/spawn/cell.ts:461-467). For those 15 scells.get(bodyId)is undefined, so any request for that forge reads as "asleep" andanswerFromCellstarts it again (src/spawn/host.ts:933,settleCell). Measured, from the children's own lines in the parent's log:forge is upforge draining ... SIGTERMforge is up(same data directory, another port)restarts=1 unclean=1Also scale-16, -17, -18. For up to 15 s two forge processes hold one
forge.db(rule: one writer per forge), and the stop does not hold: the forge is awake again seconds after "Forge stopped". In the same runs four stops (scale-13,-15,-19,-20) answered "was already asleep" in 0.2 s for a forge that had answered a request a second before and kept running; the same bookkeeping, not understood further.Who asks during the grace: the parent's own proving of a new forge (
settleChild, every 3 s for up to 3 minutes,src/spawn/reach.ts:269-289), and forscale-13something 3 minutes after birth that I did not identify.Wanted
stoppingmap): a request in that window waits for the exit, then starts it, never beside it.Measured on production 0.7.613 (vxrail, one container, 72 CPUs, 180 GiB) on 2026-11-16 01:03-01:28Z with 20 probe forges
scale-1...scale-20(size small), all removed since. Full table:scratchpad/scale-hosting.mdin the mitosis repository. Line numbers are at9fae75f15.