carlos / platform Public

census: edge protection Plan 2 overlay and decision rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 03cbe09e3febe5ceb7f3aba2430bd558dd1437d2 parent 07726e0
4 files changed, +46 −0
  • docs/superpowers/notes/census-proposal-edge-protection-2.md +23 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +2 −0
  • internal/provision/testdata/plan14-root-reads-edge-protection-2-decisions.tsv +8 −0
  • internal/provision/testdata/plan14-root-reads-edge-protection-2.tsv +13 −0
diff --git a/docs/superpowers/notes/census-proposal-edge-protection-2.md b/docs/superpowers/notes/census-proposal-edge-protection-2.md
new file mode 100644
index 000000000..94458338e
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-edge-protection-2.md
@@ -0,0 +1,23 @@
+# Census approval: edge-protection-2
+
+Ruling `census-ruling-edge-protection-2`. Every change below keeps the disposition it already has, so it needs an approval, not a decision.
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/edge/reqrecords.go` `Edge.observeRecords` | body | unchanged (1) | files one reqrec.Match in place of the Response when the request's outcome carries a guard verdict (kind block or watch, the verdict's rule tier, id, fragment and reference code; a block woke nothing), and the plain Response otherwise; still in-memory, its one scanned site is the route value passed in; no read added |
+| `internal/edge/static.go` `staticSite.serveTree` | body | unchanged (2) | consults the edge protection matcher (internal/edgeguard, pure and in-memory) on the request path (probe tier, only when no file and no _redirects rule names it) and on a rewrite target (hard tier, only when the file is there), and may answer the guard's 404 block page through guardDecide before a redirect or the rewritten file; the _redirects lookup gains an in-memory names check; the same index-aware Stat lookups inside the extracted tree, unchanged; no read added |
+| `internal/edge/edge.go` `Edge.ServeHTTP` | sites | +registry:Kind, +whole:Route | runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read |
+
+Envelopes re-pinned: `.`, `internal/console`, `internal/edge`, `internal/edgeguard`, `internal/hostenv`.
+
+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. Escalate 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. An escalation goes to the census owner as a decision.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/edge/reqrecords.go` `Edge.observeRecords`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: called from ServeHTTP's observer defer after observeAnalytics, with the route the defer already holds; returns at once when no recorder is wired or the request arrived over a tunnel (the forwarding box records it); otherwise builds the Response through requestResponse from that route and the request and hands it to the in-memory recorder, which files it into the box's log sink; its one scanned site is the route value passed in; it reads no file, no store and no box state, writes nothing outside the log sink, and makes no serving or root decision; the class of Edge.observeAnalytics (J1 root-route)
+- `internal/edge/static.go` `staticSite.serveTree`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-static-redirects;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the same index-aware Stat lookup inside the extracted tree, now run at most twice (the request path, then once for a _redirects rewrite destination cleaned rooted inside the same tree); the Open moves to serveFile; the _redirects file itself is never answered; no root decision
+- `internal/edge/edge.go` `Edge.ServeHTTP`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added
+
+Seal: `9c8acc96a63057fb8c87d389eca0ba4aefcf043adc67525c85b448f70bd5fc0a` → `9a82b5316160dc6ca33d7b03224b7a7752ebb5b86cb07ed366c0cd6158dc478a`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-edge-protection-2.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 57f37ea6e..6e050e1b5 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -25,3 +25,5 @@ plan14-root-reads-design-edge-rate-limit-358-decisions.tsv a067dcd9e32e6be2b7dd9
plan14-root-reads-design-edge-rate-limit-358.tsv 0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0
plan14-root-reads-plans-4b-after-grace.tsv 0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0
plan14-root-reads-certwarm-wake.tsv 91204fcbc484343c03bd5ae69e3084055bc519a5b317e2ae3dc49880080764e2
+plan14-root-reads-edge-protection-2-decisions.tsv 9c8acc96a63057fb8c87d389eca0ba4aefcf043adc67525c85b448f70bd5fc0a
+plan14-root-reads-edge-protection-2.tsv 9a82b5316160dc6ca33d7b03224b7a7752ebb5b86cb07ed366c0cd6158dc478a
diff --git a/internal/provision/testdata/plan14-root-reads-edge-protection-2-decisions.tsv b/internal/provision/testdata/plan14-root-reads-edge-protection-2-decisions.tsv
new file mode 100644
index 000000000..7acd79ec0
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-edge-protection-2-decisions.tsv
@@ -0,0 +1,8 @@
+# Census overlay edge-protection-2-decisions, written BY HAND (AGENTS.md, The census: census-propose refuses decisions). The decisions of census-ruling-edge-protection-2 (branch edge-protection-2, Plan 2 of docs/superpowers/specs/2026-10-24-edge-request-protection-design.md: the hard and probe tiers, watch by default; plan docs/superpowers/plans/2026-10-25-edge-protection-2-hard-probe-watch.md): one new unit and one removed. Loaded from the chain manifest before plan14-root-reads-edge-protection-2.tsv, which census-propose wrote for the approvals. Asked of the census owner on #280 with the card docs/superpowers/notes/census-proposal-edge-protection-2.md; rows carry the ruling from the start (#369).
+# No root read is added. The catalogue is data compiled into the binary and parsed at init; the edge inside the agent (carlos-edge.service, user carlos) is its only reader, and nothing opens it from disk. One frozen declaration is added, so the seal moves.
+# NEW, embedded data (file:external): the protection catalogue. Mirrors the console's embedded templates (internal/console/templates/*.html external, accepted legacy).
+@legacy 99d5044258b4fb0ae713b36b32413708ba8ac90858ddb373f84aef381a46c3e0 internal/edgeguard/catalogue.txt external legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-protection-2;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), the one caller of internal/edgeguard;basis=new: the edge protection catalogue, the hard and probe tier rules: embedded with go:embed into the binary (edgeguard.catalogueData) and parsed once at init (parseCatalogue, then buildIndex; init panics on a malformed row or a version line that disagrees with edgeguard.Version); never opened from disk at runtime; data, not code; it only says which request paths and query values the edge matches; no root decision; the class of the console's embedded templates (internal/console/templates/*.html external) file:external@0 f017cbb0b580fb799dec98930051c816c3ad45ed18a05eb424337fd1bdf3a269
+internal/edgeguard/catalogue.txt external legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-protection-2;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), the one caller of internal/edgeguard;basis=new: the edge protection catalogue, the hard and probe tier rules: embedded with go:embed into the binary (edgeguard.catalogueData) and parsed once at init (parseCatalogue, then buildIndex; init panics on a malformed row or a version line that disagrees with edgeguard.Version); never opened from disk at runtime; data, not code; it only says which request paths and query values the edge matches; no root decision; the class of the console's embedded templates (internal/console/templates/*.html external) file:external@0 f017cbb0b580fb799dec98930051c816c3ad45ed18a05eb424337fd1bdf3a269
+# Removed: Edge.recordMatch (frozen by edge-request-records-decisions) is no longer declared. Retired by an H3 census-ruling removal (zddr3's form; the loader takes H3 only with a census-ruling- basis). A removal is not in the seal.
+@remove internal/edge/reqrecords.go Edge.recordMatch
+@removed internal/edge/reqrecords.go Edge.recordMatch H3 census-ruling-edge-protection-2: no longer declared: its body is split in two. The reference-code mint (reqrec.NewRef from the time, the rule tier and id, this box's name and the mesh key the edge already holds in memory) moved unchanged into Edge.mintRef, in which the scan finds no read site, and the Match it filed is now built by Edge.observeRecords (re-frozen in the census-propose overlay edge-protection-2) from the guard verdict the observer defer finds on the request's outcome; its one scanned site, the route passed in, went with the Match. It ran in the edge inside the agent as carlos.
diff --git a/internal/provision/testdata/plan14-root-reads-edge-protection-2.tsv b/internal/provision/testdata/plan14-root-reads-edge-protection-2.tsv
new file mode 100644
index 000000000..5611d1e74
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-edge-protection-2.tsv
@@ -0,0 +1,13 @@
+# Census overlay edge-protection-2, written by census-propose (#369). census-ruling-edge-protection-2, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-edge-protection-2.md.
+# 2 body, 1 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy c2d6ffbd62656c6d14d42498f6ab6259a7f8eaad9b450b19f550ca95bafa3012 internal/edge/reqrecords.go Edge.observeRecords legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: called from ServeHTTP's observer defer after observeAnalytics, with the route the defer already holds; returns at once when no recorder is wired or the request arrived over a tunnel (the forwarding box records it); otherwise builds the Response through requestResponse from that route and the request and hands it to the in-memory recorder, which files it into the box's log sink; its one scanned site is the route value passed in; it reads no file, no store and no box state, writes nothing outside the log sink, and makes no serving or root decision; the class of Edge.observeAnalytics (J1 root-route);rev3=census-ruling-edge-protection-2;basis=files one reqrec.Match in place of the Response when the request's outcome carries a guard verdict (kind block or watch, the verdict's rule tier, id, fragment and reference code; a block woke nothing), and the plain Response otherwise; still in-memory, its one scanned site is the route value passed in; no read added whole:Route@491 c6e8607b6453e04bad358009746bcc1a97e00ef16463594e5b216e4025a84b37
+@legacy f701732ef85b1b75af7ae3fba38ce61ac6aabd606d6752aeaec5c917254ab46d internal/edge/static.go staticSite.serveTree legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-static-redirects;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the same index-aware Stat lookup inside the extracted tree, now run at most twice (the request path, then once for a _redirects rewrite destination cleaned rooted inside the same tree); the Open moves to serveFile; the _redirects file itself is never answered; no root decision;rev3=census-ruling-edge-protection-2;basis=consults the edge protection matcher (internal/edgeguard, pure and in-memory) on the request path (probe tier, only when no file and no _redirects rule names it) and on a rewrite target (hard tier, only when the file is there), and may answer the guard's 404 block page through guardDecide before a redirect or the rewritten file; the _redirects lookup gains an in-memory names check; the same index-aware Stat lookups inside the extracted tree, unchanged; no read added file:Stat@1064,file:Stat@967 a0d335dd9c673d8e5fded6c8b07e54a29c8939c337b11b891ec804a286b9ca1d
+@legacy d14dc0e7449dee627d2491d859948ccbd014c3a59899dbaae08db7a86d6982c9 internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read registry:Gate@15374,registry:Gate@15434,registry:Gate@15492,registry:Host@15477,registry:ImportGate@19242,registry:Kind@11805,registry:Kind@14112,registry:Kind@19213,whole:Route@10017,whole:Route@11808,whole:Route@12948,whole:Route@13043,whole:Route@13119,whole:Route@13163,whole:Route@14115,whole:Route@15377,whole:Route@15437,whole:Route@15480,whole:Route@15495,whole:Route@17001,whole:Route@19216,whole:Route@19245,whole:Route@21077,whole:Route@9805 50d206c2f067bcf750f7cbec1f63a8f7704fe7711c9bbbc58ee6d0f8bb84a6b7
+internal/edge/reqrecords.go Edge.observeRecords legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: called from ServeHTTP's observer defer after observeAnalytics, with the route the defer already holds; returns at once when no recorder is wired or the request arrived over a tunnel (the forwarding box records it); otherwise builds the Response through requestResponse from that route and the request and hands it to the in-memory recorder, which files it into the box's log sink; its one scanned site is the route value passed in; it reads no file, no store and no box state, writes nothing outside the log sink, and makes no serving or root decision; the class of Edge.observeAnalytics (J1 root-route);rev3=census-ruling-edge-protection-2;basis=files one reqrec.Match in place of the Response when the request's outcome carries a guard verdict (kind block or watch, the verdict's rule tier, id, fragment and reference code; a block woke nothing), and the plain Response otherwise; still in-memory, its one scanned site is the route value passed in; no read added whole:Route@491 c6e8607b6453e04bad358009746bcc1a97e00ef16463594e5b216e4025a84b37
+internal/edge/static.go staticSite.serveTree legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-static-redirects;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the same index-aware Stat lookup inside the extracted tree, now run at most twice (the request path, then once for a _redirects rewrite destination cleaned rooted inside the same tree); the Open moves to serveFile; the _redirects file itself is never answered; no root decision;rev3=census-ruling-edge-protection-2;basis=consults the edge protection matcher (internal/edgeguard, pure and in-memory) on the request path (probe tier, only when no file and no _redirects rule names it) and on a rewrite target (hard tier, only when the file is there), and may answer the guard's 404 block page through guardDecide before a redirect or the rewritten file; the _redirects lookup gains an in-memory names check; the same index-aware Stat lookups inside the extracted tree, unchanged; no read added file:Stat@1064,file:Stat@967 a0d335dd9c673d8e5fded6c8b07e54a29c8939c337b11b891ec804a286b9ca1d
+internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read registry:Gate@15374,registry:Gate@15434,registry:Gate@15492,registry:Host@15477,registry:ImportGate@19242,registry:Kind@11805,registry:Kind@14112,registry:Kind@19213,whole:Route@10017,whole:Route@11808,whole:Route@12948,whole:Route@13043,whole:Route@13119,whole:Route@13163,whole:Route@14115,whole:Route@15377,whole:Route@15437,whole:Route@15480,whole:Route@15495,whole:Route@17001,whole:Route@19216,whole:Route@19245,whole:Route@21077,whole:Route@9805 50d206c2f067bcf750f7cbec1f63a8f7704fe7711c9bbbc58ee6d0f8bb84a6b7
+@coverage . e7ea4094ad4a3d2b769c58956415caf5650aea2bf527fdd9ac8ea885947e0f9e
+@coverage internal/console 5a647e14fc12718c312cb52d0d8aa73d60f44b6e1049f9b43d7bb3bb0770d97a
+@coverage internal/edge 80ee39ce780ed78d52552f1aa9caa828b482629006fcfc74da0a7dce5c4c7979
+@coverage internal/edgeguard eb7fbf69f820445425ef4dd34b16a4af56e695867f799a7ae8cf2a70af975794
+@coverage internal/hostenv 1dd388c5b39277d2a9c39493e8da06bf0880de16d07f89b7b11123f6e2861dd3