Public: anyone can read this; the crew can change it.
An outliving cell's egress bytes reach the host's gauges, counted in the supervisor and sent back once #13755 lands #13929
Check · Review · Land · Live done — Landed and live in production.
With FORGECELLSOUTLIVE=on, a cell's egress bytes now reach the host's egress byte gauges (#13922). The cell's supervisor adds up the bytes and sends them back in batches instead of keeping the count to itself.
shipped production is serving it deploy 8e1361f
6 earlier comments
With FORGE_CELLS_OUTLIVE=on, a cell's egress bytes now reach the host's egress byte gauges (#13922). The cell's supervisor adds up the bytes and sends them back in batches instead of keeping the count to itself.
- Counting (
src/apps/egress.ts):recordEgressnow also passes every byte to a listener set with the newtapEgress(fn). The host never sets one; only the supervisor does. - Sending back (
src/spawn/supervisor.ts):egressBatch()adds up bytes per label and destination, capped at 64 destinations with the rest counted underother. On its existing 1-second tick, the supervisor writes oneegress-bytesevent per destination every 5 s (EGRESS_FLUSH_MS), plus once more when it stops. Bytes are never written per chunk. When the 300-a-minute events limit says no, the totals are kept for the next flush rather than lost. The TODO naming #13921 is gone, and so is the matching note insrc/spawn/cell.ts. - Host side:
parseEventaccepts anegress-bytesevent only if it has string label and destination of bounded length and whole, non-negative byte counts. When the host tails the events file, it passes each one torecordEgress, the same function an in-process cell feeds. - Tests (
test/cell-outlives-host.test.ts):
- End to end: a real supervisor process gets three CONNECT+GET requests through its proxy to a local server. The host's egressTotals stays at 0 until the events arrive, then holds all the bytes, and the events file has at most two egress-bytes lines. I checked that this test fails with the host-side recordEgress line removed.
- Event parsing: malformed and negative counts are rejected.
- Batching: a thousand chunks become one total, and a total the events limit refused is kept for the next flush.
Left out: live connection counts (egressSnapshot, open connections per destination) still don't include an outliving cell's connections; only byte totals and the per-run and per-repository registry counts come back. Supporting that would need open and close events, which is a separate change.
The test sends CONNECT over a raw socket instead of using fetch with a proxy, because NO_PROXY makes fetch go straight to loopback and skip the proxy.
Checks: bun scripts/gate.ts --fix passes and bun x tsc --noEmit is clean. scripts/fast.ts named nearly every test (because egress.ts is imported so widely), so I ran the suites that cover this instead: cell-outlives-host, egress-*, module-state, timers-named, job-slices, spawn-sites, spawn-cell, hosted-child-counters, contain, kernel-boundary and outbound-gate. All pass; the 31 skipped are the unix-socket suites this sandbox can't run, which the forge's check runs.
🤖 Generated with Claude Code
A cell that outlives its host now gets its egress bytes into the host's gauges. Its supervisor sums the bytes per label and destination. Every 5 s it writes one egress-bytes event per destination to events.jsonl. The host reads that file and passes each event to recordEgress. When a sum is refused because the events budget is spent, it is kept for the next flush. The host checks each event field by field: counts must be whole numbers that are not negative.
Fix for the failed check: the end-to-end test in test/cell-outlives-host.test.ts took 5.3 s because it had to wait for the real 5 s flush, and the budget is 2 s. Flushing now runs on its own timer in src/spawn/supervisor.ts. A new optional flushMs field (for tests only) shortens it, and parseConfig only accepts 50 ms up to the 5 s default. The test uses 300 ms and now takes about 1.2 s. Before, the flush was checked once a second on the supervisor's main timer; that timer still caps files and watches the cell.
Test change: the test now allows up to three egress-bytes lines instead of two. With a 300 ms flush, the three requests can fall across more than one flush. The unit test of the batch still checks that many chunks become one event.
The other two failures, test/etag.test.ts (signed-out ETag) and test/capacity.test.ts (crew concurrency, which hit a 30 s timeout), pass when run here. Neither touches the supervisor or egress code, so I left them alone.
Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts named 2,894 test files, far over its budget, so I ran the egress, supervisor and cell files myself: 249 pass, 0 fail. The unix-socket suites are skipped in this sandbox; the forge's check runs them.
🤖 Generated with Claude Code
A cell that outlives its host now gets its egress bytes into the host's gauges. Its supervisor sums the bytes per label and destination and, every 5 s, writes one egress-bytes event per destination to events.jsonl. The host reads that file and passes each event to recordEgress. A sum refused because the events budget is spent stays for the next flush. The host accepts an event only when it is well-formed and its counts are whole and not negative.
The flush runs on its own timer in src/spawn/supervisor.ts, wrapped in during("cell egress flush", …) like every other server-side timer. That wrapper is what the last check found missing. Before this change, the flush was checked once a second on the supervisor's main timer.
A new optional config field, flushMs, lets tests shorten the 5 s flush; parseConfig accepts 50 ms up to 5 s. The end-to-end test in test/cell-outlives-host.test.ts uses 300 ms and runs in about 1.2 s instead of 5.3 s.
Test change: the test now allows up to three egress-bytes lines instead of two, because at 300 ms the three requests can fall across more than one flush. The batch's unit test still checks that many chunks become one event.
Failures outside this change: the merge-queue tests (test/merge-queue.test.ts, test/merge-queue-gate-result.test.ts), the ETag tests and the crew concurrency test failed in earlier checks. All of them pass when run here, and none touches the supervisor or egress code.
Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. test/timers-named.test.ts, test/cell-outlives-host.test.ts and the two merge-queue files pass. scripts/fast.ts named 2,894 test files, too many to run, so I ran the egress, supervisor and cell files myself: 249 pass, 0 fail. The unix-socket suites are skipped in this sandbox; the forge's check runs them.
🤖 Generated with Claude Code
A cell that outlives its host now gets its egress bytes into the host's gauges (#13922). Its supervisor sums the bytes per label and destination and, every 5 s, writes one egress-bytes event per destination to events.jsonl. The host reads that file and passes each event to recordEgress. A sum refused because the events budget is spent is kept for the next flush. The host accepts an event only when it is well-formed and its counts are whole and not negative.
Flush timer: the flush runs on its own timer, inside during("cell egress flush", …) like every other server-side timer. A new optional config field, flushMs, lets tests shorten it; parseConfig accepts 50 ms up to 5 s. The end-to-end test uses 300 ms and runs in about 1.2 s instead of 5.3 s.
Merge with main: main had added the held beat door (#13906) in the same places, and I kept both sides:
SupervisorConfigandparseConfig: they take bothdoor/doorAtandflushMs.- File list in
src/spawn/supervisor.ts: it namesbeat.held, andevents.jsonlis described as carrying egress byte sums. - Comment on
cellsOutliveinsrc/spawn/cell.ts: it keeps main's text on the held door and now says the bytes reach the host's gauges. test/cell-outlives-host.test.ts: it holds both sets of tests.
scripts/gate.ts --fix also rewrapped comments in three files that came from main (src/spawn/host.ts, test/changelog-timing.test.ts, test/statement.test.ts), and those rewraps are in the merge commit.
Test change: the end-to-end test now allows up to three egress-bytes lines instead of two, because at 300 ms the three requests can fall across more than one flush. The batch's unit test still checks that many chunks become one event.
Checks run: bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I ran test/cell-outlives-host.test.ts, test/timers-named.test.ts and the egress, supervisor and held-door test files: 620 pass, 0 fail. The unix-socket suites are skipped in this sandbox; the forge's check runs them.
🤖 Generated with Claude Code
A cell that outlives its host now gets its egress bytes into the host's gauges (#13922). Its supervisor sums the bytes per label and destination and, every 5 s, writes one egress-bytes event per destination to events.jsonl. The host reads that file and passes each event to recordEgress. A sum refused because the events budget is spent stays for the next flush. The host accepts an event only when it is well-formed and its counts are whole and not negative.
Flush timer: the flush runs on its own timer, inside during("cell egress flush", …) like every other server-side timer. A new optional config field, flushMs, lets tests shorten it; parseConfig accepts 50 ms up to 5 s. The end-to-end test uses 300 ms and runs in about 1.2 s.
Merge with main: main added the held beat door (#13906) in the same places, and both are kept:
SupervisorConfigandparseConfig: they take bothdoor/doorAtandflushMs.- File list in
src/spawn/supervisor.ts: it namesbeat.held, andevents.jsonlis described as carrying egress byte sums. - Comment on
cellsOutliveinsrc/spawn/cell.ts: it keeps main's text on the held door and says the bytes reach the host's gauges. test/cell-outlives-host.test.ts: it holds both sets of tests.
Fix for the failed check: the merge commit had also rewrapped comments in three files the pull did not write: src/spawn/host.ts, test/changelog-timing.test.ts and test/statement.test.ts. They are now restored to main's text, so the diff against main is only the four files of this change.
Test change: the end-to-end test allows up to three egress-bytes lines instead of two, because at 300 ms the three requests can fall across more than one flush. The batch's unit test still checks that many chunks become one event.
Checks run: bun scripts/gate.ts passes and bun x tsc --noEmit is clean. test/cell-outlives-host.test.ts, test/statement.test.ts and test/changelog-timing.test.ts pass (26 tests). The unix-socket suites are skipped in this sandbox; the forge's check runs them.
🤖 Generated with Claude Code
When a cell outlives its host, its supervisor adds up the egress bytes per label and destination. Every 5 s it writes those totals to events.jsonl as egress-bytes events. The host reads that file and feeds the totals into its own egress gauges, the ones it serves (#13922).
tapEgress in src/apps/egress.ts passes the counts from recordEgress to the supervisor. egressBatch in src/spawn/supervisor.ts holds the totals between writes. It keeps at most 64 destinations; any more are added under other. If the per-minute events limit is used up, unsent totals wait for the next write. parseEvent checks label and destination length and that both byte counts are non-negative whole numbers before the host trusts an event. test/cell-outlives-host.test.ts covers the round trip.
This merges main, which now re-adopts the cells a previous host left running (#13927). The only conflict was the doc comment on cellsOutlive in src/spawn/cell.ts. The merged comment keeps main's text about cell records and adoption, and this branch's text about byte totals reaching the host's gauges as events.
Left out: a re-adopted cell's events.jsonl is not read yet. The adopt path from #13927 has no supervisor handle to read it through, so after a restart its refusals and its byte totals both go uncounted until the host starts reading that file for adopted cells. That gap comes from #13927 and is not fixed here.
bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit passes. scripts/fast.ts named most of the suite for this merge, so I ran the cell, supervisor, egress, held-door and beat tests myself: 48 files, 299 pass, 0 fail. 37 were skipped because this sandbox can't bind unix sockets or doesn't have esbuild; the forge's check runs them.
🤖 Generated with Claude Code
When a cell outlives its host, its supervisor adds up the egress bytes per label and destination. Every 5 s it writes those totals to events.jsonl as egress-bytes events. The host reads that file and feeds the totals into its own egress gauges, the ones it serves (#13922).
tapEgress in src/apps/egress.ts passes the counts from recordEgress to the supervisor. egressBatch in src/spawn/supervisor.ts holds the totals between writes. It keeps at most 64 destinations; any more are added under other. If the per-minute events limit is used up, unsent totals wait for the next write. parseEvent checks label and destination length and that both byte counts are non-negative whole numbers before the host trusts an event. test/cell-outlives-host.test.ts covers the round trip.
This merges main, which now re-adopts the cells a previous host left running (#13927). The only conflict was the doc comment on cellsOutlive in src/spawn/cell.ts, which now describes both adoption and the byte totals.
Fix for the failed check: the supervisor's timer (cell egress flush) was missing from UNTIMED in test/job-slices.test.ts, so that test was right to fail. It is now listed there with its reason, like the supervisor's other two jobs: it runs in the cell's supervisor, not the host. The other failures in the check log were in test/packs-hands.test.ts and test/take-expect.test.ts. They don't touch this change and passed three runs in a row here, so I left them alone.
Left out: a re-adopted cell's events.jsonl is not read yet. The adopt path from #13927 has no supervisor handle to read it through, so after a restart its refusals and its byte totals both go uncounted until the host starts reading that file for adopted cells. That gap comes from #13927 and is not fixed here.
Checks run here: bun scripts/gate.ts --fix changed nothing, bun x tsc --noEmit passes, and the three test files named in the check log pass. Before this fix I ran the cell, supervisor, egress, held-door and beat tests: 48 files, 299 pass, 0 fail, 37 skipped. The skips are suites this sandbox can't run (unix sockets, esbuild); the forge's check runs them.
🤖 Generated with Claude Code
No page or terminal surface changes, so the phone/keyboard/no-JS checks do not apply. The change is bounded: events are validated field by field at the host boundary, writes are batched to one per destination per flush, the budget refusal keeps the sum, and the new timer is named and listed in UNTIMED. Tests cover the round trip, parsing and batching. Next two things: (1) read events.jsonl for re-adopted cells (#13927) so their bytes and refusals are counted after a restart; (2) make the end-to-end test assert on the sum of event bytes rather than a line-count ceiling, which depends on flush timing.
With
FORGE_CELLS_OUTLIVE=on, a cell's egress bytes now reach the host's egress byte gauges (#13922). The cell's supervisor adds up the bytes and sends them back in batches instead of keeping the count to itself.src/apps/egress.ts):recordEgressnow also passes every byte to a listener set with the newtapEgress(fn). The host never sets one; only the supervisor does.src/spawn/supervisor.ts):egressBatch()adds up bytes per label and destination, capped at 64 destinations with the rest counted underother. On its existing 1-second tick, the supervisor writes oneegress-bytesevent per destination every 5 s (EGRESS_FLUSH_MS), plus once more when it stops. Bytes are never written per chunk. When the 300-a-minute events limit says no, the totals are kept for the next flush rather than lost. The TODO naming #13921 is gone, and so is the matching note insrc/spawn/cell.ts.parseEventaccepts anegress-bytesevent only if it has string label and destination of bounded length and whole, non-negative byte counts. When the host tails the events file, it passes each one torecordEgress, the same function an in-process cell feeds.test/cell-outlives-host.test.ts):- End to end: a real supervisor process gets three CONNECT+GET requests through its proxy to a local server. The host's
egressTotalsstays at 0 until the events arrive, then holds all the bytes, and the events file has at most twoegress-byteslines. I checked that this test fails with the host-siderecordEgressline removed. - Event parsing: malformed and negative counts are rejected. - Batching: a thousand chunks become one total, and a total the events limit refused is kept for the next flush.Left out: live connection counts (
egressSnapshot, open connections per destination) still don't include an outliving cell's connections; only byte totals and the per-run and per-repository registry counts come back. Supporting that would need open and close events, which is a separate change.The test sends CONNECT over a raw socket instead of using
fetchwith a proxy, becauseNO_PROXYmakesfetchgo straight to loopback and skip the proxy.Checks:
bun scripts/gate.ts --fixpasses andbun x tsc --noEmitis clean.scripts/fast.tsnamed nearly every test (becauseegress.tsis imported so widely), so I ran the suites that cover this instead:cell-outlives-host,egress-*,module-state,timers-named,job-slices,spawn-sites,spawn-cell,hosted-child-counters,contain,kernel-boundaryandoutbound-gate. All pass; the 31 skipped are the unix-socket suites this sandbox can't run, which the forge's check runs.🤖 Generated with Claude Code
Closes #13922