plan: probe-burst limit rev 3 (Astra plan R2: 1 P1 + 2 P2 fixed)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+51
−6
docs/superpowers/plans/2026-10-31-probe-burst-limit.md+8 −6docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R2.md+43 −0
CI passed — run details
diff --git a/docs/superpowers/plans/2026-10-31-probe-burst-limit.md b/docs/superpowers/plans/2026-10-31-probe-burst-limit.md| index 2daab0ab8..62994f550 100644 |
| --- a/docs/superpowers/plans/2026-10-31-probe-burst-limit.md |
| +++ b/docs/superpowers/plans/2026-10-31-probe-burst-limit.md |
| @@ -10,18 +10,18 @@ |
| **Spec:** `docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md` (rev 2, approved by Paul 2026-10-31), building on §5.5 of `docs/superpowers/specs/2026-10-24-edge-request-protection-design.md`. Read both. |
| -**Review history:** plan rev 1 Astra R1 NOT READY (3 P1: verdict precedence, record-only on far asset edges, CLI read; 4 P2: API serial bump, per-counter bound, slow-peer isolation, trip reference). Rev 2 fixes all seven (`CODEX-FINDINGS-PROBE-BURST-PLAN-R1.md`). Two rounds remain. |
| +**Review history:** plan rev 1 Astra R1 NOT READY (3 P1: verdict precedence, record-only on far asset edges, CLI read; 4 P2: API serial bump, per-counter bound, slow-peer isolation, trip reference). Rev 2 fixes all seven (`CODEX-FINDINGS-PROBE-BURST-PLAN-R1.md`). Plan rev 2 Astra R2 NOT READY (1 P1: asset fills drop the browser signal before home counts; 2 P2: sender budget counted trips not messages; no read-time bound on notice bodies); rev 3 fixes all three (`CODEX-FINDINGS-PROBE-BURST-PLAN-R2.md`). One round remains. |
| ## Global Constraints |
| - Threshold 60 not-founds in 60 s per app and client; cool-down 10 minutes; client key `ratelimit.ClientKey(clientIP(r))` (/32 IPv4, /64 IPv6). |
| -- A not-found is: a final status 404, or a hard or probe verdict (watch or block) whatever the status; a burst-mode (`probe/admin`) rule match counts only with a final 404. A request carrying any `Sec-Fetch-Mode` header never counts. |
| +- A not-found is: a final status 404, or a hard or probe verdict (watch or block) whatever the status; a burst-mode (`probe/admin`) rule match counts only with a final 404. A request carrying any `Sec-Fetch-Mode` header never counts. **Counting happens only on the edge that saw the visitor's own request headers** (R2-1): the home box never counts a request that arrived as an asset fill (the fill rebuilds headers, `assetFillRequest`); the far edge counts that request itself in `serveAssetFar`'s defer, from the visitor's original request and the fill's final status, whether or not the fill reached the home. Ordinary backhaul hops forward the visitor's headers and are counted at the home as today. |
| - During a cool-down, refuse only requests to catalogue paths (`edgeguard.Check` hit, any group incl. admin) the app is not known to serve. Known to serve today = a static site's file exists (or `_redirects` names the path), the check `serveTree` already makes. |
| - Watch first: the burst rule's catalogue mode is watch. `CARLOS_EDGE_PROTECT=block` (dev) refuses for real. Promotion to block is a later one-line change on Paul's approval, not in this plan. |
| - Fleet apps (forward routes, and anything delivered `viaTunnel`) are never refused by the burst limit in v1, only recorded. |
| - **Verdict precedence (one rule, one place):** a request still has one verdict, but a verdict that does not block is replaced by a later candidate that blocks; a blocking verdict is never replaced. Among non-blocking candidates the first stands. So a burst watch (or a fleet or record-only exemption) never weakens a hard or probe block, and the static resolved-file hard check still runs after a burst watch. `guardDecide` and `burstDecide` both go through `func decideVerdict(st *guardState, v *guardVerdict) (applied bool)`. |
| - An app with the record-only switch on is never refused by any protection (hard, probe, burst); matches are still recorded and counted as recorded. |
| -- Only boxes holding the mesh key send or accept notices. Notices: signed, timestamp within `hopSkew` (30 s), bound to the receiving box's name, expiry in the future and at most 10 minutes ahead, client a canonical /32 or /64. Sender cap 120 notices/minute/box; receiver cap 600/minute; overflow counted, never silent. No retry; sending never blocks serving. |
| +- Only boxes holding the mesh key send or accept notices. Notices: signed, timestamp within `hopSkew` (30 s), bound to the receiving box's name, expiry in the future and at most 10 minutes ahead, client a canonical /32 or /64. Sender cap 120 outgoing notice messages per minute per box, across all peers: a trip's broadcast reserves one message per peer at once, or is not sent at all and stays local (counted) (R2-2); receiver cap 600/minute; overflow counted, never silent. No retry; sending never blocks serving. |
| - Bounds: 100,000 counters and 50,000 cool-downs per box, oldest evicted first, evictions counted; each counter holds at most the last 60 timestamps (a fixed ring), and a client already cooling is not counted at all, so memory is independent of request volume. |
| - No storage writes on the request path or per trip; no new polling. Provider-neutral. |
| - A received notice is logged only to the box's operator log (`log.Printf`, capped), never to a tenant's records. A refusal record says the cool-down came from "this app" or "another app on the platform" and never names another app. |
| @@ -129,6 +129,7 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| - `TestBurstFleetAppNeverRefused`: forward route in block mode: recorded, forwarded. |
| - `TestBurstOneVerdictPerRequest`: a cooling client's `/.env` gets exactly one Match record and one Protection count. |
| - `TestBurstWatchNeverWeakensABlock` (R1-1): block mode, cooling client, `/.env` on a fleet forward route: the hard rule blocks (404 block page), not a burst watch; and a static rewrite to `/.env` is still blocked after a burst watch on the request path. |
| + - `TestBurstAssetFillCountedOnlyAtTheFarEdge` (R2-1): two edges; 60 browser-style requests (`Sec-Fetch-Mode: no-cors`) for missing declared assets through the far edge never trip on either edge; 60 identical requests without the header trip on the far edge, and the home counts none of the fills. |
| - `TestBurstTripRefFindsItsRecord`: the trip's code resolves through the console's edge-ref lookup to the trip record. |
| - In `internal/edgeguard`: `TestBurstRuleLookups` (`RuleByID`, `RuleByHash` find it; `Check` never returns it). In `internal/reqrec`: `TestTripRecordAndCap`, `TestBurstMatchCooldownFields`. |
| - [ ] **Step 2:** Run `go test ./internal/edge/ ./internal/edgeguard/ ./internal/reqrec/ -run 'Burst|Trip'`. Expected: FAIL. |
| @@ -150,15 +151,16 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| - Produces: |
| - Wire: `POST /.carlos/burst-notice` on the receiving edge's public listener, `Host` = a host the receiver serves (any key of its edges file's `Hosts`, the lowest in sort order that has no `*`), header `X-Carlos-Burst-Auth: <unix>:<hex>`, JSON body `{"client":"203.0.113.7/32","until":<unix seconds>,"from":"<sender box>","ref":"<trip ref>"}` at most 512 bytes. |
| - MAC: HMAC-SHA256 under the mesh signing key over `"carlos-burst-notice\x00" + receiverBox + "\n" + ts + "\n" + body`; verify under current or next key (`meshKeys()`), timestamp within `hopSkew`. |
| - - `func (e *Edge) sendBurstNotices(client netip.Prefix, until time.Time, ref string)`: for every edges-file box other than `e.box` with a non-empty dial address (`edgesfile.Reader.Dial`, as `foldHomes` does) and a servable host, enqueue one notice on that peer's own bounded queue (64), drained by that peer's own goroutine, so a slow peer never delays another; each send uses `e.backhaulTransport(dial)` with a notice-specific total deadline of 3 s, reads and closes the response body, is signed at dispatch (not at enqueue), and is dropped unsent if its expiry has passed; cap 120 trips per minute box-wide; overflow, expiry drops and send failures counted and logged via `logThrottled` with a fixed key; no retry. No mesh key: sends nothing. Peers that leave the edges files have their goroutine stopped. |
| - - `func (e *Edge) serveBurstNotice(w http.ResponseWriter, r *http.Request) bool`: intercepted in ServeHTTP after `acceptHop` and before route lookup, for `POST` with path `/.carlos/burst-notice` and the auth header present. Answers 204 on apply, 404 on anything it refuses (no key, bad MAC, stale ts, wrong receiver, bad body, client not a canonical /32 or /64, expiry out of bounds, over the 600/minute cap), counting each refusal reason; logs an accepted notice to the operator log through a capped logger, never to tenant records. Never re-sends. |
| + - `func (e *Edge) sendBurstNotices(client netip.Prefix, until time.Time, ref string)`: for every edges-file box other than `e.box` with a non-empty dial address (`edgesfile.Reader.Dial`, as `foldHomes` does) and a servable host, enqueue one notice on that peer's own bounded queue (64), drained by that peer's own goroutine, so a slow peer never delays another; each send uses `e.backhaulTransport(dial)` with a notice-specific total deadline of 3 s, reads and closes the response body, is signed at dispatch (not at enqueue), and is dropped unsent if its expiry has passed; the box-wide budget of 120 outgoing messages per minute is reserved per broadcast as in the Global Constraints, before anything is queued; overflow, expiry drops and send failures counted and logged via `logThrottled` with a fixed key; no retry. No mesh key: sends nothing. Peers that leave the edges files have their goroutine stopped. |
| + - `func (e *Edge) serveBurstNotice(w http.ResponseWriter, r *http.Request) bool`: intercepted in ServeHTTP after `acceptHop` and before route lookup, for `POST` with path `/.carlos/burst-notice` and the auth header present. It reads the body under `http.MaxBytesReader` (512 bytes) with a 2 s read deadline set through `http.ResponseController` (the bounded login-body reader near edge.go:2046 is the pattern); a slow or oversized body is refused (404) and the connection closed (R2-3). Answers 204 on apply, 404 on anything it refuses (no key, bad MAC, stale ts, wrong receiver, bad body, client not a canonical /32 or /64, expiry out of bounds, over the 600/minute cap), counting each refusal reason; logs an accepted notice to the operator log through a capped logger, never to tenant records. Never re-sends. |
| - A request with that path but no auth header falls through to the app as today. |
| - [ ] **Step 1: Failing tests** with two real `Edge`s sharing a mesh key and published edges files, the backhaul port and root CAs overridden the way existing hop tests do: |
| - `TestBurstNoticeAppliesOnThePeer`: trip on edge A; within the test's wait, edge B refuses (block mode) a catalogue path from that client on its own app with `cooldown_from="another app on the platform"`. |
| - `TestBurstNoticeRefusesForgery` (Review Focus 2): wrong key, stale timestamp (31 s), wrong receiver name, until 11 min ahead, client `203.0.113.0/24`: each 404 and not applied. |
| - `TestBurstNoticeNoKeyNoSendNoAccept`: an edge with no mesh key sends nothing and refuses every notice (the fleet box case). |
| - - `TestBurstNoticeCaps` (Review Focus 3): 130 trips in a minute send 120 and count 10; 610 notices received apply 600 and count 10. |
| + - `TestBurstNoticeCaps` (Review Focus 3): with three peers, 50 trips in a minute transmit exactly 120 messages (40 broadcasts) and count 10 broadcasts kept local, counting actual transmissions at the peers; 610 notices received apply 600 and count 10. |
| + - `TestBurstNoticeStalledBodyBounded` (R2-3): a real connection that sends the notice headers and then stalls its body is answered 404 and closed within the 2 s body deadline, applying nothing. |
| - `TestBurstNoticePathWithoutAuthReachesApp`: `POST /.carlos/burst-notice` without the header is proxied to the app. |
| - `TestBurstNoticeSlowPeerIsolated` (R1-6): one peer that never answers and one healthy peer: the healthy peer applies within 1 s; the stalled send gives up at 3 s and is counted. |
| - `TestBurstNoticeIsNotAHop`: a valid hop signature or door signature in the burst header is refused (domain separation). |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R2.md b/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R2.md| new file mode 100644 |
| index 000000000..0061bb5dc |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R2.md |
| @@ -0,0 +1,43 @@ |
| +**1 new P1 and 2 new P2 findings. Round 2 of at most 3; reviewed `f128c9532f941c80ca292856f0aa252c1c42cc06`.** |
| + |
| +| Round 1 finding | Disposition | Revised plan | |
| +|---|---|---| |
| +| R1-1: burst watch suppresses hard/probe enforcement | **Fixed** | Explicit replacement precedence and regression cases for fleet and static rewrites: [plan:22](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:22), [plan:131](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:131). | |
| +| R1-2: record-only misses far asset edges | **Fixed** | Adds remote asset owners to settings resolution and both guard sites: [plan:184](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:184). | |
| +| R1-3: CLI lacks a read interface | **Fixed** | Specifies GET endpoint, client method, dispatch, documentation and binary tests: [plan:187](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:187). | |
| +| R1-4: protection-only API writes omit serial bump | **Fixed** | Explicitly extends serial bump, audit and response: [plan:186](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:186). | |
| +| R1-5: timestamp storage unbounded within one counter | **Fixed** | Fixed 60-entry ring, no counting while cooling, flood test: [plan:85](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:85). | |
| +| R1-6: slow peer stalls healthy peers | **Fixed** | Per-peer queues/workers, three-second deadline, dispatch-time signing and expiry checks: [plan:153](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:153). | |
| +| R1-7: trip reference absent from record interface | **Fixed** | Adds `Trip.Ref`, mints once, shares with notices and tests lookup: [plan:115](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:115). | |
| + |
| +These dispositions concern the revised plan, not implemented fixes. |
| + |
| +1. **P1 — Task 3: asset fills erase the browser exemption before counting at home.** |
| + |
| + [Plan:118](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:118) excludes requests carrying `Sec-Fetch-Mode` at the counting site. But `assetFillRequest` creates fresh headers and copies only `User-Agent` and `Accept`, dropping that header ([assetcatch.go:651](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/assetcatch.go:651), [assetcatch.go:664](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/assetcatch.go:664)). The fill reaches home through a signed hop ([assetcatch.go:1213](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/assetcatch.go:1213)); the visitor’s address survives forwarding and is used by `clientIP` ([edge.go:4006](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:4006), [analytics.go:76](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/analytics.go:76)). Home fills explicitly remain inside protection observation ([edge.go:2192](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:2192)). |
| + |
| + A tenant page can therefore make a visitor request 60 distinct missing assets through a far edge. Home sees 60 headerless 404s attributed to that visitor and starts a platform-wide cool-down. This recreates the attack the browser exemption was introduced to prevent. |
| + |
| + **Fix:** carry the original browser-exemption signal through authenticated asset fills and consume it before home counting. Add a two-edge test: browser-generated missing-asset fills never trip; otherwise identical scanner fills do. |
| + |
| + **Invariant / fault family:** browser-originated requests cannot initiate a platform-wide cool-down, including after internal request reconstruction ([spec:80](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md:80)). |
| + |
| +2. **P2 — Task 4: the sender budget counts trips rather than outgoing notices.** |
| + |
| + [Plan:153](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:153) enqueues one notice per peer but caps **120 trips** per minute. Its test likewise measures trips ([plan:161](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:161)). With three peers, that permits 360 outgoing notices. The approved spec caps **120 notices sent per box per minute**, with excess trips staying local ([spec:135](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md:135)). |
| + |
| + **Fix:** define the budget in outgoing messages across all peer queues. Specify how a broadcast reserves that budget and how deferred sends respect the per-minute limit. Test multiple recipients and count actual transmissions, not calls to `sendBurstNotices`. |
| + |
| + **Invariant / fault family:** fan-out must remain within the approved box-wide message budget. |
| + |
| +3. **P2 — Task 4: incoming notice bodies have a byte bound but no read-time bound.** |
| + |
| + The notice endpoint accepts public POSTs before route lookup and authenticates a MAC covering the body ([plan:151](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:151), [plan:154](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:154)). Its 512-byte limit does not stop a caller sending those bytes indefinitely slowly. The public listener deliberately has no `ReadTimeout` ([edge.go:4370](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:4370)). Neither the sender’s three-second deadline nor the receiver’s accepted-notice cap bounds unauthenticated body reads. |
| + |
| + **Fix:** specify a short receiver-side body deadline, including failure/drain handling. The bounded login-body reader provides an existing pattern ([edge.go:2046](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:2046)). Test a real connection that sends valid-looking headers and then stalls its body. |
| + |
| + **Invariant / fault family:** unauthenticated notice processing must consume bounded time and resources. |
| + |
| +No P3 findings. All citations checked at the requested commit. No files changed; no tests run. |
| + |
| +**NOT READY** |
| \ No newline at end of file |