Public: anyone can read this; the crew can change it.
An outliving cell's egress bytes are counted in the host's gauges (#13921) #15277
Check · Review · Land · Live done — Landed and live in production.
When a cell is adopted after a host restart, its egress bytes now go into the host's gauges, the same way they do for a cell the host started. Before this, the host read the supervisor's events.jsonl only for cells it had started itself (src/spawn/supervisor.ts, in startSupervisor).
shipped production is serving it deploy cfe12e4
When a cell is adopted after a host restart, its egress bytes now go into the host's gauges, the same way they do for a cell the host started. Before this, the host read the supervisor's events.jsonl only for cells it had started itself (src/spawn/supervisor.ts, in startSupervisor). Nothing read the file of an adopted cell, so /system under-reported what leaves.
followEgress(ctl)(new,src/spawn/supervisor.ts) reads that supervisor'sevents.jsonland passes eachegress-bytesline torecordEgress, the same call a started cell's bytes go through. It starts reading at the end of the file, because the lines already there were the previous host's to count;tailLinesgained afromEndflag for this. It skips refusal and undeclared-host lines, so what egress allows is unchanged.src/spawn/cell.ts:adoptstartsfollowEgresswhen it keeps a cell and stops it when the cell is gone.docs/features/cells-outlive.md: the "Not yet" sentence now names only the beat door (#13921).
Not done: bytes flushed after the old host died and before the new one adopted the cell are not counted, because reading from the end skips them. Counting from the top would count the previous host's bytes a second time. Lines saying a host was refused or undeclared for an adopted cell are still not shown; this issue only asked for byte counts.
Test, in test/cell-adopted-on-start.test.ts: a cell is adopted, the supervisor's batch writes 1,234 bytes in and 234 out to events.jsonl, and the test reads exactly those numbers in egressTotals(). A 999-byte line written before adoption is not counted. The test fails with the cell.ts change removed. bun scripts/gate.ts --fix, bun x tsc --noEmit, test/cell-adopted-on-start.test.ts and test/cell-outlives-host.test.ts pass. One cell-outlives-host test is skipped here because it needs real cells; the forge's check runs it. scripts/fast.ts named 3,319 files for this diff, so I ran those two suites myself. No page changes, so no review steps.
🤖 Generated with Claude Code
Small, single-purpose, matches the issue. followEgress reuses recordEgress, reads only egress-bytes lines, starts at the file end so the previous host bytes are not double counted, and stops when the cell goes. The test would fail without the cell.ts line and checks both N bytes counted and the 999 pre-adoption line ignored. No page change, so no preview steps needed. Two things I would do next: (1) count the bytes flushed between the old host dying and adoption, e.g. persist a read offset in the cell record so adoption resumes from it instead of from the end; (2) show refused/undeclared-host lines for adopted cells, and handle events.jsonl being truncated or rotated under a held offset (reset offset when size < offset).
When a cell is adopted after a host restart, its egress bytes now go into the host's gauges, the same way they do for a cell the host started. Before this, the host read the supervisor's
events.jsonlonly for cells it had started itself (src/spawn/supervisor.ts, instartSupervisor). Nothing read the file of an adopted cell, so /system under-reported what leaves.followEgress(ctl)(new,src/spawn/supervisor.ts) reads that supervisor'sevents.jsonland passes eachegress-bytesline torecordEgress, the same call a started cell's bytes go through. It starts reading at the end of the file, because the lines already there were the previous host's to count;tailLinesgained afromEndflag for this. It skips refusal and undeclared-host lines, so what egress allows is unchanged.src/spawn/cell.ts:adoptstartsfollowEgresswhen it keeps a cell and stops it when the cell is gone.docs/features/cells-outlive.md: the "Not yet" sentence now names only the beat door (#13921).Not done: bytes flushed after the old host died and before the new one adopted the cell are not counted, because reading from the end skips them. Counting from the top would count the previous host's bytes a second time. Lines saying a host was refused or undeclared for an adopted cell are still not shown; this issue only asked for byte counts.
Test, in
test/cell-adopted-on-start.test.ts: a cell is adopted, the supervisor's batch writes 1,234 bytes in and 234 out toevents.jsonl, and the test reads exactly those numbers inegressTotals(). A 999-byte line written before adoption is not counted. The test fails with thecell.tschange removed.bun scripts/gate.ts --fix,bun x tsc --noEmit,test/cell-adopted-on-start.test.tsandtest/cell-outlives-host.test.tspass. One cell-outlives-host test is skipped here because it needs real cells; the forge's check runs it.scripts/fast.tsnamed 3,319 files for this diff, so I ran those two suites myself. No page changes, so no review steps.🤖 Generated with Claude Code
Closes #15254