Edge protection: the probe-burst limit blocks by default (#491)
Seven days of burst watch records on the flagship (2026-11-07 to 11-13, 165 apps): 246 trips from 139 /24s and 7,933 would-refuse records, with no real visitor among them. Paul approved promotion on that evidence (2026-11-14, recorded on #1004). edgeguard.BurstRule moves from watch to block, so a client in a cool-down is refused (429, Retry-After, reference code) the catalogue paths an app is not known to serve, on every app, including cool-downs shared by mesh notice. Ordinary pages, a static site's own files and fleet apps are unchanged; an app's record-only switch still turns it off. Missing site icons (favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png) no longer count toward a trip: in calibration a link-preview or monitoring fetcher tripped four times on nothing else. Two #491 follow-ups: a member can read the record-only switch with `carlos protection` (protection half of the telemetry GET only), and a notice worker drops notices to a peer that left the edges files instead of sending them late. The record-only headline copy is not applied (awaiting copy review). Astra R1 READY AFTER FIXES (P2 fixed, tested), R2 READY. Census census-ruling-probe-burst-block approved by Astra on #280. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from probe-burst-block-491 into main.
19 files changed,
+571
−50
docs/superpowers/notes/census-claims-probe-burst-block.tsv+1 −0docs/superpowers/notes/census-proposal-probe-burst-block.md+19 −0docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md+24 −0docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md+19 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md+51 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md+103 −0docs/superpowers/specs/2026-10-24-edge-request-protection-design.md+8 −0docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md+4 −1internal/console/apierrors.go+14 −5internal/console/protectionsetting_test.go+22 −4internal/edge/burst_edge_test.go+121 −31internal/edge/burst_notice.go+26 −0internal/edge/burst_notice_test.go+118 −2internal/edge/edge.go+1 −1internal/edge/guard.go+27 −3internal/edgeguard/catalogue.go+5 −2internal/edgeguard/catalogue_test.go+1 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv+6 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-claims-probe-burst-block.tsv b/docs/superpowers/notes/census-claims-probe-burst-block.tsv| new file mode 100644 |
| index 000000000..b5dc943bc |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-probe-burst-block.tsv |
| @@ -0,0 +1 @@ |
| +internal/edge/guard.go:Edge.noteBurst after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts |
diff --git a/docs/superpowers/notes/census-proposal-probe-burst-block.md b/docs/superpowers/notes/census-proposal-probe-burst-block.md| new file mode 100644 |
| index 000000000..77b54d232 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-probe-burst-block.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: probe-burst-block |
| + |
| +Ruling `census-ruling-probe-burst-block`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/edge/guard.go` `Edge.noteBurst` | body | unchanged (3) | after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts | |
| + |
| +Envelopes re-pinned: `internal/edge`, `internal/edgeguard`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/edge/guard.go` `Edge.noteBurst`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read |
| + |
| +Seal: `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182` → `94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md| new file mode 100644 |
| index 000000000..48c965fb3 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md |
| @@ -0,0 +1,24 @@ |
| +Reviewed `4c6416787..374bcff00711d247235b7bab0425e3c5ac6f11d8`, round 1. |
| + |
| +No P1 findings. |
| + |
| +**P2 — Notice workers: a stale snapshot can prune a newly created peer.** |
| + |
| +At [burst_notice.go:400](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:400), `burstPeerCurrent` reads the snapshot before acquiring `n.mu`, then prunes every peer using that snapshot. |
| + |
| +Failure scenario: a worker captures a snapshot without Betty and pauses. The home map adds Betty; `sendBurstNotices` acquires `n.mu`, reads the newer snapshot and creates Betty’s worker and queue (lines 266–278). The paused worker resumes and prunes Betty using its older snapshot (lines 400–403). Betty’s queued notices are dropped as `Gone` despite her remaining eligible. |
| + |
| +Fix: acquire `n.mu` before reading the home-map snapshot, matching `sendBurstNotices`. Add a deterministic concurrency test covering this ordering. |
| + |
| +Fault family: peer reconciliation must not apply an older snapshot after newer peer creation. Fix within this round; no further review round required. |
| + |
| +No P3 findings. |
| + |
| +Census verdicts: |
| + |
| +- **`internal/edge`: approve.** Read `burst_notice.go` lines 252–305 and 362–494, including the new check and its dispatch caller; also the changed tests and guard comments. The change adds no tenant-controlled root reads or execution paths and preserves signing and transport checks. The P2 concerns erroneous notice loss. |
| +- **`internal/edgeguard`: approve.** Read [catalogue.go:114](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edgeguard/catalogue.go:114), lines 114–170, and the changed lookup test. Promotion changes the existing rule’s mode without adding input paths. Existing catalogue, static-file, fleet and record-only checks remain in place. |
| + |
| +`git diff --check` passed. Targeted tests could not start: the read-only sandbox denied Go’s build-directory creation. No files changed; no full suites run. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md| new file mode 100644 |
| index 000000000..3e7ea5989 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md |
| @@ -0,0 +1,19 @@ |
| +Reviewed `fe516719e18e85445c2972fd4a69b3393d9557cf` against local `amadan/main`, within the brief’s round-2 scope. |
| + |
| +No P1, P2, or P3 findings. |
| + |
| +Round-1 P2: **resolved**. Snapshot acquisition now occurs under `n.mu`, matching peer creation ([burst_notice.go:395](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:395), lines 395–406). |
| + |
| +The icon exclusion requires a plain 404 with no guard verdict. Hard/probe matches still count, and cool-down refusal runs before the observer’s exclusion. Both checks start from `r.URL.Path`; catalogue normalization and query matching retain priority through the verdict. Empty paths are safe; trailing slashes are not treated as icon filenames. |
| + |
| +`TestBurstIconMissesNeverCount` tests its stated behavior through a real Edge: repeated icon 404s produce no counts or trips, followed by ordinary misses that trip the same client. It does not directly cover icon-shaped catalogue matches or escaping variants. |
| + |
| +Census verdicts: |
| + |
| +- **`Edge.noteBurst`: APPROVE**, retaining `legacy / accepted-legacy`. Read [guard.go:287](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/guard.go:287), lines 287–352. The added string check introduces no file, store, registry, or execution access and preserves catalogue verdicts. |
| +- **`internal/edge` envelope: APPROVE.** Read the changed functions and tests, including `guard.go` lines 297–352 and [burst_notice.go:252](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:252), lines 252–305 and 362–498; traced guard callers in `edge.go` lines 2864–2909 and `static.go` lines 638–703. No new tenant-controlled root access; signing, transport checks, static-file exemptions, and record-only behavior remain intact. |
| +- **`internal/edgeguard` envelope: APPROVE.** Read [catalogue.go:114](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edgeguard/catalogue.go:114), lines 114–171, and the changed lookup test. Promotion changes the existing rule’s mode without adding input paths or weakening its checks. |
| + |
| +`git diff --check` passed. Targeted tests could not start: the read-only sandbox denied Go’s work-directory creation. No files changed; no full suites run. |
| + |
| +READY |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md| new file mode 100644 |
| index 000000000..e8515ea72 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md |
| @@ -0,0 +1,51 @@ |
| +# Review brief: branch probe-burst-block-491, icon exclusion and census, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `probe-burst-block-491`, commit 4cdfed7fe23e05d8d049bda2e6e6e641787a59a1. |
| +Under review: commit 7065330f4 (the icon exclusion) and the census card |
| +`docs/superpowers/notes/census-proposal-probe-burst-block.md` for the whole |
| +branch against amadan's main (`git diff amadan/main...4cdfed7fe` touches |
| +internal/edge, internal/edgeguard, internal/console and docs; the merge commit |
| +4cdfed7fe only brings main in). |
| +Authorities, merged on main: `docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md`, |
| +`docs/superpowers/specs/2026-10-24-edge-request-protection-design.md` §5.5. |
| + |
| +Round 1 (`docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md`) |
| +found one P2 (stale snapshot pruning a new peer), fixed in 1cc2ca0f2 with the |
| +test added in f2e5c4e81. Give one line on it: resolved, partly or not. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved promotion to block and the icon exclusion (2026-11-14, |
| + recorded on amadan discussion #1004). Whether to exclude icons is decided; |
| + check only that the mechanism is right. |
| + |
| +## What to check |
| + |
| +1. `burstIconPath` and its call in `Edge.noteBurst` (internal/edge/guard.go): |
| + does it exclude only plain not-founds for favicon.ico/.png/.svg, |
| + favicon-*.png and apple-touch-icon*.png? Can a scanner use it to make |
| + catalogue probes uncounted (a hard or probe match must still count), or |
| + to avoid a refusal during a cool-down? Is the path it reads the one the |
| + catalogue matched (escaping, `//`, query, trailing slash)? Any panic on |
| + an empty or odd path? |
| +2. `TestBurstIconMissesNeverCount`: does it test what it says? |
| +3. Census: a verdict for the unit `internal/edge/guard.go` `Edge.noteBurst` |
| + (claim in `docs/superpowers/notes/census-claims-probe-burst-block.tsv`) |
| + and for each re-pinned envelope (`internal/edge`, `internal/edgeguard`), |
| + per AGENTS.md "The census", citing the lines read. |
| + |
| +## 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. |
| +- **P3**: clarity or polish. Follow-up list only. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3 with evidence (file:line), failure scenario, |
| +fix and fault family. Then the census verdicts. End with exactly one of |
| +READY, READY AFTER FIXES, NOT READY. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md| new file mode 100644 |
| index 000000000..50e502f4f |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md |
| @@ -0,0 +1,103 @@ |
| +# Review brief: branch probe-burst-block-491 (whole branch, with its census card), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `probe-burst-block-491`, commit e974371a182279e35011108630d624e07cf657bc. |
| +Under review: the diff `4c6416787..e974371a1` (base is amadan's main). |
| +Authorities, merged on main: |
| +`docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md` (§3, §4, §5a, §6), |
| +`docs/superpowers/specs/2026-10-24-edge-request-protection-design.md` §5.5, |
| +`docs/superpowers/plans/2026-10-31-probe-burst-limit.md`, and the precedent |
| +commit 378646f1c ("Edge protection: the hard tier blocks by default"). |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches, |
| +and check every claim against that code. |
| + |
| +## What the branch does |
| + |
| +1. `internal/edgeguard/catalogue.go`: `BurstRule.Mode` goes from watch to |
| + block, so in the default mode (`guardCatalogue`) a client in a probe-burst |
| + cool-down is refused (429) the catalogue paths an app is not known to |
| + serve, on every app, including cool-downs received as mesh notices. |
| + Tests that relied on watch now name watch mode or demote the rule; |
| + new witness `TestBurstCatalogueRefusesByDefault`; |
| + `TestBurstNoticeAppliesOnThePeer` runs in the default and block modes. |
| +2. `internal/console/apierrors.go`: the telemetry GET |
| + (`GET /api/cli/apps/{account}/{app}/telemetry`, read by |
| + `carlos protection`) answers a person who is a member but not an owner |
| + with the protection half alone, instead of 403. Owners and Operate |
| + service credentials read the whole object. The PUT is unchanged. |
| +3. `internal/edge/burst_notice.go`: a notice worker checks its peer against |
| + the current home map before taking each budget slot (`burstPeerCurrent`), |
| + prunes departed peers, and drops the notice as Gone. New test |
| + `TestBurstNoticeDepartedPeerStopsAtDispatch`. |
| +4. Census: `docs/superpowers/notes/census-proposal-probe-burst-block.md` |
| + re-pins the `internal/edge` and `internal/edgeguard` envelopes; no unit |
| + changes. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul's rulings in the probe-burst spec (thresholds 60/60 s/10 min, |
| + per-app counting, platform-wide cool-down, Sec-Fetch-Mode never counts, |
| + fleet apps only recorded, record-only switch per app). Report only |
| + mechanisms that fail to honour them. |
| +- Whether to promote at all is Paul's call on the calibration evidence, |
| + not this review's. |
| + |
| +## What to check |
| + |
| +1. Promotion: with the rule blocking by default, can anything now be |
| + refused that the spec says must never be: a page not in the catalogue, |
| + a static site's existing file, a fleet app's request, a request to an |
| + app whose record-only switch is on, or a request from a client not |
| + cooling? Is `guardBlock` / `guardWatch` / `guardOff` behaviour unchanged? |
| + Does verdict precedence (`decideVerdict`) still never let a burst |
| + verdict replace or weaken a hard block? |
| +2. Tests: do the changed tests still test what their names say, and does |
| + any test elsewhere (edge, edgeguard, console, reqrec, host) still |
| + assume the burst rule watches by default? Does `demoteBurstRule` restore |
| + global state safely (no `t.Parallel` races on `edgeguard.BurstRule`)? |
| +3. Telemetry GET: is the member read gated correctly (instanceGate, then |
| + role)? Can a member, a non-member, an Instance-role service token or a |
| + linked/scoped credential now read anything beyond the protection half, |
| + or anything at all they could not before? Is the response for an absent |
| + protection half `{}`? Does any other caller of `handleAPITelemetryGet` |
| + or `telemetryGate` change behaviour? |
| +4. Notice workers: can `burstPeerCurrent` deadlock (it takes `n.mu`; is it |
| + ever called with `n.mu` held, or while `sendBurstNotices` holds it and |
| + waits on the worker)? Can pruning close `p.stop` twice, or prune a |
| + freshly created peer for the same box? Does a nil home map now drop |
| + notices that were sent before? Is anything sent to a box no longer in |
| + the targets? |
| +5. Census: give a verdict on each re-pinned envelope (`internal/edge`, |
| + `internal/edgeguard`) per AGENTS.md "The census": reject if the change |
| + lets root open, run, query or follow anything new from tenant-, app- or |
| + agent-controlled input, or weakens a check root relies on. |
| + |
| +## 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 or task, 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 the census verdict per envelope (approve or reject, citing |
| +the lines read). 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. |
diff --git a/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md b/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md| index ae50a178f..e4a2497a4 100644 |
| --- a/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md |
| +++ b/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md |
| @@ -365,6 +365,14 @@ route (or one allow rule) removes it. *My call:* 60 not-founds in 60 s, a 10-min |
| keyed by `clientIP` truncated as #358 does (/32 IPv4, /64 IPv6); the builder |
| checks both numbers against request records before shipping. |
| +*Calibrated and promoted (#491, Paul 2026-11-14):* seven days of watch records |
| +(2026-11-07 to 11-13) held up 60 in 60 s and 10 minutes, and the rule blocks |
| +by default, platform-wide. One change from the review: a missing site icon |
| +(`favicon.ico`/`.png`/`.svg`, `favicon-*.png`, `apple-touch-icon*.png`, in any |
| +directory) never counts toward a trip, since link-preview fetchers and monitors |
| +ask for them on their own and one tripped four times on nothing else. A hard |
| +or probe match on such a path still counts. |
| + |
| ### 5.6 The "under attack" switch |
| A per-app switch, set by CLI or console and live within seconds, for an incident: |
diff --git a/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md b/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md| index 8954b0608..5a6949d7d 100644 |
| --- a/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md |
| +++ b/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md |
| @@ -76,7 +76,10 @@ Added here: |
| - **What counts as a not-found.** A response the edge sends or passes on with |
| status 404, plus any hard or probe tier match (watch or block) whatever the |
| status. A burst-mode rule match (`probe/admin`) counts only if the answer |
| - was a 404, since real admins use those paths. *My call.* |
| + was a 404, since real admins use those paths. *My call.* A plain 404 for a |
| + missing site icon (`favicon.ico`/`.png`/`.svg`, `favicon-*.png`, |
| + `apple-touch-icon*.png`) never counts (Paul, 2026-11-14, from the #491 |
| + calibration review). |
| - **Browsers never count** (builder check 1). A request carrying a |
| `Sec-Fetch-Mode` header, which every current browser sends on every request |
| and scanners do not, never counts toward a trip. *My call:* this stops a |
diff --git a/internal/console/apierrors.go b/internal/console/apierrors.go| index f8d6b759f..ec66f3ed6 100644 |
| --- a/internal/console/apierrors.go |
| +++ b/internal/console/apierrors.go |
| @@ -98,9 +98,9 @@ func (s *Server) handleAPIAvailability(w http.ResponseWriter, r *http.Request) { |
| writeJSON(w, http.StatusOK, resp) |
| } |
| -// telemetryGate is the instance gate plus the owner rule both telemetry |
| -// doors keep: the browser forms for these settings are owner-only, so the |
| -// person path here is too. A SERVICE holds no account role (AccountByID does |
| +// telemetryGate is the instance gate plus the owner rule the telemetry PUT |
| +// keeps: the browser forms for these settings are owner-only, so the person |
| +// path here is too. A SERVICE holds no account role (AccountByID does |
| // not populate Role), which is why this reads the kind first. |
| func (s *Server) telemetryGate(w http.ResponseWriter, r *http.Request) (string, *Account, string, bool) { |
| principal, acct, app, ok := s.instanceGate(w, r) |
| @@ -117,12 +117,18 @@ func (s *Server) telemetryGate(w http.ResponseWriter, r *http.Request) (string, |
| // handleAPITelemetryGet answers the app-level telemetry object as stored |
| // (absent halves absent, so the caller sees what is set on the app itself, |
| -// not what it inherits). The PUT's gate: it is that door's read. |
| +// not what it inherits). An owner, or a service credential the PUT would |
| +// take, reads the whole object. A member who is not an owner reads the |
| +// protection half alone (#491): the Protection tab already shows every |
| +// member whether the app records only, so `carlos protection` shows them |
| +// the same; the errors and analytics halves stay the owner's. |
| func (s *Server) handleAPITelemetryGet(w http.ResponseWriter, r *http.Request) { |
| - _, acct, app, ok := s.telemetryGate(w, r) |
| + _, acct, app, ok := s.instanceGate(w, r) |
| if !ok { |
| return |
| } |
| + p, _ := principalFrom(r.Context()) |
| + protectionOnly := p.Kind == PrincipalUser && acct.Role != RoleOwner |
| ctx, cancel := context.WithTimeout(r.Context(), instanceStoreTimeout) |
| defer cancel() |
| st, _, err := telemetry.Read(ctx, s.cfg.Releases, telemetry.AppKey(acct.Sqid, app)) |
| @@ -131,6 +137,9 @@ func (s *Server) handleAPITelemetryGet(w http.ResponseWriter, r *http.Request) { |
| jsonError(w, http.StatusBadGateway, "could not read the settings") |
| return |
| } |
| + if protectionOnly { |
| + st = telemetry.Settings{Protection: st.Protection} |
| + } |
| writeJSON(w, http.StatusOK, st) |
| } |
diff --git a/internal/console/protectionsetting_test.go b/internal/console/protectionsetting_test.go| index 344de2c57..9bf3b49eb 100644 |
| --- a/internal/console/protectionsetting_test.go |
| +++ b/internal/console/protectionsetting_test.go |
| @@ -264,8 +264,9 @@ func TestAPITelemetryProtectionAuditLine(t *testing.T) { |
| } |
| } |
| -// The read beside the PUT: the app's stored settings as stored, under the |
| -// PUT's gate (Operate, and a person must own the account). |
| +// The read beside the PUT: the app's stored settings as stored, for an |
| +// Operate credential or an owner. A member reads the protection half alone, |
| +// as the Protection tab shows it to them (#491). |
| func TestAPITelemetryGet(t *testing.T) { |
| fx, _ := ptFixture(t) |
| getURL := fx.ts.URL + "/api/cli/apps/" + fx.sqid + "/shop/telemetry" |
| @@ -297,7 +298,24 @@ func TestAPITelemetryGet(t *testing.T) { |
| t.Fatal(err) |
| } |
| member := cliToken(t, fx, "kim@keymail.dev", "code-ps-get-member") |
| - if status, _, body := rawReq(t, http.MethodGet, getURL, member, ""); status != http.StatusForbidden { |
| - t.Fatalf("member GET = %d %s, want 403", status, body) |
| + status, _, body = rawReq(t, http.MethodGet, getURL, member, "") |
| + var st telemetry.Settings |
| + if status != http.StatusOK || json.Unmarshal([]byte(body), &st) != nil || !telemetry.RecordOnly(st) || |
| + st.Errors != nil || st.Analytics != nil || strings.Contains(body, "log_level") { |
| + t.Fatalf("member GET = %d %s, want the protection half alone", status, body) |
| + } |
| + // Nothing stored for protection: a member sees nothing at all. |
| + if err := telemetry.Update(context.Background(), fx.rel, telemetry.AppKey(fx.sqid, "shop"), func(st *telemetry.Settings) { |
| + st.Protection = nil |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if status, _, body := rawReq(t, http.MethodGet, getURL, member, ""); status != http.StatusOK || strings.TrimSpace(body) != "{}" { |
| + t.Fatalf("member GET with no protection stored = %d %s, want {}", status, body) |
| + } |
| + // A stranger to the account gets nothing. |
| + stranger := cliToken(t, fx, "sam@keymail.dev", "code-ps-get-stranger") |
| + if status, _, body := rawReq(t, http.MethodGet, getURL, stranger, ""); status == http.StatusOK { |
| + t.Fatalf("non-member GET = %d %s, want a refusal", status, body) |
| } |
| } |
diff --git a/internal/edge/burst_edge_test.go b/internal/edge/burst_edge_test.go| index eed075b06..fbf4fca11 100644 |
| --- a/internal/edge/burst_edge_test.go |
| +++ b/internal/edge/burst_edge_test.go |
| @@ -220,11 +220,11 @@ func (g *burstRig) wantRefused(t *testing.T, w *httptest.ResponseRecorder, until |
| return code |
| } |
| -// The scanner's 60th not-found trips it. In the default (watch) mode its |
| -// 61st catalogue request still reaches the app, and is recorded as the |
| -// refusal it would have been, saying the cool-down started on this app. |
| +// The scanner's 60th not-found trips it. In watch mode its 61st catalogue |
| +// request still reaches the app, and is recorded as the refusal it would |
| +// have been, saying the cool-down started on this app. |
| func TestBurstTripsAndRecordsWouldRefuse(t *testing.T) { |
| - g := newBurstRig(t, "") |
| + g := newBurstRig(t, "watch") |
| until := g.trip(t, burstHost) |
| tr := g.rec.trips[0] |
| ref, err := reqrec.ParseRef(tr.Ref, g.key) |
| @@ -263,6 +263,51 @@ func TestBurstRefusesInBlockMode(t *testing.T) { |
| } |
| } |
| +// The promotion (#491): in the default mode the burst rule refuses. After |
| +// the trip the cooling client's next catalogue request is refused on the |
| +// app it tripped on and on another app, an ordinary page still reaches the |
| +// app, and the probe rules themselves still only watch for a client that is |
| +// not cooling. The app's record-only switch turns the refusal off for that |
| +// app alone. |
| +func TestBurstCatalogueRefusesByDefault(t *testing.T) { |
| + g := newBurstRig(t, "", burstHost+"/about") |
| + if g.e.guard != guardCatalogue { |
| + t.Fatalf("guard mode %v, want the catalogue's", g.e.guard) |
| + } |
| + until := g.trip(t, burstHost) |
| + n := g.upstream.Load() |
| + code := g.wantRefused(t, g.get(burstHost, "/wp-login.php"), until) |
| + m := g.lastMatch(t, "/wp-login.php") |
| + wantBurstMatch(t, m, reqrec.KindBlock, reqrec.CooldownFromThisApp, until) |
| + if m.Ref != code || m.Status != 429 || g.upstream.Load() != n { |
| + t.Fatalf("this app: %+v, upstream %d; want the refusal", m, g.upstream.Load()-n) |
| + } |
| + g.wantRefused(t, g.get(burstOther, "/xmlrpc.php"), until) |
| + wantBurstMatch(t, g.lastMatch(t, "/xmlrpc.php"), reqrec.KindBlock, reqrec.CooldownFromOtherApp, until) |
| + if w := g.get(burstHost, "/about"); w.Code != 200 || w.Body.String() != "page /about" { |
| + t.Fatalf("/about: %d %q, want the page", w.Code, w.Body.String()) |
| + } |
| + |
| + r := httptest.NewRequest("GET", "http://"+burstHost+"/wp-login.php", nil) |
| + r.RemoteAddr = "198.51.100.7:4000" |
| + w := httptest.NewRecorder() |
| + g.e.ServeHTTP(w, r) |
| + if w.Code != 404 || w.Body.String() != "the app's own 404" { |
| + t.Fatalf("a client not cooling: %d %q, want the app's answer", w.Code, w.Body.String()) |
| + } |
| + if m := g.lastMatch(t, "/wp-login.php"); m.Kind != reqrec.KindWatch || m.Tier != reqrec.TierProbe { |
| + t.Fatalf("a client not cooling: match %+v, want the probe watch", m) |
| + } |
| + |
| + g.e.SetProtectionRecordOnly(map[string]bool{"bdk/shop": true}) |
| + n = g.upstream.Load() |
| + if w := g.get(burstHost, "/wp-login.php"); w.Code != 404 || w.Body.String() != "the app's own 404" || g.upstream.Load() != n+1 { |
| + t.Fatalf("record only: %d %q, want the app's answer", w.Code, w.Body.String()) |
| + } |
| + wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| + g.wantRefused(t, g.get(burstOther, "/wp-login.php"), until) |
| +} |
| + |
| // Review Focus 1: a page that is not in the catalogue is never refused, |
| // whoever shares the address. |
| func TestBurstNeverRefusesAnOrdinaryPage(t *testing.T) { |
| @@ -318,6 +363,39 @@ func TestBurstBrowserRequestsNeverCount(t *testing.T) { |
| } |
| } |
| +// Missing site icons never count (Paul, #491): a fetcher that asks for |
| +// favicons and touch icons an app does not have is not a scanner, however |
| +// many it misses. Every icon spelling below is a 404 from the app; the same |
| +// number of other misses still trips. |
| +func TestBurstIconMissesNeverCount(t *testing.T) { |
| + icons := []string{"/favicon.ico", "/favicon.png", "/favicon.svg", "/Favicon.ICO", "/favicon-32x32.png", |
| + "/apple-touch-icon.png", "/apple-touch-icon-precomposed.png", "/apple-touch-icon-120x120.png", |
| + "/apple-touch-icon-152x152-precomposed.png", "/static/favicon.ico", "/img/apple-touch-icon.png"} |
| + g := newBurstRig(t, "") |
| + for i := 0; i < burstThreshold+10; i++ { |
| + if w := g.get(burstHost, icons[i%len(icons)]); w.Code != 404 { |
| + t.Fatalf("%s: %d", icons[i%len(icons)], w.Code) |
| + } |
| + } |
| + shop := burstAppKey(registry.Route{Account: "bdk", App: "shop"}) |
| + if n := g.e.burst.ringLen(shop, burstScanner); n != 0 || len(g.rec.trips) != 0 { |
| + t.Fatalf("icon misses counted %d times, %d trips", n, len(g.rec.trips)) |
| + } |
| + // Names that only look like icons count as any other miss. |
| + for _, p := range []string{"/favicon.php", "/apple-touch-icon.php", "/favicon.ico/x", "/myfavicon.ico"} { |
| + if burstIconPath(p) { |
| + t.Fatalf("%s read as an icon", p) |
| + } |
| + } |
| + // The control: ordinary misses from the same client trip. |
| + for i := 0; i < burstThreshold; i++ { |
| + g.get(burstHost, fmt.Sprintf("/missing-%d", i)) |
| + } |
| + if _, _, ok := g.e.burst.cooling(burstScanner); !ok || len(g.rec.trips) != 1 { |
| + t.Fatalf("ordinary misses: cooling %v, trips %d; want one trip", ok, len(g.rec.trips)) |
| + } |
| +} |
| + |
| // An admin page is a page real admins open: a match on it counts only when |
| // the app has no such page. |
| func TestBurstAdminCountsOnlyOn404(t *testing.T) { |
| @@ -400,21 +478,31 @@ func TestBurstFleetAppNeverRefused(t *testing.T) { |
| } |
| // One request has one verdict, one record and one Protection count, however |
| -// many rules it meets. |
| +// many rules it meets. In the default mode that count is a block: the burst |
| +// rule refuses, and the Protection tab counts a refusal as blocked. |
| func TestBurstOneVerdictPerRequest(t *testing.T) { |
| - g := newBurstRig(t, "") |
| - until := g.trip(t, burstHost) |
| - g.meter.Drain() |
| - matches := len(g.rec.match) |
| - g.get(burstHost, "/wp-login.php") |
| - if len(g.rec.match) != matches+1 { |
| - t.Fatalf("%d matches for one request", len(g.rec.match)-matches) |
| - } |
| - wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| - f := g.meter.Drain() |
| - d, ok := f.Guard[usage.GuardKey(burstHost, "bdk", "shop")] |
| - if len(f.Guard) != 1 || !ok || d.Checked != 1 || d.Watch != 1 || d.Block != 0 || !maps.Equal(d.Groups, map[string]int64{"burst/probe-burst": 1}) { |
| - t.Fatalf("guard counts %+v, want one recorded burst/probe-burst", f.Guard) |
| + for _, tc := range []struct { |
| + protect string |
| + kind reqrec.Kind |
| + watch, block int64 |
| + }{ |
| + {"", reqrec.KindBlock, 0, 1}, |
| + {"watch", reqrec.KindWatch, 1, 0}, |
| + } { |
| + g := newBurstRig(t, tc.protect) |
| + until := g.trip(t, burstHost) |
| + g.meter.Drain() |
| + matches := len(g.rec.match) |
| + g.get(burstHost, "/wp-login.php") |
| + if len(g.rec.match) != matches+1 { |
| + t.Fatalf("mode %q: %d matches for one request", tc.protect, len(g.rec.match)-matches) |
| + } |
| + wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), tc.kind, reqrec.CooldownFromThisApp, until) |
| + f := g.meter.Drain() |
| + d, ok := f.Guard[usage.GuardKey(burstHost, "bdk", "shop")] |
| + if len(f.Guard) != 1 || !ok || d.Checked != 1 || d.Watch != tc.watch || d.Block != tc.block || !maps.Equal(d.Groups, map[string]int64{"burst/probe-burst": 1}) { |
| + t.Fatalf("mode %q: guard counts %+v, want one %s burst/probe-burst", tc.protect, f.Guard, tc.kind) |
| + } |
| } |
| } |
| @@ -436,9 +524,11 @@ func TestBurstWatchNeverWeakensABlock(t *testing.T) { |
| } |
| }) |
| t.Run("static rewrite", func(t *testing.T) { |
| - // The default mode, where the burst rule watches and the .env rule |
| - // blocks. The .git rule watches here, so a hard-tier request path |
| - // whose own verdict does not block still reaches the static handler. |
| + // The default mode with the burst rule watching, as an app's own |
| + // exemption will make it, and the .env rule blocking. The .git rule |
| + // watches here, so a hard-tier request path whose own verdict does |
| + // not block still reaches the static handler. |
| + demoteBurstRule(t) |
| g := newBurstStaticRig(t, "", map[string]string{".env": "SECRET=1", "_redirects": "/* /.env 200\n"}) |
| until := g.trip(t, burstHost) |
| env, ok := edgeguard.RuleByID("hard.secrets.env") |
| @@ -471,8 +561,8 @@ func TestBurstWatchNeverWeakensABlock(t *testing.T) { |
| if m := g.lastMatch(t, "/.git/config"); m.Kind != reqrec.KindBlock || m.RuleID != "hard.secrets.env" { |
| t.Fatalf("/.git/config: match %+v, want the hard block", m) |
| } |
| - // Without the promotion the burst watch stands, as the first |
| - // verdict that does not block. |
| + // With the .env rule watching too, the burst watch stands, as the |
| + // first verdict that does not block. |
| env.Mode = edgeguard.ModeWatch |
| g.get(burstHost, "/wp-login.php") |
| wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| @@ -795,13 +885,14 @@ func TestBurstStaleFillCountedOnceAtTheHome(t *testing.T) { |
| } |
| } |
| -// promoteBurstRule sets the burst rule's catalogue mode to block for the |
| -// test, as the later one-line promotion will: in the default mode the burst |
| -// rule then refuses while the probe rules still only watch. |
| -func promoteBurstRule(t *testing.T) { |
| +// demoteBurstRule sets the burst rule's catalogue mode back to watch for the |
| +// test, as it was before the promotion (#491): in the default mode the burst |
| +// rule then only records. |
| +func demoteBurstRule(t *testing.T) { |
| t.Helper() |
| - edgeguard.BurstRule.Mode = edgeguard.ModeBlock |
| - t.Cleanup(func() { edgeguard.BurstRule.Mode = edgeguard.ModeWatch }) |
| + mode := edgeguard.BurstRule.Mode |
| + edgeguard.BurstRule.Mode = edgeguard.ModeWatch |
| + t.Cleanup(func() { edgeguard.BurstRule.Mode = mode }) |
| } |
| // Fix round 1, finding 2: a static site's own file is never refused by the |
| @@ -826,8 +917,7 @@ func TestBurstNeverRefusesAnExistingStaticHardFile(t *testing.T) { |
| } |
| } |
| }) |
| - t.Run("burst rule promoted", func(t *testing.T) { |
| - promoteBurstRule(t) |
| + t.Run("default mode", func(t *testing.T) { |
| // With the .env rule watching (as an app's own allow rule will make |
| // it), a burst refusal still never takes a file the site has. |
| env, ok := edgeguard.RuleByID("hard.secrets.env") |
diff --git a/internal/edge/burst_notice.go b/internal/edge/burst_notice.go| index a5a518d75..d174957bf 100644 |
| --- a/internal/edge/burst_notice.go |
| +++ b/internal/edge/burst_notice.go |
| @@ -385,6 +385,27 @@ func (e *Edge) runBurstPeer(n *burstNotices, p *burstPeer) { |
| } |
| } |
| +// burstPeerCurrent reports whether p is still one of this box's notice |
| +// peers in the home map as it stands now, pruning every peer that is not. |
| +// A box that left the edges files, stopped advertising notices or lost its |
| +// dial address is otherwise pruned only on the next trip, so a notice |
| +// queued for it, or waiting for a slot in the budget, would still be sent |
| +// to it (#491 follow-up). Checked before every slot is taken, so a dropped |
| +// notice never spends one. |
| +func (e *Edge) burstPeerCurrent(n *burstNotices, p *burstPeer) bool { |
| + m := e.homes.Load() |
| + if m == nil { |
| + return false |
| + } |
| + // The snapshot is read under n.mu, as sendBurstNotices reads it, so a |
| + // worker can never prune with a map older than the one a newer peer was |
| + // created from (Astra R1 P2). |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + n.pruneLocked(n.targetsLocked(m.snapshot(), e.box, m.privateDial)) |
| + return n.peers[p.box] == p |
| +} |
| + |
| // retire removes an idle peer, unless a notice arrived for it meanwhile. |
| func (n *burstNotices) retire(p *burstPeer) bool { |
| n.mu.Lock() |
| @@ -405,6 +426,11 @@ func (n *burstNotices) retire(p *burstPeer) bool { |
| func (e *Edge) dispatchBurstNotice(n *burstNotices, p *burstPeer, nt burstNotice) { |
| var at time.Time |
| for { |
| + if !e.burstPeerCurrent(n, p) { |
| + n.count(func(s *burstNoticeStats) { s.Gone++ }) |
| + e.logThrottled("burst-notice-gone", fmt.Sprintf("probe-burst notice to %s dropped: the box left the edges files", p.box)) |
| + return |
| + } |
| now := e.burstNow() |
| if now.Sub(nt.trip) > burstNoticeMaxAge || !nt.until.After(now) { |
| n.count(func(s *burstNoticeStats) { s.Stale++ }) |
diff --git a/internal/edge/burst_notice_test.go b/internal/edge/burst_notice_test.go| index 2f578afae..ad07e8706 100644 |
| --- a/internal/edge/burst_notice_test.go |
| +++ b/internal/edge/burst_notice_test.go |
| @@ -3,6 +3,7 @@ package edge |
| import ( |
| "bufio" |
| "bytes" |
| + "cmp" |
| "context" |
| "crypto/rand" |
| "crypto/tls" |
| @@ -309,9 +310,19 @@ func transmitted(x *noticeEdge) int64 { |
| } |
| // A client that trips on annie is refused on betty, on betty's own app, |
| -// with the record saying the cool-down started on another app. |
| +// with the record saying the cool-down started on another app: in block |
| +// mode, and in the default mode since the promotion (#491). |
| func TestBurstNoticeAppliesOnThePeer(t *testing.T) { |
| - s := newNoticeScene(t, true) |
| + for _, protect := range []string{"block", ""} { |
| + t.Run("mode "+cmp.Or(protect, "default"), func(t *testing.T) { |
| + s := newNoticeScene(t, true) |
| + t.Setenv("CARLOS_EDGE_PROTECT", protect) |
| + burstNoticeAppliesOnThePeer(t, s) |
| + }) |
| + } |
| +} |
| + |
| +func burstNoticeAppliesOnThePeer(t *testing.T, s *noticeScene) { |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "bdk", "shop", true) |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "bab", "blog", true) |
| s.publish(t) |
| @@ -542,6 +553,111 @@ func TestBurstNoticeOnlyToAdvertisingPeers(t *testing.T) { |
| } |
| } |
| +// #491 follow-up: a peer that leaves while a notice for it waits for a slot |
| +// in the budget is dropped at dispatch, not sent once the slot frees, and |
| +// its worker stops then rather than on the next trip. A peer that stayed |
| +// still gets its notice. |
| +func TestBurstNoticeDepartedPeerStopsAtDispatch(t *testing.T) { |
| + s := newNoticeScene(t, true) |
| + a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "bdk", "shop", true) |
| + b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "bab", "blog", true) |
| + c := s.add(t, "carol", "127.0.0.13", "docs.example.com", "bab", "docs", true) |
| + s.publish(t) |
| + stats := func() burstNoticeStats { return a.edge().notices.stats() } |
| + peers := func() int { |
| + n := a.edge().notices |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + return len(n.peers) |
| + } |
| + |
| + // 60 trips 50 s in use the whole budget; one more 105 s in waits for the |
| + // slots that free at 110 s, one notice per peer. |
| + s.clock.advance(50 * time.Second) |
| + for i := range 60 { |
| + s.trip(t, a, noticeClient(i)) |
| + } |
| + waitFor(t, 10*time.Second, "120 notices sent", func() bool { return stats().Sent == 120 }) |
| + s.clock.advance(55 * time.Second) |
| + s.trip(t, a, noticeClient(60)) |
| + time.Sleep(300 * time.Millisecond) |
| + if st := stats(); st.Sent != 120 || st.Gone != 0 || peers() != 2 { |
| + t.Fatalf("counts %+v, %d peers while two notices wait for a slot", st, peers()) |
| + } |
| + |
| + // Betty stops advertising notices while hers waits. |
| + b.file.advertise = false |
| + s.publish(t) |
| + s.clock.advance(5*time.Second + 100*time.Millisecond) |
| + waitFor(t, 5*time.Second, "carol's notice sent and betty's dropped", func() bool { |
| + st := stats() |
| + return st.Sent == 121 && st.Gone == 1 |
| + }) |
| + if n := len(b.arrivals()); n != 60 { |
| + t.Fatalf("betty saw %d notices, want the 60 sent before she left", n) |
| + } |
| + if n := len(c.arrivals()); n != 61 { |
| + t.Fatalf("carol saw %d notices, want 61", n) |
| + } |
| + waitFor(t, 5*time.Second, "betty's worker gone", func() bool { return peers() == 1 }) |
| +} |
| + |
| +// Astra R1 P2: a worker checking its peer never prunes with a home map |
| +// older than the one a newer peer was created from. The worker waits on |
| +// n.mu while sendBurstNotices, holding it, sees betty arrive in a newer |
| +// snapshot and creates her peer; once the worker has the lock, betty stays. |
| +// With the snapshot read before the lock the worker would prune her. |
| +func TestBurstPeerCurrentNeverPrunesWithAnOlderSnapshot(t *testing.T) { |
| + file := func(box, eip, host string) edgesFileView { |
| + return edgesFileView{V: 1, Box: box, EIP: eip, BurstNotices: true, Hosts: map[string]edgesHostView{host: {Role: "home"}}} |
| + } |
| + annie, betty, carol := file("annie", "192.0.2.11", "shop.example.com"), file("betty", "192.0.2.12", "blog.example.com"), file("carol", "192.0.2.13", "docs.example.com") |
| + m := &homeMap{snap: &homeSnapshot{read: true, files: map[string]edgesFileView{ |
| + "control/edges/annie.json": annie, "control/edges/carol.json": carol, |
| + }}} |
| + e := &Edge{box: "annie"} |
| + e.homes.Store(m) |
| + n := newBurstNotices() |
| + peer := func(box string) *burstPeer { |
| + return &burstPeer{box: box, q: make(chan burstNotice, 1), stop: make(chan struct{})} |
| + } |
| + carolPeer := peer("carol") |
| + n.peers["carol"] = carolPeer |
| + |
| + n.mu.Lock() |
| + done := make(chan bool, 1) |
| + go func() { done <- e.burstPeerCurrent(n, carolPeer) }() |
| + // Long enough for the worker to reach the lock (and, read in the old |
| + // order, the snapshot without betty). |
| + time.Sleep(200 * time.Millisecond) |
| + m.mu.Lock() |
| + m.snap = &homeSnapshot{read: true, files: map[string]edgesFileView{ |
| + "control/edges/annie.json": annie, "control/edges/betty.json": betty, "control/edges/carol.json": carol, |
| + }} |
| + m.mu.Unlock() |
| + targets := n.targetsLocked(m.snapshot(), e.box, false) |
| + if len(targets) != 2 { |
| + t.Fatalf("targets %+v, want betty and carol", targets) |
| + } |
| + bettyPeer := peer("betty") |
| + n.peers["betty"] = bettyPeer |
| + n.mu.Unlock() |
| + |
| + if !<-done { |
| + t.Fatal("carol, still a peer, was reported gone") |
| + } |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + if n.peers["betty"] != bettyPeer { |
| + t.Fatal("betty's new peer was pruned with the older snapshot") |
| + } |
| + select { |
| + case <-bettyPeer.stop: |
| + t.Fatal("betty's worker was stopped") |
| + default: |
| + } |
| +} |
| + |
| // R3-2: the budget is taken at dispatch, over any 60 s and not per |
| // calendar minute, and a notice that cannot be sent within 10 s of its |
| // trip is dropped and counted. |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index f6fc9eadb..4f47d2618 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -343,7 +343,7 @@ type Edge struct { |
| // guard is CARLOS_EDGE_PROTECT, read once in New: what the edge does |
| // with a request matching a hard or probe rule (guard.go). By default |
| // each rule's own mode: from catalogue version 2 the hard tier blocks |
| - // and the probe tier watches. |
| + // and the probe tier watches; the probe-burst rule blocks (#491). |
| guard guardMode |
| // guardMint is mintRef, bound once in New: a method value taken per |
| // request would allocate for every guarded request, and most never |
diff --git a/internal/edge/guard.go b/internal/edge/guard.go| index 268ec02d7..8d6ce9961 100644 |
| --- a/internal/edge/guard.go |
| +++ b/internal/edge/guard.go |
| @@ -23,8 +23,9 @@ type guardMode uint8 |
| const ( |
| // guardCatalogue, the default, does what each rule's own mode says. From |
| // catalogue version 2 the hard tier blocks; the probe tier watches and |
| - // the burst rule counts, so their matches are recorded with the app's |
| - // answer. |
| + // its burst-mode rules count, so their matches are recorded with the |
| + // app's answer. The probe-burst rule (edgeguard.BurstRule) blocks since |
| + // its calibration review (#491): a cooling client is refused. |
| guardCatalogue guardMode = iota |
| // guardOff runs no check at all. |
| guardOff |
| @@ -293,11 +294,31 @@ func burstNotFound(status int, v *guardVerdict) bool { |
| return v.rule.Tier == reqrec.TierHard || v.rule.Tier == reqrec.TierProbe |
| } |
| +// burstIconPath reports whether path names a site icon that link-preview |
| +// fetchers, monitors and home-screen shortcuts ask for on their own: |
| +// favicon.ico or favicon.png/.svg, favicon-*.png, and apple-touch-icon*.png, |
| +// in any directory, any case. A miss on one never counts toward a trip |
| +// (Paul, #491 calibration, 2026-11-14): on 2026-11-13 a fetcher tripped four |
| +// times on one app collecting nothing but missing icons. A scanner gains |
| +// nothing from it, since an icon is never a catalogue path. |
| +func burstIconPath(path string) bool { |
| + name := strings.ToLower(path[strings.LastIndexByte(path, '/')+1:]) |
| + switch name { |
| + case "favicon.ico", "favicon.png", "favicon.svg": |
| + return true |
| + } |
| + if strings.HasPrefix(name, "favicon-") && strings.HasSuffix(name, ".png") { |
| + return true |
| + } |
| + return strings.HasPrefix(name, "apple-touch-icon") && strings.HasSuffix(name, ".png") |
| +} |
| + |
| // noteBurst counts one answered request toward the probe-burst limit, from |
| // the observer defer of the box that saw the visitor's own headers: a |
| // request the guard ran for, that no browser sent (every current browser |
| // sends Sec-Fetch-Mode on every request, scanners do not), and that is a |
| -// not-found by burstNotFound. A far edge's asset fill this box acknowledged |
| +// not-found by burstNotFound, and not a missing site icon (burstIconPath). |
| +// A far edge's asset fill this box acknowledged |
| // is the far edge's to count. On a trip it mints the trip's code once, |
| // files the trip record and tells the other edges. |
| func (e *Edge) noteBurst(rt registry.Route, r *http.Request, status int, out *outcome) { |
| @@ -310,6 +331,9 @@ func (e *Edge) noteBurst(rt registry.Route, r *http.Request, status int, out *ou |
| if !burstNotFound(status, out.guard.verdict) { |
| return |
| } |
| + if out.guard.verdict == nil && burstIconPath(r.URL.Path) { |
| + return |
| + } |
| if _, browser := r.Header["Sec-Fetch-Mode"]; browser { |
| return |
| } |
diff --git a/internal/edgeguard/catalogue.go b/internal/edgeguard/catalogue.go| index 111686ca5..5ade98fec 100644 |
| --- a/internal/edgeguard/catalogue.go |
| +++ b/internal/edgeguard/catalogue.go |
| @@ -116,8 +116,11 @@ var ( |
| // it, because the cool-down is about the client, and the edge decides it |
| // beside Check rather than through it. It is here so a record or a |
| // reference code that names it is explained like any other rule (RuleByID, |
| -// RuleByHash). Its mode is watch until blocking is approved. |
| -var BurstRule = &Rule{ID: reqrec.BurstRuleID, Group: "probe-burst", Tier: reqrec.TierBurst, Mode: ModeWatch} |
| +// RuleByHash). It blocks: a client in a cool-down is refused the catalogue |
| +// paths the app is not known to serve, wherever the cool-down started. It |
| +// watched from release until the calibration review (#491); an app's |
| +// record-only switch still turns it off for that app. |
| +var BurstRule = &Rule{ID: reqrec.BurstRuleID, Group: "probe-burst", Tier: reqrec.TierBurst, Mode: ModeBlock} |
| var burstRuleHash = reqrec.RuleHash(BurstRule.ID) |
diff --git a/internal/edgeguard/catalogue_test.go b/internal/edgeguard/catalogue_test.go| index 792703b1d..305f9aee6 100644 |
| --- a/internal/edgeguard/catalogue_test.go |
| +++ b/internal/edgeguard/catalogue_test.go |
| @@ -155,7 +155,7 @@ func TestParseAccepts(t *testing.T) { |
| // ever matches it, because a cool-down is about the client, not the request. |
| func TestBurstRuleLookups(t *testing.T) { |
| r := BurstRule |
| - if r.ID != "burst.probe-burst.cooldown" || r.Group != "probe-burst" || r.Tier != reqrec.TierBurst || r.Mode != ModeWatch { |
| + if r.ID != "burst.probe-burst.cooldown" || r.Group != "probe-burst" || r.Tier != reqrec.TierBurst || r.Mode != ModeBlock { |
| t.Fatalf("BurstRule = %+v", *r) |
| } |
| if got, ok := RuleByID(r.ID); !ok || got != r { |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index da37016e4..e29503ca9 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -212,3 +212,4 @@ plan14-root-reads-offline-move-stage-refusals-339.tsv 846d1f22e6eb6b2cd8b3086fa5 |
| plan14-root-reads-fleet-tunnel-tls-state.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332 |
| plan14-root-reads-replica-console-account.tsv 87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16 |
| plan14-root-reads-offline-move-pool-target-413.tsv f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182 |
| +plan14-root-reads-probe-burst-block.tsv 94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167 |
diff --git a/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv b/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv| new file mode 100644 |
| index 000000000..415f6fb6c |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay probe-burst-block, written by census-propose (#369). census-ruling-probe-burst-block, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-probe-burst-block.md. |
| +# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy ed0009717059de6de9cd99d188bcac56ec8a873d8910bb8821fe7cb3fea29815 internal/edge/guard.go Edge.noteBurst legacy accepted-legacy accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read;rev3=census-ruling-probe-burst-block;basis=after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts whole:Route@574,whole:Route@742,whole:Route@800 922524dfba524388e85449817d024288a23f775c6bd5ccdb4b1a3fd47a5bcd9b |
| +internal/edge/guard.go Edge.noteBurst legacy accepted-legacy accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read;rev3=census-ruling-probe-burst-block;basis=after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts whole:Route@574,whole:Route@742,whole:Route@800 922524dfba524388e85449817d024288a23f775c6bd5ccdb4b1a3fd47a5bcd9b |
| +@coverage internal/edge 46e4db369a9df88989104adffc0a3a13833d4c3397c41e276d37b6d358d308ce |
| +@coverage internal/edgeguard a26fa6f359b091151c8df59275bccd02cd2621686f40c4164f48f7155ac16895 |