The naïve story
You'd think FastAPI's request.is_disconnected() lets you detect when Dad hits the stop button mid-stream, gracefully drain the adapter, and write a clean 'aborted' marker to the JSONL. You'd be wrong, and Dad caught me on this.
What actually happens — when the SSE generator is the consumer
When the client disconnects from a StreamingResponse, Starlette cancels the entire ASGI task. The cancellation fires a CancelledError at whatever await is currently suspended — almost always the __anext__() on the adapter. The cancellation reaches the loop before the next iteration's is_disconnected() check ever runs. So on any route where the SSE generator is itself the thing consuming the adapter — which is still how seven of the eight chat routes are built (Cradle's, added on 2026-10-29, is one of them):
- The
disconnectedflag and thepippa_user_abortedmarker code paths almost never fire. - Whatever was already eagerly appended before the cancellation is durable — that's everything Dad saw streaming on screen.
- Whatever the adapter was about to emit between the cancellation point and the natural end of the turn is lost.
The invariant those routes keep
Anything Dad watched stream onto his screen is in the JSONL. Not 'everything the adapter ever generated.'
The healing layer (Truth track, lesson 4) reconstructs from what is in the JSONL. Since by construction that matches what Dad saw, the system never presents broken chat. The invariant is about the conversations that keep a JSONL at all: a private conversation writes none, by design (Truth track, lesson 7). One held-back case sits under that sentence: on a Mac whose veil key exists but will not read, the lines Dad watched wait in memory and reach the JSONL only when the key reads again. If the process dies first, those lines are lost, and for a turn still streaming they were its only record: the assistant segment still streaming reaches SQLite only when it ends (a steered Claude turn commits each earlier segment as it goes, so only the segment still streaming is exposed), so what Dad saw of it is then in neither store (lesson 4).
What the canonical route does instead
The Claude route stopped living with that. It splits the work in two: a pipeline task that calls the adapter, writes the JSONL and SQLite and every other side effect, and pushes SSE lines onto a queue; and a thin generator that only relays that queue to the browser. A disconnect cancels the relay and nothing else. The pipeline is detached into a set of background streams the server keeps track of, runs to its natural end, and lands everything. At shutdown the server gives those streams up to thirty seconds to finish before it cancels what remains.
So on that route the stronger invariant holds: everything the adapter generated lands, not only what Dad happened to be watching. The other seven routes, Cradle's included, have not adopted the split. That is Rule 2 read the other way round — a guarantee the ancestor grows does not flow sideways into the variants on its own.