plan: probe-burst limit rev 4 (Astra plan R3 fixes; Paul: build without a fourth round)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+50
−5
docs/superpowers/plans/2026-10-31-probe-burst-limit.md+8 −5docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R3.md+42 −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 62994f550..098af72b4 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`). 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. |
| +**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`). Plan rev 3 Astra R3 NOT READY (1 P1: notices to a receiver on an older release reach a tenant app; 2 P2: sender budget enforced at enqueue not dispatch (second round in that family), far-edge fill counting placement). Paul, 2026-10-31: apply the three fixes below in rev 4 and build without a fourth plan round; the per-task reviews and the whole-branch review check them (`CODEX-FINDINGS-PROBE-BURST-PLAN-R3.md`). |
| ## 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. **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. |
| +- 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. Burst counting has its own ownership condition, separate from the records condition (R3-2): `serveAssetFar` counts every request it holds a guard state for, whether or not a fill reached the home, **except** a request it reforwarded to the home as an ordinary hop (`reforwarded`), which the home counts; so each visitor response counts exactly once. |
| - 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 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. |
| +- Only boxes holding the mesh key send or accept notices, and **a box sends a notice only to a peer whose published edges file says it accepts them** (R3-1): a new boolean `burst_notices` in the edges file the host's edges-file pass writes (`true` from this release on). An older or rolled-back receiver rewrites its edges file without the field, so senders stop sending to it; a notice can never reach a tenant app through a receiver that lacks the interceptor. 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: at most 120 notice messages actually transmitted per minute per box, enforced at one point only, at dispatch: every peer worker takes a token from one box-wide limiter (120 per minute, no burst above that) immediately before transmitting; a notice that cannot get a token within 10 s of its trip, or whose expiry has passed, is dropped unsent and counted (R2-2, R3; the stopping rule's single-enforcement option); 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. |
| @@ -115,7 +115,7 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| - `reqrec.KindTrip = "trip"` and `func (r *Recorder) Trip(t Trip)` with `type Trip struct { Response; Until time.Time; Ref string }`, one record (message `trip burst <client prefix> until <rfc3339>`) with fields `kind=trip`, `tier=burst`, `rule=burst.probe-burst.cooldown`, `ref`, `cooldown_until`, at most 10 per app per minute. The trip's code is minted once at the trip site with `e.mintRef(reqrec.TierBurst, BurstRule.ID)` and the same value goes to `Recorder.Trip` and to the notices. |
| - Placement: |
| - **Check.** In ServeHTTP where the guard runs (edge.go, the `out.guard != nil` block): if the client is cooling and `edgeguard.Check(path, query)` hits, call `burstDecide` *before* `guardDecide` for non-static routes. For a static route served locally, a hard-tier hit (`CheckTier(..., TierHard)`) is decided by `burstDecide` in edge.go before `guardDecide`, since the hard tier refuses even existing files (protection spec ruling 7); a probe-tier decision moves to `serveTree`'s probe point (static.go): when the path is not found and the client is cooling and the path hits, `burstDecide` there; an existing file is never refused. `fleet` is true for forward routes and `viaTunnel` requests. |
| - - **Count.** In the observer defer, after `observeGuardCount`: when `out.guard != nil`, the request has no `Sec-Fetch-Mode` header, and it is a not-found by the Global Constraints rule, call `e.burst.note(appKey, client)`; on a trip, `Recorder.Trip` and Task 4's `e.sendBurstNotices(client, until, ref)`. `serveAssetFar`'s defer counts the same way under its records condition and never refuses. |
| + - **Count.** In the observer defer, after `observeGuardCount`: when `out.guard != nil`, the request has no `Sec-Fetch-Mode` header, and it is a not-found by the Global Constraints rule, call `e.burst.note(appKey, client)`; on a trip, `Recorder.Trip` and Task 4's `e.sendBurstNotices(client, until, ref)`. `serveAssetFar`'s defer counts under the burst ownership condition in the Global Constraints (not its records condition) and never refuses; the home's defer skips requests that arrived as asset fills. |
| - The Protection counts need no change: `observeGuardCount` already counts the verdict's rule, and `BurstRule` is not burst-mode, so a refusal counts as blocked and a would-be refusal as recorded, under group `burst/probe-burst`. |
| - [ ] **Step 1: Failing tests** through a real `Edge` with the real catalogue (as `guard_test.go`/`guard_usage_test.go` build one), clock injectable through the limiter: |
| @@ -130,6 +130,7 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| - `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. |
| + - `TestBurstFarCountsOnceIncludingReforward` (R3-2): a scanner's missing-asset requests through the far edge count once each (far edge) when filled, and once each (home) when the far edge reforwards them as ordinary hops. |
| - `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. |
| @@ -143,7 +144,7 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| **Files:** |
| - Create: `internal/edge/burst_notice.go` |
| -- Modify: `internal/edge/edge.go` (intercept), `internal/edge/mesh.go` (MAC domain) |
| +- Modify: `internal/edge/edge.go` (intercept), `internal/edge/mesh.go` (MAC domain), the edges-file writer in `internal/host` and `internal/edgesfile`/`homemap.go`'s `edgesFileView` (the `burst_notices` field) |
| - Test: `internal/edge/burst_notice_test.go` |
| **Interfaces:** |
| @@ -160,6 +161,8 @@ Draft rows (`where` relative to the repo root's owning package; the review may c |
| - `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): 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. |
| + - `TestBurstNoticeOnlyToAdvertisingPeers` (R3-1): a peer whose edges file lacks `burst_notices` (an older release) receives no notice at all, and its app sees no request on `/.carlos/burst-notice`. |
| + - `TestBurstNoticeBudgetAtDispatch` (R3-2): with three peers and a backlog built in one minute, transmissions in any 60 s window never exceed 120, across the minute boundary; notices older than 10 s are dropped and counted. |
| - `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. |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R3.md b/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R3.md| new file mode 100644 |
| index 000000000..db63b4d9c |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-PROBE-BURST-PLAN-R3.md |
| @@ -0,0 +1,42 @@ |
| +**1 new P1, 1 new P2, and 1 unresolved P2. Round 3 of 3; reviewed `bec821d38de5b02ad958622fb1407c8cc2326ac0`.** |
| + |
| +Dispositions concern the plan, not implemented fixes. |
| + |
| +| Previous finding | Disposition | Evidence | |
| +|---|---|---| |
| +| R1-1: burst watch suppresses hard/probe enforcement | **Fixed** | Shared verdict precedence and resolved-file regression test: [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** | Remote asset owners enter settings resolution; both guard sites consume it: [plan:186](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:186). | |
| +| R1-3: CLI lacks a read interface | **Fixed** | GET endpoint, client method, dispatch, docs and binary tests specified: [plan:189](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:189). | |
| +| R1-4: protection-only writes omit serial bump | **Fixed** | API serial bump, audit and response explicitly extended: [plan:188](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:188). | |
| +| R1-5: timestamp storage unbounded within one counter | **Fixed** | Fixed 60-entry ring, no counting during cool-down, 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 workers and three-second total deadline: [plan:154](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:154). | |
| +| R1-7: trip reference absent from record interface | **Fixed** | Explicit `Trip.Ref`, minted once and shared with notices: [plan:115](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:115). | |
| +| R2-1: asset fills erase browser exemption | **Fixed** | Home fills no longer count; far counting uses original headers: [plan:18](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:18). A separate counting-placement conflict remains below. | |
| +| R2-2: sender budget counts trips rather than transmissions | **Not fixed — remaining P2** | Task 4 now reserves messages, but only **before enqueueing**: [plan:154](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:154). Backlogged messages reserved in minute A can drain alongside 120 newly reserved messages in minute B. **Fix:** enforce one box-wide budget at dispatch, with explicit reservation expiry/revalidation, and test backlog recovery across a minute boundary. **Invariant:** at most 120 actual outgoing notices per minute, as [spec:135](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md:135) requires. | |
| +| R2-3: incoming bodies lack a read-time bound | **Fixed** | Receiver deadline, failure closure and stalled-connection test specified: [plan:155](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:155). | |
| + |
| +1. **P1 — Task 4: mixed-version rollout delivers platform notices to tenant applications.** |
| + |
| + [Plan:152](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:152) selects an arbitrary served hostname and sends the client’s `/32` or `/64`, sender box and trip reference. [Plan:154](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:154) sends to every eligible peer without establishing receiver support. |
| + |
| + During a rolling upgrade, an older receiver has no notice interceptor. `acceptHop` lets this non-hop request continue ([homemap.go:1277](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/homemap.go:1277)); the hostname selects an ordinary route ([edge.go:1908](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:1908)); an admitted POST reaches its application ([edge.go:2438](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/edge.go:2438)). That tenant receives another app’s client key and trip reference. TLS and the notice MAC do not prevent delivery to the wrong application layer. |
| + |
| + **Fix:** use a platform-owned endpoint whose fallback cannot reach tenants, or specify a receiver-first deployment gate that prevents sending to unsupported or rolled-back receivers. Add a mixed-version test asserting that no notice body reaches an app. |
| + |
| + **Invariant / fault family:** platform-wide protection evidence stays inside the platform trust boundary; another tenant must not receive it. See [spec:148](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md:148) and [spec:157](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md:157). |
| + |
| +2. **P2 — Task 3: the specified far-edge placement excludes the fills it must count.** |
| + |
| + The revised global rule assigns asset-fill counting to the far edge, but [plan:118](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/docs/superpowers/plans/2026-10-31-probe-burst-limit.md:118) still says to count “under its records condition.” |
| + |
| + That condition is `billed || !reached.Load()` ([assetcatch.go:1088](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/assetcatch.go:1088)). Sending fill headers sets `reached=true` ([assetcatch.go:1110](/home/paulca/.cache/tmp/claude-1001/design-probe-burst-491/internal/edge/assetcatch.go:1110)); a normal fill does not set `billed`. Following this placement therefore skips scanner 404 fills at the far edge, while the revised home rule skips them too. The scanner half of the new two-edge test would fail. |
| + |
| + **Fix:** give burst counting its own explicit ownership condition, separate from record/Protection-count ownership. Count completed fills at far, and ordinary forwarded requests at home; cover fill fallback and reforwarding to prevent double counting. |
| + |
| + **Invariant / fault family:** each eligible visitor response contributes exactly once to the burst counter. |
| + |
| +No P3 findings. Citations checked against the requested commit. No files changed; no tests run. |
| + |
| +The sole P1 concerns mixed-version notice routing. Refusing unsupported receivers up front, or cutting cross-edge sharing, removes it. For the recurring sender-budget family, recommend the stopping rule’s single-enforcement-point option: one dispatch budget with a boundary test. This concludes round 3. |
| + |
| +**NOT READY** |
| \ No newline at end of file |