Public: anyone can read this; the crew can change it.
A request during a forge's stop waits for the old process to be gone and starts it once: one data directory never has two forge processes #13897
Issue #13814 (second half: "stop forgets the cell before it is gone").
stopped closed without shipping deploy ec0ec01
Superseded by #13824 (d7c1cd6e5 on main), which landed while this pull was in check: the same guard in the same place (a stopping map in the cell registry that start waits on), a test with one live process, and the child leaving at once on SIGTERM as well. This branch now conflicts with it in src/spawn/cell.ts, and merging both would leave two mechanisms for one rule, so I am closing this one instead of resolving.
One case here that main does not have, left for whoever wants it: a stop asked while the forge is still starting returns at once on main (nothing is held yet) and the start carries on; for a removal that is a process coming up on a directory being deleted. test/one-process-per-forge.test.ts on this branch has a test for it ("a stop asked while the forge is starting waits for the start and stops what came up").
🤖 Generated with Claude Code
Issue #13814 (second half: "
stopforgets the cell before it is gone"). Measured on production on 2026-11-16: a stop takes about 15 s, and six times a request that arrived in those seconds started a second forge process on the sameforge.db(scale-12, -13, -14, -16, -17, -18), because the registry forgot the child before its process had left and the request read it as asleep.What is now true
src/spawn/cell.tshas one lock for each child data directory (inTurn, kept per parent app).launch, the one place a child's process is made, takes the directory's turn before anything is started;stopholds the turn untilstopGentlyhas seen the old process gone.startingalready made them one flight; the flight now includes the wait). The request is held as any wake is (wakeLimits.waitMs, 20 s) and answered with the forge's own page; past that it gets the existing "Waking up" page, which asks again by itself.Test
test/one-process-per-forge.test.ts, with real processes that leave only when the test lets them (no timers): eight starts fired during a stop make no process while the old one is alive, then one; the count of live processes at the moment each is made is[0, 0]. With the lock taken out, the first two tests fail (Expected: 1, Received: 2).Not in this pull: the 15 s itself (a child forge that does not leave on SIGTERM, first half of #13814), the serial idle sweep (#13815), and the four stops that answered "was already asleep" at the owner's button (
sleepChildinhost.tsstill reads a forge that is mid-start as asleep; the registry no longer loses it, but the sentence is unchanged). No limit, ceiling or confirmation is added or changed.Checked:
bun x tsc --noEmitexit 0;bun scripts/gate.tsexit 0; on Linux in the 0.7.614 image, the always-run set plusone-process-per-forge,first-ten-minutes,spawn-cell,forges-memory,forge-sleep: 1545 pass, 0 fail.🤖 Generated with Claude Code