Public: anyone can read this; the crew can change it.
Suspension, removal and sign-out close streams held on hosted child forges #14985
Check · Review · Land · Live done — Landed and live in production.
When an account is suspended or removed, or a browser is signed out, the streams it holds open on a hosted child forge served in-process now close. That covers event streams, app sockets and git transfers in progress. Until now they stayed open until the client disconnected.
shipped production is serving it deploy 6b7374e
When an account is suspended or removed, or a browser is signed out, the streams it holds open on a hosted child forge served in-process now close. That covers event streams, app sockets and git transfers in progress. Until now they stayed open until the client disconnected. This closes the deepsec finding from #14765.
What changed (src/http/server.ts)
- The code in
serve()that ends what an account holds open is now one function,enforceStanding(app). It listens foraccount.suspended,account.removedandsession.endedon the forge's bus and closes matching streams at once. A timer also checks the forge's database (sweepStanding), which catches a change written by another process. Matching is by account and session id, not by scanning every stream.serve()calls it for its own forge. forgeHttp(child)now callsenforceStanding(child)too. Itsclose()used to do nothing. Now it stops the listener and the timer, andletGoalready calls it when a child closes or the server stops.- The issue pointed at
src/http/caller.ts, but that file didn't need to change: it already keeps one list of held streams per forge database. What was missing was anything closing a child's streams, so the fix is inserver.ts.
Test (test/standing-hosted-child.test.ts)
It opens /events through forgeHttp(child) and checks that the stream ends in three cases:
- the account is suspended on the child;
- the browser is signed out on the child;
- the suspension is written by a second process on the child's data, so only the child's timer can catch it.
All three fail against main's server.ts and pass with the change.
Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts named 2,508 test files, too many to run here, so I ran the suites that cover this change: standing-every-process, standing-hosted-child, standing-live, standing-rule, standing, hosted-child-cells, hosted-child-counters, hosted-child-crew, sse and mcp-account-suspend. 49 pass, 0 fail.
Left out: children that run in their own cell are not covered here; each one runs its own serve().
Try it: on a hosted child, open /events while signed in, then suspend that account from the child's admin. The stream ends.
🤖 Generated with Claude Code
When an account is suspended or removed, or a browser is signed out, the streams it holds open on a hosted child forge served in-process now close. That covers event streams, app sockets and git transfers in progress. Until now they stayed open until the client disconnected. This closes the deepsec finding from #14765.
What changed (src/http/server.ts)
- The code in
serve()that ends what an account holds open is now one function,enforceStanding(app). It listens foraccount.suspended,account.removedandsession.endedon the forge's bus and closes matching streams at once. A timer also checks the forge's database (sweepStanding), which catches a change written by another process. Matching is by account and session id, not by scanning every stream.serve()calls it for its own forge. forgeHttp(child)now callsenforceStanding(child)too. Itsclose()used to do nothing. Now it stops the listener and the timer, andletGoalready calls it when a child closes or the server stops.- The issue pointed at
src/http/caller.ts, but that file didn't need to change: it already keeps one list of held streams per forge database. What was missing was anything closing a child's streams, so the fix is inserver.ts.
Test (test/standing-hosted-child.test.ts)
It opens /events through forgeHttp(child) and checks that the stream ends in three cases:
- the account is suspended on the child;
- the browser is signed out on the child;
- the suspension is written by a second process on the child's data, so only the child's timer can catch it.
Each test waits for the stream to end with no timer of its own, so a stream that stays open fails it by bun's test timeout. Against main's server.ts all three fail that way; with the change they pass.
Checks run: bun scripts/gate.ts and bun x tsc --noEmit are clean. scripts/fast.ts named 2,508 test files, too many to run here, so I ran the suites that cover this change: standing-every-process, standing-hosted-child, standing-live, standing-rule, standing, hosted-child-cells, hosted-child-counters, hosted-child-crew, sse and mcp-account-suspend, all passing. The new test and standing-every-process were run again after the timer fix.
Left out:
- Children that run in their own cell are not covered here; each one runs its own
serve(). - The gate says the new test's
personandstreamOnhelpers look like the ones intest/standing-every-process.test.ts. That is a warning, not a failure, and I left them separate rather than moving them into a shared helper.
Try it: on a hosted child, open /events while signed in, then suspend that account from the child's admin. The stream ends.
🤖 Generated with Claude Code
Clean. enforceStanding(app) is the old serve() block moved into one function, and forgeHttp(child) now calls it. close() stops both the bus subscription and the sweep timer, and it is idempotent. Every other forgeHttp caller (tui api, preview-seed, the child cache in serve) calls close() or hands it to letGo, so no timer leaks. Matching is by account and session id from the forge's own bus and database, and no client-written value is trusted. No new surface, so the page, terminal and docs rules do not apply. The tests cover suspend, sign-out, and a suspension written by another process that only the child's sweep can catch. Their own comments say a stream left open fails them by timeout, which is what they would do on main. The gate reports the test helpers as near-duplicates of standing-every-process; that is a warning, so I am not asking for a change.
When an account is suspended or removed, or a browser is signed out, the streams it holds open on a hosted child forge served in-process now close. That covers event streams, app sockets and git transfers in progress. Until now they stayed open until the client disconnected. This closes the deepsec finding from #14765.
What changed (
src/http/server.ts)serve()that ends what an account holds open is now one function,enforceStanding(app). It listens foraccount.suspended,account.removedandsession.endedon the forge's bus and closes matching streams at once. A timer also checks the forge's database (sweepStanding), which catches a change written by another process. Matching is by account and session id, not by scanning every stream.serve()calls it for its own forge.forgeHttp(child)now callsenforceStanding(child)too. Itsclose()used to do nothing. Now it stops the listener and the timer, andletGoalready calls it when a child closes or the server stops.src/http/caller.ts, but that file didn't need to change: it already keeps one list of held streams per forge database. What was missing was anything closing a child's streams, so the fix is inserver.ts.Test (
test/standing-hosted-child.test.ts) It opens/eventsthroughforgeHttp(child)and checks that the stream ends in three cases:All three fail against main's
server.tsand pass with the change.Checks run:
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean.scripts/fast.tsnamed 2,508 test files, too many to run here, so I ran the suites that cover this change:standing-every-process,standing-hosted-child,standing-live,standing-rule,standing,hosted-child-cells,hosted-child-counters,hosted-child-crew,sseandmcp-account-suspend. 49 pass, 0 fail.Left out: children that run in their own cell are not covered here; each one runs its own
serve().Try it: on a hosted child, open
/eventswhile signed in, then suspend that account from the child's admin. The stream ends.🤖 Generated with Claude Code
Closes #14963