carlos / platform Public

edge-held-streams: design rev 2 after Astra round 1 (#432)

Summary

Accepts all ten round-1 findings: the activator owns leg admission and cancels legs synchronously in beginStopLocked and the swap switch; redirects become 204; no capability fallback; one classification point ahead of every dispatch; legs run through the route's own proxy; reopen rule bounds amplification; admissibility replaces actAwake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 538fdfe33cac6291e3d377b9087d6f1b33bdb92b parent 9ca0d92
3 files changed, +556 −158
  • docs/superpowers/specs/2026-10-28-edge-held-streams-design.md +301 −158
  • docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md +154 −0
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md +101 −0

CI passed — run details

diff --git a/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md b/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md
index ccff3fa36..e72a2fbb7 100644
--- a/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md
+++ b/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md
@@ -1,7 +1,11 @@
# Edge-held event streams — design
Discussion: carlos/platform #432 (feature request from Rastrillo, with the
-amendment in post 835). Status: draft, rev 1, 2026-10-28.
+amendment in post 835). Status: draft, rev 2, 2026-10-28.
+
+Review history: round 1 (Astra, `CODEX-FINDINGS-edge-held-streams.md`):
+NOT READY, 4 P1 and 6 P2. All ten are accepted in rev 2 and marked
+**(r1 P1-n / P2-n)** where they land. None declined.
## 1. Intent
@@ -33,10 +37,12 @@ Goals:
- G3. While the instance sleeps, the browser's connection stays open and alive
(edge heartbeats). When the instance wakes, the edge reopens the upstream
with `Last-Event-ID` and the browser sees one unbroken stream.
-- G4. **No silent stream**: while the instance is awake, a held downstream
- always has an upstream, or is being reconnected to one within a bounded
- time, or is closed. The page never goes quiet with nothing to say so.
-- G5. Works for every app with no app change beyond the opt-in marker, and
+- G4. **No silent stream**: while the host is *admissible* (§3.5), a held
+ downstream has an upstream leg, or is inside a bounded reopen delay
+ (§3.6), or is closed. Its quiet time is bounded by one tick (§3.7).
+- G5. **No stream holds up a stop.** Every upstream leg is cancelled before
+ the process (or generation) it is connected to is signalled to stop.
+- G6. Works for every app with no app change beyond the opt-in marker, and
costs no bucket reads and no S3 requests.
Non-goals:
@@ -46,6 +52,7 @@ Non-goals:
- Knowing whether the page applied an event. `Last-Event-ID` at the edge says
delivered, not applied; Rastrillo tracks fetches owed in the browser.
- WebSockets, long-poll, or any non-SSE stream.
+- Redirects on a held stream (§3.3).
- Cross-origin streams (§5.8).
- Fanning events out between replicas or boxes. An app's `Notify` reaches the
streams its own process holds; that is the app's design, not the edge's.
@@ -55,7 +62,8 @@ Non-goals:
Anti-goals (a failure even if it works):
- Any path by which an opted-in stream keeps an instance awake, including a
- fallback to a plain proxied stream when a bound is hit.
+ fallback to a plain proxied stream when a bound is hit or a capability is
+ missing.
- Any path by which an outsider's request wakes an instance it would not have
woken without the marker.
- A per-request bucket or registry read on the hold path.
@@ -68,22 +76,34 @@ An app opts a stream in by putting `carlos_hold=1` in the stream's query
string: `new EventSource("/live?carlos_hold=1")`. Paul accepted this over a
list of stream paths in the app's config.
-A request is a **held-stream request** when all of these hold:
+**Classification** happens once, on the edge whose activator manages the
+host, immediately after the upstream lookup (§3.8). A request is **marked**
+when its query has the parameter `carlos_hold` with the exact value `1`. On
+a route whose upstream is `hibernating` (`ActivatorOwned() && !viaTunnel`)
+and whose row has `Hibernate` set, a marked request is one of:
+
+- a **held-stream request**: GET, `Accept` includes `text/event-stream`
+ (every `EventSource` sends it), not an upgrade. It goes to the hold
+ branch;
+- anything else marked (another method, no SSE `Accept`, an upgrade):
+ answered `400` by the edge **(r1 P2-1)**.
+
+Either way, **a marked request to a hibernating route never reaches
+`act.ServeHTTP`, the asset catch, the shared cache, or an upgrade dispatch.**
+That is the invariant G1/G2 rest on, and it is enforced in one place: the
+classification sits ahead of every one of those dispatches, and nothing
+after it re-reads the marker.
-- the method is GET;
-- the query has the parameter `carlos_hold` with the exact value `1`;
-- the `Accept` header includes `text/event-stream` (every `EventSource`
- sends it);
-- the route is a hibernating instance this box's activator manages (the
- upstream's `hibernating` flag, which is `ActivatorOwned() && !viaTunnel`,
- and `rt.Hibernate`). On any other route the marker is stripped and the
- request proxied exactly as today.
+On any other route (always-on, resident, a service, a static site) the
+marker is stripped and the request proxied exactly as today: there is no
+sleep there to protect.
The holding edge strips `carlos_hold` from the query before any upstream
leg, leaving the rest of the raw query byte for byte (no re-encoding, no
reordering). The app never sees the marker. An edge that forwards the
-request elsewhere (a backhaul hop, a fleet tunnel) does **not** strip it: the
-marker has to reach the edge that will hold the stream (§3.4).
+request elsewhere (a backhaul hop, a fleet tunnel) does **not** strip it and
+does not classify: the marker has to reach the edge that will hold the
+stream (§3.4).
Why the marker is safe to accept from anyone: like `X-Carlos-Sidecar`, it
only weakens the sender's own request (no activity credit, no wake). It
@@ -91,106 +111,183 @@ cannot suppress another client's activity and cannot wake anything. The one
thing an outsider can do with it is take up held-stream slots (§3.6), which
is equally true of any opt-in.
-### 3.2 Activity and wake semantics
-
-Every upstream leg of a held stream (first open and every reopen) goes
-through the sidecar admission path, `activator.BeginSidecarRequest`, not
-`begin`:
-
-- awake: proceed, no in-flight count, no stamp;
-- waking (someone else's wake): join it and proceed when it finishes;
-- asleep, stopping, fenced, shutting down: no leg; the stream is held.
-
-Nothing on the hold path calls `begin`, so G1 and G2 hold by construction.
-The browser's request itself is not counted either: the holding handler
-answers it entirely outside `begin`.
+### 3.2 The activator owns leg admission and cancellation (r1 P1-1, P1-2, P1-4, P2-5)
+
+Every upstream leg (first open and every reopen) is admitted by the
+activator, which registers it against the entry and the generation it was
+admitted on, under `a.mu`, in the same step that decides it may run. The
+Activator seam (`edge.Activator`) gains these methods. They are part of the
+required interface, not an optional one: the edge and activator ship in one
+binary, test fakes get them too, and a nil activator already means no route
+is `hibernating`. There is no "holding unsupported" fallback to proxy through
+**(r1 P1-4)**.
+
+- `AdmitHeldLeg(ctx, rt) (HeldLeg, error)`. Same decisions as
+ `BeginSidecarRequest` (awake: admit; waking: join, then decide; asleep,
+ stopping, fenced, probe-held, shutting down, child dead: refuse with no
+ wake), plus: on admit, under `a.mu`, it records the leg on the entry with
+ the current generation number and a cancel function. It never calls
+ `begin`, never touches `inflight` or `lastActive`.
+- `HeldLeg` carries `Context()` (derived from `ctx`, cancelled by the
+ activator as below), and `Done()` to deregister when the leg ends.
+- `HeldAdmissible(host) bool`: in-memory, under `a.mu`; true exactly when
+ `AdmitHeldLeg` would admit without waiting. It is the same predicate,
+ written once and used by both **(r1 P2-5)**.
+- `SetHeldWakeHook(func(host string))`: called, outside `a.mu`, when a host
+ becomes admissible: a wake completes, a recovery probe releases its hold,
+ a fence lifts. The edge side is a non-blocking per-host channel send; the
+ hook may drop a signal and nothing depends on it except latency (§3.7).
+
+**Cancellation is synchronous and lives with the stop, not with a
+notification.** One helper, `cancelHeldLegsLocked(e, gen)`, cancels every
+registered leg on the entry (or on one generation of it). It only calls
+context cancel functions, so it is safe under `a.mu` and never blocks. It
+is called:
+
+- from `beginStopLocked`, before the stop goroutine is started, for every
+ generation of the entry. Every stop reason that goes through it (idle,
+ lease lost, exited, fenced, restart, release, retired, shutdown) is
+ covered;
+- in the swap's switch critical section (`swap.go`, beside
+ `interruptCmdsLocked(e, retiring.gen.N, …)`), for the retiring
+ generation, before `genRetired` and before the retiring generation's
+ drain **(r1 P1-1)**.
+
+The plan enumerates the remaining direct process-stop calls that do not pass
+through `beginStopLocked` (for example `maintenance.go`'s and the restart
+path's `proc.Stop` calls) and routes each through the helper. A guard test,
+in the style of the swap simulation's markers, fails when a process-stop call
+site exists without it.
+
+Why this closes the races **(r1 P1-2)**: admission and registration are one
+step under `a.mu`, and so are the state change to stopping (or the
+generation switch) and cancellation. A leg is either registered before the
+stop, and cancelled by it, or admitted after it, and refused. A leg that
+was admitted and then cancelled before it dialled fails its dial at once.
+Through the generation proxy, a leg registered on generation N can only
+reach N: the switch that makes N+1 current cancels N's legs in the same
+critical section, so a leg whose dial happens after the switch already has
+a cancelled context. The process's SIGTERM drain therefore never has a held
+stream handler to wait for.
+
+When a leg's context is cancelled, the edge treats it exactly as "upstream
+ended" (§3.3 step 6): if the host is admissible (a swap: the successor is
+current), it reopens at once; if not (a stop), it holds.
### 3.3 Hold, relay, resume: the per-stream loop
-Each held stream is one goroutine on the holding edge, owning the browser's
-connection, with this loop:
-
-1. **Register** the stream in the host's held set (§3.5) before checking the
- instance's state, so a wake that lands between the check and the
- registration still finds it.
-2. **Admit** an upstream leg (§3.2). If admitted, open it: the original
- method, path and raw query (marker stripped), the original headers minus
- hop-by-hop headers, and `Last-Event-ID` set to the last id the edge has
- relayed (or the browser's own `Last-Event-ID` before the first one).
-3. **First leg, instance awake** (the browser has had no response yet): the
- upstream's response becomes the browser's. A 200 `text/event-stream`
- is relayed and the loop continues; anything else is passed through as
- is (status, headers, body), and the stream ends. A session that expired
- answers 401 or 303, and the browser's `EventSource` fails with the app's
- real answer instead of looping.
-4. **Not admitted** (asleep): if the browser has had no response yet, the
- edge writes `200`, `Content-Type: text/event-stream`,
- `Cache-Control: no-cache`, and flushes. The stream is now held: the edge
- sends heartbeats (§3.7) and waits for a wake signal or a tick.
-5. **Reopen** (any leg after the browser has its response): the upstream
- must answer 200 `text/event-stream`. Anything else (401, 403, 303, 404,
- 5xx) closes the browser's stream. The browser reconnects to the same
- marked URL; that reconnect is a fresh held-stream request, so step 3
- passes the app's real answer through and the browser stops (#432 item 6
- as corrected in post 835).
-6. **Upstream ends.** Ask the activator whether the host is awake:
- - not awake (stopping or asleep): back to held (step 4's heartbeats);
- - awake: the app ended the stream itself (it bounds stream lifetime).
- Reopen at once (step 2). Rapid ends are backed off (§3.6).
-7. **Browser ends** (disconnect, context done): close any upstream leg and
- deregister.
-
-Relaying is per event, not per byte. The edge reads the upstream line by line
-and writes an event downstream, flushed, when its terminating blank line
-arrives. That is the only buffering: one event in progress, capped at
-64 KiB (an event over the cap closes the stream). Event framing is what
-makes the rest safe: a heartbeat is only ever written between events, and an
-upstream that dies mid-event leaves nothing half-written for the next leg's
-first event to merge into. The edge tracks `id:` exactly as the SSE spec
-defines the last event ID (an `id` field containing NUL is ignored; an empty
-`id` resets it). `retry:` and comment lines are relayed as part of the event
-they arrive in, or on their own if they arrive alone.
+Each held stream is owned by one **stream task** on the holding edge. It is
+the only writer of the browser's connection. Leg readers and timers feed it
+over channels, so no blocking read or admission can stall heartbeats,
+cancellation or the maximum hold (§3.6) **(r1 P2-3)**.
+
+1. **Register** the stream in the host's held set before anything else, so a
+ wake signal that lands during the next step still finds it.
+2. **Admit** a leg (§3.2). Admission can wait up to `wakeWaitBound` when it
+ joins another request's wake. The first response is never kept waiting
+ for that: if the browser has had no response 2 seconds after the stream
+ task started, the edge commits its own held response (step 4) and the
+ admission carries on behind it.
+3. **First leg, browser has no response yet.** The leg's response becomes
+ the browser's:
+ - `200` with `Content-Type: text/event-stream` and identity encoding:
+ the edge writes the leg's headers through the shared response hooks
+ (§3.3a), minus `Content-Length`, `Content-Encoding`,
+ `Transfer-Encoding` and hop-by-hop headers **(r1 P2-2)**, and starts
+ relaying;
+ - a `3xx`: **not followed and not passed through.** The browser's Fetch
+ would follow it and the request it then makes carries no marker, so it
+ would be counted and could wake the host **(r1 P1-3)**. The edge
+ answers `204 No Content` instead, which a native `EventSource` treats
+ as final (it stops and does not reconnect). Apps that want the page to
+ react to an expired session answer 401 or 403;
+ - any other status (401, 403, 404, 5xx…): passed through as is, through
+ the shared response hooks. The browser's `EventSource` stops with the
+ app's real answer;
+ - `200` that is not identity-encoded `text/event-stream`: `502`, logged
+ throttled per host.
+4. **Not admitted, or the 2-second commit.** If the browser has had no
+ response yet, the edge writes `200`, `Content-Type: text/event-stream`,
+ `Cache-Control: no-cache`, and flushes. These are the edge's own headers;
+ none of the app's are sent. The stream is now held: heartbeats run
+ (§3.7) and the task waits for a wake signal, a tick, or its admission
+ finishing.
+5. **Reopen** (any leg after the browser has a response): the leg must
+ answer `200` identity `text/event-stream`. Its response headers are
+ discarded (the browser's headers went out with the first response; a
+ `Set-Cookie` on a later leg is lost, which the app docs say). Anything
+ else, including a `3xx` (not followed), closes the browser's stream. The
+ browser reconnects to the same marked URL; that is a fresh held-stream
+ request, so step 3 gives it the app's real answer and it stops (#432
+ item 6 as corrected in post 835).
+6. **Leg ends** (upstream EOF, transport error, or its context cancelled):
+ if `HeldAdmissible(host)`, reopen through the reopen rule (§3.6);
+ otherwise hold.
+7. **Browser ends** (disconnect, write deadline, context done): cancel the
+ open leg, call its `Done()`, deregister.
+
+**Opening a leg.** Each leg is a GET built from the original request: same
+path and raw query (marker stripped), same headers minus hop-by-hop
+headers, `Accept-Encoding: identity` in place of the browser's
+**(r1 P2-2)**, and `Last-Event-ID` set to the last id the edge has relayed
+(or the browser's own `Last-Event-ID` before the first one). Its context is
+the `HeldLeg`'s. Response headers must arrive within 10 seconds, or the leg
+counts as failed.
+
+**3.3a The leg goes through the route's own proxy (r1 P2-6).** A leg is
+served by running the route's existing `up.proxy` (the same handler chain
+`act.ServeHTTP` would have been handed) into an edge-internal response
+writer that hands status, headers and body to the stream task. So every leg
+gets exactly what a proxied request gets today: forwarded-header
+reconstruction and edge signing, purge-header removal, generation
+selection and stamping, response cookie scoping and the other response
+hooks. The relay never opens its own transport. Two consequences for the
+builder: the reverse proxy aborts a failed body copy with
+`panic(http.ErrAbortHandler)` when it sees a server context, so the leg runs
+in its own goroutine and recovers that panic as "leg ended"; and terminal
+first-leg answers (step 3) are written from what that writer captured, so
+they too have been through the response hooks.
+
+**Relaying is per event.** The edge reads the leg line by line and hands the
+stream task one complete event at a time, on its terminating blank line.
+That is the only buffering: one event in progress, capped at 64 KiB (an
+event over the cap closes the stream). Event framing makes the rest safe: a
+heartbeat is only ever written between events, and a leg that dies
+mid-event leaves nothing half-written for the next leg's first event to
+merge into (a partial event is dropped). The edge tracks the last event ID
+exactly as the SSE spec defines it (an `id` field containing NUL is ignored;
+an empty `id` resets it). `retry:` and comment lines are relayed as part of
+the event they arrive in, or on their own if they arrive alone. A BOM at the
+start of a leg is stripped before parsing.
+
+**Downstream writes** have a 10-second write deadline
+(`http.ResponseController.SetWriteDeadline`). A browser that cannot take a
+heartbeat in 10 seconds is closed.
### 3.4 Which edge holds
The edge whose activator manages the host holds the stream: the same edge
that would otherwise call `act.ServeHTTP` for it. Edges that only forward
(backhaul hop to the home box, fleet tunnel) proxy the marked request as an
-ordinary long request, unchanged, and see the home edge's heartbeats like any
-other bytes. A backhaul hop keeps its slot for the stream's life, by the
-existing rule (`backhaulAcquire`: a long-lived stream is sustained
-cross-region egress, which is what the cap bounds). That is unchanged.
+ordinary long request, unchanged, and see the home edge's heartbeats like
+any other bytes. The home edge answers within 2 seconds (§3.3 step 2), well
+inside the hop's 30-second header budget. A backhaul hop keeps its slot for
+the stream's life, by the existing rule (`backhaulAcquire`: a long-lived
+stream is sustained cross-region egress, which is what the cap bounds).
+That is unchanged.
When a reload means this edge no longer manages the host (route removed,
moved, repointed to a tunnel or fleet box), its held streams for that host
are closed. Each browser reconnects and is routed afresh.
-### 3.5 What the activator gives the edge
-
-The edge's `Activator` seam gains an optional interface (type-asserted, so a
-nil or older activator means no holding: the marker is stripped and the
-request proxied as today):
-
-- `BeginSidecarRequest(ctx, rt) error`: already exists (§3.2).
-- `Awake(host string) bool`: in-memory, under `a.mu`, true when the entry's
- state is `actAwake`.
-- `SetHostStateHook(func(host string, s HostState))`, with states `Awake`
- (the transition to `actAwake`) and `Stopping` (`beginStopLocked`). The hook
- is called without `a.mu` held, never blocks the activator (the edge side
- is a non-blocking channel send per host), and may drop a signal when its
- buffer is full; correctness never depends on it (§3.7's tick).
-
-On `Awake` the edge reopens every held stream on that host. On `Stopping`
-the edge closes the upstream legs of that host's held streams first. The
-instance's own SIGTERM drain then has no open stream handlers to wait for,
-so a stop is not held to `actStopTimeout` by streams the edge was going to
-lose anyway.
-
-Generation swaps (zero-downtime overlap): an awake instance can move to a new
-generation without a stop. On a reload where a host's upstream changes, the
-edge closes that host's open upstream legs and reopens them against the
-current upstream, non-waking, with `Last-Event-ID`. The old generation's
-drain therefore never waits on a held stream.
+### 3.5 Admissible
+
+A host is **admissible** when `HeldAdmissible(host)` is true: an entry
+exists, is `actAwake`, its child is alive, it is not fenced, not
+`probeHeld`, and the service is not shutting down. G4 and the simulation in
+§7 are stated against admissibility, not against `actAwake` **(r1 P2-5)**:
+a recovery probe that is awake but held is not admissible, and a held stream
+waits through it.
### 3.6 Bounds
@@ -205,10 +302,19 @@ drain therefore never waits on a held stream.
that page; `retry:` makes it come back in 30 seconds instead. The request
never reaches the activator, so it neither wakes nor counts (post 835's
amendment to item 7: no proxied fallback, ever).
-- **Rapid ends while awake:** an upstream that ends within 2 seconds of
- opening, having relayed no event, counts as a quick end. Reopens after
- quick ends back off 1s, 2s, 4s, capped at 30s; five quick ends in a row
- close the browser's stream. Any relayed event resets the count.
+- **Reopen rule (r1 P2-4).** A stream never opens two legs less than 1
+ second apart, whatever they relayed. A leg that ends less than 30 seconds
+ after it opened is a **short leg**, with or without events; after a short
+ leg the next reopen waits 1s, 2s, 4s … capped at 30s, and five short legs
+ in a row close the browser's stream. A leg that lasted 30 seconds or more
+ resets the count. A reopen because the host became admissible after a
+ sleep, or because a swap cancelled the leg, is not a short leg. Per host,
+ reopens are therefore bounded by the held-stream cap at one per second
+ each, and in practice by the backoff.
+- The browser's original request passes the edge's admission once, in the
+ usual way: the plan throttle and the rate limit's `rateAdmit`, exactly
+ once, in the hold branch (§3.8). Legs are edge-internal and are bounded by
+ the reopen rule, not by those.
The constants are the builder's to tune; the shapes are not.
@@ -216,26 +322,45 @@ The constants are the builder's to tune; the shapes are not.
Every held stream has one timer. When 25 seconds pass with nothing written
downstream, the edge writes the comment line `: ping` and a blank line,
-between events, and flushes. This runs whether or not an upstream leg is
-open, so an app that is silent while awake is covered too.
-
-The same tick is the backstop for G4: on each tick a held stream with no
-upstream leg calls `Awake(host)`, and reopens if true. A lost or dropped wake
-signal therefore costs at most one tick (25s) of quiet, never a silent
-stream for the rest of the night.
-
-### 3.8 Where it sits in the edge
-
-The held-stream branch runs after everything that judges the browser's
-request (host lookup, the password gate, the rate limit's admission,
-analytics and usage metering) and before the asset cache and the activator
-call, on the hibernating path only. It is handed a writer that flushes. The
-rate limit's slot comes back when the edge writes the response headers
-(`slotWriter`'s existing rule). Compression already skips
-`text/event-stream` (`compress.go`). The cache never sees the request.
+between events, and flushes. This runs whether or not a leg is open, so an
+app that is silent while awake is covered too.
+
+The same tick is the backstop for G4: on each tick a stream with no open
+leg and no pending reopen delay calls `HeldAdmissible(host)`, and starts a
+reopen if true. A lost or dropped wake signal therefore costs at most one
+tick (25s) of quiet. The wake hook only makes a resume faster; correctness
+never depends on it. Cancellation never depends on a signal at all (§3.2).
+
+### 3.8 Where it sits in the edge (r1 P2-1)
+
+In `Edge.ServeHTTP` on the holding edge, the order is:
+
+1. host lookup and the existing early refusals, unchanged (login POST
+ handling, door scope, import gate, plan-disabled), then the observing
+ writer (usage meter and analytics), the edge guard, and the password
+ gate, all as today;
+2. **classification and the hold branch (§3.1)**, here: after the password
+ gate, before the hop asset-fill answer, the upgrade branch, the local
+ asset catch, compression, the plan throttle, the shared cache, the rate
+ limit and the activator call. The hold branch runs `planThrottleAdmit`
+ and `rateAdmit` itself, once each; the rate limit's slot comes back when
+ the edge writes the response headers (`slotWriter`'s existing rule);
+3. everything else, unchanged, for unmarked requests.
+
+On a forwarding edge, the far asset answer and the backhaul run before
+lookup, as today. A marked request is not an asset request: the asset catch
+(local, far and the hop fill) passes any request carrying the marker
+through untouched, so it reaches the backhaul or the home edge's
+classification.
+
+The hold branch is handed the observing writer directly. It must support
+`Flush` and `http.ResponseController` write deadlines (`Unwrap`), which the
+plan verifies for every wrapper in that chain. No compression wrapper is
+involved: the hold branch sits before it, and it writes identity bytes.
Usage metering counts the downstream bytes as it counts any response's;
-heartbeats are a few bytes a minute.
+heartbeats are a few bytes a minute. Analytics records one request per
+browser connection.
### 3.9 Counters
@@ -243,14 +368,15 @@ A resume is not a wake reason: it never causes a wake, so counting it as one
would be wrong. The edge keeps its own counters, published in the box status
snapshot beside the edge's other counters: streams held now (per host and
total), resumes, refusals over a cap, closes by reason (upstream refused,
-maximum hold, quick ends, host no longer managed).
+redirect refused, maximum hold, short legs, host no longer managed, write
+deadline).
## 4. Constraints
- The marker parameter name `carlos_hold` and value `1` are wire contract
once Rastrillo ships against them; changes are additive only.
- The hold path makes no bucket read, no registry read, and no S3 request.
- `Awake` and admission are in-memory.
+ Admission, admissibility and cancellation are in-memory.
- Linux-only facilities are not needed; the code must cross-compile
(darwin, windows) like the rest of `internal/edge`.
- Witnesses go through production wiring: the edge with a real activator and
@@ -263,44 +389,61 @@ maximum hold, quick ends, host no longer managed).
activity.
2. **Awake, browser connects:** app's response passed through; the leg is
activity-invisible, so the instance still sleeps after its idle window.
-3. **Instance sleeps under an open stream:** `Stopping` closes the leg; the
- stream is held; heartbeats continue.
-4. **Another request wakes it:** `Awake` reopens every held stream on the
- host with `Last-Event-ID`; the browser sees the missed events and carries
- on.
-5. **App ends the stream while awake:** immediate reopen, non-waking.
+3. **Instance sleeps under an open stream:** `beginStopLocked` cancels the
+ leg before SIGTERM; the stream is held; heartbeats continue.
+4. **Another request wakes it:** the wake hook (or the next tick) reopens
+ every held stream on the host with `Last-Event-ID`; the browser sees the
+ missed events and carries on.
+5. **App ends the stream while awake:** reopen under the reopen rule,
+ non-waking.
6. **Edge restart or platform roll:** held streams close; browsers reconnect;
each is held (asleep) or relayed (awake). No wake from the reconnects.
-7. **Deploy (convergence cycle):** a sleep then a wake; cases 3 and 4. A
- zero-downtime overlap swap: §3.5's reload rule.
-8. **Cross-origin `EventSource`:** while awake the app's own CORS headers
- pass through on the first leg; while asleep the edge's own 200 carries
- none and the browser refuses it. Held streams are same-origin only, and
- the docs say so.
-9. **Wake race:** the instance wakes between a stream's state check and its
- registration. Register-then-check (§3.3 step 1) plus the tick (§3.7)
- cover it.
-10. **Region HA failover or a move:** the host leaves this edge's managed
+7. **Deploy:** a convergence cycle is a sleep then a wake (cases 3 and 4). A
+ zero-downtime overlap swap cancels the retiring generation's legs in the
+ switch's critical section; they reopen on the successor at once.
+8. **Cross-origin `EventSource`:** while admissible the app's own CORS
+ headers pass through on the first leg; while asleep the edge's own 200
+ carries none and the browser refuses it. Held streams are same-origin
+ only, and the docs say so.
+9. **Wake race:** register-then-admit (§3.3 step 1) plus the tick (§3.7).
+10. **Stop race:** a leg admitted just before a stop is registered and
+ cancelled by it; one asked for just after is refused (§3.2).
+11. **Region HA failover or a move:** the host leaves this edge's managed
set at reload; its held streams close and reconnect to the new owner.
+12. **Recovery probe:** awake but held, so not admissible; streams stay held
+ until the probe releases (wake hook) or the next tick.
+13. **Session expired while asleep:** held; on wake the reopen gets 401 (or
+ a redirect) and the stream closes; the reconnect, now admissible, gets
+ the 401 (or the 204) and the page stops.
## 6. Left to the builder
-- The exact shape of the held set, the hook's channel and its buffer size.
+- The exact shape of the held set, the stream task and its channels, and
+ the wake hook's buffer.
- Where the counters attach in the status snapshot.
-- Tuning the constants in §3.6 and §3.7.
-- Whether `BeginSidecarRequest` is reused under its own name or gains a
- neutral alias for this caller (behaviour must stay identical).
-- Docs: a short page section on holding streams for app authors (marker,
- same-origin, `Last-Event-ID`, the 30s over-cap retry), through the copy
- review.
+- Tuning the constants in §3.3 and §3.6, and the heartbeat interval.
+- Docs: a short section for app authors (the marker, same-origin only,
+ `Last-Event-ID`, no redirects, later-leg cookies lost, the 30-second
+ over-cap retry), through the copy review.
## 7. Testing
-- A randomized simulation of one host's states (awake, stopping, asleep,
- waking, swap) against N held streams with lost and delayed hook signals,
- checking two invariants: no held stream ever contributes to `inflight` or
- `lastActive`, and no stream stays upstream-less for more than one tick
- while the host is awake.
-- Production-wired witnesses for cases 1–7 against a real child app that
- serves SSE with ids and honours `Last-Event-ID`.
-- The marker-strip test pins byte-for-byte query preservation.
+- A randomized simulation of one host's lifecycle (waking, awake, stopping,
+ asleep, failed wake, overlap swap, fence, probe held and released,
+ shutdown) against N held streams, with wake signals dropped and delayed
+ at random, checking three invariants: no held stream ever contributes to
+ `inflight` or `lastActive` or starts a wake; no process or generation is
+ signalled to stop while a leg registered on it is uncancelled; and no
+ stream goes more than one tick without a leg while its host is
+ admissible, outside a reopen delay.
+- The guard test for process-stop call sites (§3.2).
+- Production-wired witnesses for cases 1–7, 10 and 13 against a real child
+ app that serves SSE with ids and honours `Last-Event-ID`, including a
+ witness that the app's SIGTERM drain finishes without waiting on a held
+ stream.
+- Witnesses that a leg carries the edge's forwarded headers and signing and
+ not the client's forged ones, and that a first-leg `Set-Cookie` is scoped
+ as a proxied response's is.
+- The marker-strip test pins byte-for-byte query preservation; a test pins
+ that a marked request to a hibernating route never reaches
+ `act.ServeHTTP`, whatever its method or headers.
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md b/docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md
new file mode 100644
index 000000000..ae7eeadba
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md
@@ -0,0 +1,154 @@
+# Edge-held event streams — review findings
+
+Commit reviewed: `9ca0d9209a562a41c265406a0d6e6b4f83a8b6cf` (verified `HEAD`).
+Round: **1 of 3**.
+Document: `docs/superpowers/specs/2026-10-28-edge-held-streams-design.md`.
+
+Read-only source review. No files changed, no subagents spawned, and no test suites run.
+
+## P1 findings
+
+### P1-1 — Reload does not detect an overlap generation switch
+
+**Section:** §3.5, lines 189–193.
+
+**Problem and evidence:** The design relies on a reload changing the host’s upstream to move held streams off a retiring generation. Generation-managed routes instead select the current generation dynamically. [edge.go:816](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/edge.go:816) constructs `appSocketProxy`; [genproxy.go:255](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/genproxy.go:255) consults `ServingGen` per request. The switch installs the successor without changing the route or requiring an edge reload: [swap.go:662](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/swap.go:662). Its retirement notification closes idle connections only; active responses continue: [genproxy.go:175](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/genproxy.go:175).
+
+**Failure scenario:** An overlap swap leaves a held leg connected to the old process. No reload or `Stopping` transition occurs for the awake host. The old process’s SIGTERM drain waits on that stream until its stop timeout, contradicting the stated guarantee.
+
+**Concrete fix:** Track each leg’s generation and use the existing `OnGenRetired` notification to cancel legs belonging to the retiring generation before its drain. Reopen through current-generation selection. Define registration and rechecking so a leg cannot miss retirement while opening. Retain reload handling for route ownership changes.
+
+**Fault family:** Generation retirement must shed held legs independently of route reloads.
+
+### P1-2 — A dropped `Stopping` notification leaves the upstream open through the stop
+
+**Section:** §3.5, lines 177–186; §3.7, lines 222–225.
+
+**Problem and evidence:** `Stopping` notifications may be dropped, but the tick only checks streams **without** an upstream. It cannot repair a missed cancellation of an existing leg. Moreover, sending a notification does not establish that cancellation happens before SIGTERM. [activator.go:3003](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:3003) changes state and launches `stop`; [activator.go:4430](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:4430) gives the process a 20-second stop budget. The proposed tick is 25 seconds.
+
+**Failure scenario:** A full notification channel drops `Stopping`. The app’s graceful shutdown waits for its SSE handler, while the edge keeps that handler connected. The tick ignores it because an upstream exists, so the process reaches its stop timeout. There is also an opening race: admission succeeds, stopping occurs, and the leg opens after the cancellation pass.
+
+**Concrete fix:** Make leg cancellation a reliable lifecycle operation, with registration coordinated against stop and generation retirement. Keep lossy notifications for wake acceleration only. Define how an opening leg is cancelled and how cancellation precedes process drain without blocking under `a.mu`.
+
+**Fault family:** Termination ordering and cancellation cannot depend on lossy notifications.
+
+### P1-3 — Passing through a redirect can remove the opt-in and restore ordinary activity
+
+**Section:** §3.3, steps 3 and 5, lines 120–135.
+
+**Problem and evidence:** The design says a 303 is passed through and makes `EventSource` fail. Native `EventSource` uses Fetch, which follows redirects, including 303. The terminal status check occurs after Fetch processes the redirect. See [https://fetch.spec.whatwg.org/#http-redirect-fetch](https://fetch.spec.whatwg.org/#http-redirect-fetch) and [https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface](https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface).
+
+The redirected request need not retain `carlos_hold=1`. An unmarked request reaches ordinary admission at [activator.go:5884](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:5884).
+
+**Failure scenario:** `/live?carlos_hold=1` returns `303 Location: /login`. The browser requests `/login` without the marker, earns activity credit, and can wake the host if it has slept meanwhile. A redirect to an unmarked SSE endpoint can restore an indefinitely counted stream.
+
+**Concrete fix:** Define redirect handling explicitly. A safe default is to convert upstream redirects into a terminal, non-redirect response without following them. If redirects must work, specify a bounded policy that preserves non-waking admission across every target.
+
+**Fault family:** Activity exclusion must survive response-driven follow-up requests.
+
+### P1-4 — The optional-interface fallback explicitly permits waking and counted streams
+
+**Section:** §3.5, lines 170–172.
+
+**Problem and evidence:** If the activator lacks the new optional interface, the design strips the marker and proxies normally. An activator can satisfy the existing edge interface while lacking the new interface; its route remains on the hibernating path. [edge.go:2069](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/edge.go:2069) calls `ServeHTTP`, which reaches `begin` at [activator.go:5884](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:5884). That path wakes absent entries and increments `inflight`.
+
+**Failure scenario:** A marked request served through an activator without holding support wakes a sleeping instance or keeps an awake instance counted for the stream’s lifetime.
+
+**Concrete fix:** Refuse eligible marked requests without calling the activator when holding support is unavailable. Specify the refusal response. Do not use ordinary proxying as a compatibility fallback.
+
+**Fault family:** Unsupported capability must preserve G1/G2 through refusal.
+
+## P2 findings
+
+### P2-1 — The stated insertion point does not exist in the current request pipeline
+
+**Section:** §3.8, lines 229–235.
+
+**Problem and evidence:** The design places handling after rate admission but before the asset cache. The actual order includes:
+
+- Upgrade dispatch to the activator at [edge.go:1963](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/edge.go:1963).
+- Local asset handling at [edge.go:1980](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/edge.go:1980).
+- Shared-cache lookup at `edge.go:2038`.
+- Ordinary rate admission at `edge.go:2052`.
+
+Asset fills independently call the activator at [assetcatch.go:586](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/assetcatch.go:586). The §3.1 predicate also does not exclude an upgrade request carrying the marker and SSE `Accept` header.
+
+**Failure scenario:** A builder inserts the handler beside the ordinary activator call, leaving earlier asset or upgrade dispatch able to wake or count a qualifying request.
+
+**Concrete fix:** Specify early classification and a dedicated admitted hold branch before those dispatches. Explicitly reject marked upgrade combinations without activation. Define bypasses for local, far, and signed-hop asset handling while preserving the existing security gates, account throttle, metering, and exactly-once rate admission.
+
+**Fault family:** Every dispatch path must obey the same activity-exclusion decision.
+
+### P2-2 — First-leg headers need transformation for an edge-owned response
+
+**Section:** §3.3, lines 116–152; §3.8, line 235.
+
+**Problem and evidence:** “The upstream’s response becomes the browser’s” leaves representation and framing headers unspecified. The edge changes the body by inserting heartbeats and concatenating successive upstream responses. Also, forwarding the original `Accept-Encoding` allows an upstream to return compressed SSE that the proposed line parser cannot directly interpret. [compress.go:125](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/compress.go:125) only excludes SSE from compression performed by this edge.
+
+**Failure scenario:** A valid finite SSE response supplies `Content-Length`. Copying that length downstream ends the browser response after the first leg or makes subsequent writes fail. A gzip-encoded upstream supplies compressed bytes to the event parser.
+
+**Concrete fix:** Define an identity upstream representation, handling for unexpected content encodings, and removal of upstream body-length/framing metadata from a successful held response. Preserve ordinary response handling separately for terminal non-SSE answers.
+
+**Fault family:** Downstream HTTP metadata must describe the body the edge actually sends.
+
+### P2-3 — Blocking admission and I/O have no specified progress policy
+
+**Section:** §§3.2, 3.3, 3.6 and 3.7.
+
+**Problem and evidence:** The one-goroutine loop must admit, open, read, write, heartbeat, and react to lifecycle events, but the design does not specify how blocking operations coexist with its deadlines. `BeginSidecarRequest` can wait for 30 seconds on another wake: [activator.go:1810](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:1810). Existing local transports have no response-header timeout: [genproxy.go:211](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/genproxy.go:211). A backhaul allows only 30 seconds for response headers: [edge.go:3227](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/edge.go:3227).
+
+**Failure scenario:** A request joins a slow wake and exhausts the forwarding edge’s header budget before receiving its first response. Alternatively, a silent upstream read or blocked downstream write prevents the owner loop from servicing heartbeats, cancellation, or maximum lifetime.
+
+**Concrete fix:** Define a cancellable I/O arrangement with one downstream writer, bounded opening/header waits, independent heartbeat and lifetime scheduling, and bounded stalled writes. Specify the initial-response policy while joining a wake, plus handling of transport errors before and after downstream headers.
+
+**Fault family:** Stream liveness and resource bounds must survive blocked I/O.
+
+### P2-4 — Successful short streams bypass the reconnect backoff
+
+**Section:** §3.6, lines 208–211.
+
+**Problem and evidence:** Only a leg ending within two seconds **without an event** counts as a quick end; any event resets the counter. The browser’s original request passes rate admission once, whereas each subsequent leg is generated inside the holding loop. Rate admission is per incoming request at [ratelimit.go:124](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/ratelimit.go:124).
+
+**Failure scenario:** An endpoint returns one valid event and immediately closes. Each held connection repeatedly issues upstream GETs as fast as the app can answer. Neither the quick-end limit nor the original request limiter bounds this amplification. The 64-stream cap bounds concurrent connections, not request rate.
+
+**Concrete fix:** Bound reopen frequency regardless of whether a leg emitted an event. Use a minimum reconnect delay or a per-host attempt budget; reset failure backoff only after a defined stable interval. Refusals must remain non-waking.
+
+**Fault family:** One admitted browser connection must not create unbounded upstream request amplification.
+
+### P2-5 — `actAwake` is not equivalent to admission being open
+
+**Section:** §3.5, lines 175–176; §3.7; §7.
+
+**Problem and evidence:** The proposed `Awake` method checks only `actAwake`. Recovery probes can be in that state while still fenced and `probeHeld`: [recoveryprobe.go:228](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/recoveryprobe.go:228). `BeginSidecarRequest` refuses both conditions at [activator.go:1817](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/activator.go:1817). Opening a probe clears `probeHeld` without another transition to `actAwake`: [recoveryprobe.go:343](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/activator/recoveryprobe.go:343).
+
+**Failure scenario:** The tick repeatedly sees “awake” but cannot open a leg. The §7 invariant then fails for a deliberately unavailable probe, or the implementation treats repeated refused admission as progress and weakens G4. Probe release also produces no proposed `Awake` transition notification.
+
+**Concrete fix:** Distinguish process state from availability to serve held traffic. Define G4 against the latter, preserve admission refusals, and notify when recovery opens admission. Include fenced probes, probe release, shutdown, and failed wakes in the simulation.
+
+**Fault family:** Liveness checks must use the same availability conditions as admission.
+
+### P2-6 — The new relay must explicitly retain existing proxy trust transformations
+
+**Section:** §3.3, lines 116–123; §3.8.
+
+**Problem and evidence:** The design specifies original request headers minus hop-by-hop headers and first-response pass-through, but does not identify how the relay retains the existing proxy’s security transformations. These include forwarded-header reconstruction and signing at [homemap.go:1414](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/homemap.go:1414), inbound purge-header removal at [purge_header.go:218](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/purge_header.go:218), and response cookie scoping at [cookiescope.go:79](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-streams-432/internal/edge/cookiescope.go:79).
+
+**Failure scenario:** A builder opens legs directly with a transport and follows the stated header-copy rules. Client-supplied forwarded headers reach the app, or a first-leg `Set-Cookie` escapes the existing tenant-domain restriction. Passing the earlier password gate does not provide these later protections.
+
+**Concrete fix:** Name the shared proxy rewrite and response-modification contract that every leg must execute. Require its use before parsing or copying responses, including terminal first-leg responses. Add witnesses for forged forwarded headers and cross-account cookie scope.
+
+**Fault family:** The hold path must preserve the existing client-to-app and tenant-to-browser trust boundaries.
+
+## P3 findings
+
+None.
+
+## Builder questions
+
+1. What terminal response replaces an upstream redirect, and are any redirects supported?
+2. What reliable operation registers and cancels a leg against host stopping and generation retirement?
+3. While joining a wake or awaiting first-leg headers, when does the edge commit its own SSE response, and when does it terminate instead?
+4. Which existing proxy component will the relay reuse to preserve request rewrites, response security hooks, and generation selection?
+5. What reconnect-rate budget applies even when every upstream leg emits an event?
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md
new file mode 100644
index 000000000..347103a59
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md
@@ -0,0 +1,101 @@
+# Review brief: edge-held event streams design, round 2 of 3
+
+Repo carlos/platform, branch `edge-held-streams-432`, commit: the tip of
+that branch when you start (`git rev-parse HEAD`; name it in your output).
+Under review: `docs/superpowers/specs/2026-10-28-edge-held-streams-design.md`.
+Authorities: the code on this branch (it is `main` plus this spec), chiefly
+`internal/activator/activator.go` (`serve`, `BeginSidecarRequest`, `begin`,
+`beginStopLocked`, the idle sweep), `internal/edge/edge.go` (`Reload`'s
+`hibernating` upstream flag, `ServeHTTP`, the backhaul hop),
+`internal/edge/ratelimit.go` (`slotWriter`), `internal/edge/compress.go`,
+and the zero-downtime deploy specs under `docs/superpowers/specs/`.
+The request is amadan discussion carlos/platform #432 and its post 835; the
+spec's §1-§2 restate it. Do not review against unmerged branches; if this
+work needs one, say so as a P1 and stop.
+
+You are an independent reviewer. Read the document, then the code it
+names, and check every claim against that code. Read it also as the
+engineer who must write the implementation plan from it alone: report the
+places where you would have to guess and a wrong guess would matter.
+
+## Fixed: do not re-argue
+
+- Paul's ruling (#432): the edge holds the stream; the browser does not
+ retry on its own. Report only mechanisms that fail to honour it.
+- Paul's ruling (2026-10-28): the opt-in is the URL marker `carlos_hold=1`
+ (spec §3.1), not a list of paths in app config.
+- Post 835: an opted-in stream is activity-invisible and non-waking in every
+ outcome; no proxied fallback when a cap is reached.
+
+## What to check
+
+1. G1/G2: is there any path (first leg, reopen, over-cap, error, swap,
+ reload, hop, tunnel) where an opted-in stream reaches `begin`, earns
+ in-flight or `lastActive`, or causes a wake?
+2. G4: can a held downstream sit with no upstream while the host is awake
+ for longer than one tick? Check the register-then-check order, the hook
+ (`Awake`/`Stopping`) and where those transitions really happen in the
+ activator, including waking-then-failed, generation swaps, fences,
+ probes and shutdown.
+3. Stopping: does closing upstream legs on `Stopping` interact badly with
+ the stop path, the SIGTERM drain, `actStopTimeout`, or the sidecar
+ rules? Is `beginStopLocked` the only path to a stop that ends a
+ process's streams?
+4. Zero-downtime overlap swaps: does §3.5's reload rule match how the edge
+ actually picks a generation's upstream (`genManaged`, `e.gens`)? Would a
+ drain wait on a held leg?
+5. Edge placement (§3.8): is the proposed position in `Edge.ServeHTTP` real
+ (gate, rate limit, analytics, usage meter, cache, activator call), and
+ does the writer it gets support Flush there?
+6. The hop and tunnel (§3.4): does a forwarding edge pass the marker and
+ the stream through untouched, and do any of its timeouts cut a quiet
+ stream before a 25 s heartbeat?
+7. SSE framing (§3.3): is per-event relay with `id:` tracking correct
+ against the SSE spec, and does the over-cap `retry:` answer actually make
+ a native `EventSource` reconnect?
+8. Anything an outsider can do with the marker that the spec does not
+ bound.
+
+## Round 2
+
+Earlier rounds: round 1, `docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md`
+(NOT READY: P1-1..P1-4, P2-1..P2-6). Rev 2 marks where each landed.
+
+First give one line per P1 and P2 from round 1: resolved, partly, or not.
+Carry every unresolved or partly resolved finding forward at its current
+severity, then add new findings. The verdict covers everything
+outstanding, round 1 included. Check especially that rev 2's new
+mechanisms are real against the code: `cancelHeldLegsLocked` at every
+process-stop and generation-retire site (§3.2), running each leg through
+`up.proxy` into an internal writer (§3.3a), and the §3.8 position.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section, the problem, the
+evidence (file:line, verified), the failure scenario, a concrete fix and
+the invariant or trust boundary it breaks (that is its fault family).
+Then a short list headed "Builder questions": decisions the spec leaves
+open that a planner could not settle alone, most important first. End
+with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.