carlos / platform Public

spec: PPv2 rev 3, Astra round 2 P2s; F1 decision to Paul

Round 2 repeated fault family F1 (S3 forgery on the reverse path), so
stopping rule 2 holds the third round: section 14 offers one-way PPv2
(recommended), evidence-gated rollback, or stopping. Port 80 probe table
and transition gates fixed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9869fab7ea37d39716302ee96f01768a5902bef4 parent 9d1be70
2 files changed, +88 −10
  • docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md +36 −10
  • docs/superpowers/specs/ASTRA-FINDINGS-edge-ppv2-R2.md +52 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md b/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
index 09027c9ef..5d7365faf 100644
--- a/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
+++ b/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
@@ -1,6 +1,6 @@
# PROXY protocol v2 on the region HA load balancers
-Design, 2026-11-12, **rev 2** (Astra round 1 applied, §12). Agent manager 8a3d302 asked for it on 2026-11-12 with Paul's approval: client IP preservation off and PROXY protocol v2 on, on both target groups of each region NLB, before G6 opens the NLBs to customers. Design only; the build is a separate GO. Review budget: at most three Astra rounds (AGENTS.md stopping rules); round 1 found one P1 (fault family F1, §12), so round 2 follows.
+Design, 2026-11-12, **rev 3** (Astra rounds 1 and 2 applied, §12 and §13; **stopped under stopping rule 2**: round 2 repeated fault family F1, so the decision in §14 goes to Paul before any third round). Agent manager 8a3d302 asked for it on 2026-11-12 with Paul's approval: client IP preservation off and PROXY protocol v2 on, on both target groups of each region NLB, before G6 opens the NLBs to customers. Design only; the build is a separate GO. Review budget: at most three Astra rounds (AGENTS.md stopping rules); rounds 1 and 2 each found one P1 in fault family F1, so two rounds are spent and the third waits on §14.
Line citations are to `origin/main` at ae1b8cca. AWS facts quote "Edit target group attributes for your Network Load Balancer" (docs.aws.amazon.com/elasticloadbalancing/latest/network/edit-target-group-attributes.html, read 2026-11-12) unless another page is named.
@@ -92,7 +92,7 @@ The header's destination address and port are not used.
### 4.5 Counters
-Per listener and, for trusted connections, per node address, since start: `proxied`, `no_client`, `no_client_refused` (§4.6), `ignored` (untrusted header consumed), `ignored_private` (untrusted header from a private address: almost certainly an NLB node missing from the key), `malformed`, `timeout`. One journal line at start (`edge: proxy protocol: armed on :80 and :443, trusting 172.31.29.110,172.31.11.189`), and one throttled line every minute while armed, naming every counter. `no_client_refused` and `ignored_private` above zero also log once a minute at warning level with the peer address. The cutover reads these lines over SSM (§6.4); no new metric or alarm in the edge.
+Per listener and, for trusted connections, per node address, since start: `proxied`, `no_client`, `no_client_refused` (§4.6), `ignored` (untrusted header consumed), `ignored_private` (untrusted header from a private address: almost certainly an NLB node missing from the key), `marker_trusted` (§6.4), `malformed`, `timeout`. One journal line at start (`edge: proxy protocol: armed on :80 and :443, trusting 172.31.29.110,172.31.11.189`), and one throttled line every minute while armed, naming every counter. `no_client_refused` and `ignored_private` above zero also log once a minute at warning level with the peer address. The cutover reads these lines over SSM (§6.4); no new metric or alarm in the edge.
### 4.6 A trusted connection without a client address answers the health check only
@@ -175,20 +175,24 @@ The probe runs in region (§10), with one process per NLB address and port, each
- **plain:** a normal request to the echo app, which returns the `X-Forwarded-For` it received;
- **marker:** a PPv2 header claiming source 192.0.2.1 (TEST-NET-1), then the same request.
-What each state answers, per NLB address and port:
+What each state answers, per NLB address. On `:443` the request goes to the echo app. On `:80` it is a `GET` for the echo app's host with redirects not followed, so the expected answer is today's `302` to HTTPS (`internal/edge/edge.go:3840`), not 200:
-| State on that node | plain | marker |
-|---|---|---|
-| S0 | 200, probe's address | 200, probe's address (client header ignored, §4.4) |
-| S1 | 200, probe's address | fails: the NLB's header is first, the marker is payload (400 or TLS error) |
-| S2 | 200, probe's address | fails, the same way |
-| S3 | `503`, refused (§4.6) | **200 with 192.0.2.1: forgery** |
+| State on that node | plain `:443` | marker `:443` | plain `:80` | marker `:80` |
+|---|---|---|---|---|
+| S0 | 200, probe's address | 200, probe's address (client header ignored, §4.4) | 302 | 302 |
+| S1 | 200, probe's address | fails: the NLB's header is first, the marker is payload (TLS error) | 302 | fails: 400 |
+| S2 | 200, probe's address | fails, the same way | 302 | fails: 400 |
+| S3 | 503, refused (§4.6) | **200 with 192.0.2.1: forgery** | 503 | **302: forgery, invisible from outside** |
+
+Because `:80` cannot show the forged address, the edge itself counts it: a trusted `proxied` header whose source is in 192.0.2.0/24 (TEST-NET-1, never a real client) closes the connection and increments `marker_trusted`, logged at warning level. That counter above zero means S3 on that target's port, whatever the probe saw.
Convergence of a step, per TG port, needs all of:
- after A: the marker fails on **both** NLB addresses for 30 consecutive attempts (60 s); plain stays 200 with the probe's address;
- after B: the same, plus every target's counters show `proxied` rising from **both** node addresses and `no_client_refused` at 0;
- after a reverse A (S1 to S0): the marker answers 200 with the probe's address on both addresses for 30 consecutive attempts;
-- all the time: every target healthy in both TGs (`describe-target-health` every 10 s), and `malformed`, `timeout`, `ignored_private` at 0.
+- all the time: `malformed`, `timeout`, `ignored_private` and `marker_trusted` at 0.
+
+**Transition gates and maintenance rows are separate.** From the start of an attribute step until its convergence record is written, every target is healthy in both TGs (`describe-target-health` every 10 s) and no drain, restart or group roll runs. Maintenance rows (§10 rows 5 and 6) run only between steps: during one, the named target may be `unhealthy.draining` or deregistered, every other target stays healthy, and the plain probe stays at 0 errors. The all-healthy gate is back before the next attribute step starts.
The script writes the record (times, counts, per-address results) that the next step requires.
@@ -302,3 +306,25 @@ Flagship rows: 1, 2, 3 (one held connection of each kind), 4 (echo and burst), 5
| P2: the witness does not prove the cutover claims | rollout claims beyond evidence | Accepted: §3 states the assumption; §6.4 convergence per address and port gates each step; §10 row 3 holds connections across steps. |
| P2: `aws_network_interfaces` has no private addresses | infra discovery | Accepted: singular lookups per zone (§8.1). |
| P2: the member bootstrap binary refuses the new key | bootstrap compatibility | Accepted: §6.1 step 2 and the unwinding order. |
+
+## 13. Astra round 2 and where it went
+
+`docs/superpowers/specs/ASTRA-FINDINGS-edge-ppv2-R2.md`, NOT READY. Round 1 dispositions: R1.2, R1.3, R1.4, R1.6, R1.7 resolved; R1.1 (F1) and R1.5 partly.
+
+| Finding | Fault family | Disposition |
+|---|---|---|
+| P1: S3 still reachable on rollback and not bounded. S1 and S2 answer the probe identically, so S2 to S1 cannot be proven converged before PPv2 goes off; S3 drift after the window has no detector (forged requests count as `proxied`); the incident's serial drained restarts keep forged connections serving and can fail | **F1, second round running** | **Not fixed: stopping rule 2. Options in §14.** |
+| P2: the probe table is wrong for `:80` (302 redirect, not echo) | rollout evidence | Fixed in rev 3: per-port table with redirects not followed; the edge's own `marker_trusted` counter covers `:80` (§6.4). |
+| P2: "every target healthy all the time" contradicts the drain and roll rows | rollout evidence | Fixed in rev 3: transition gates and maintenance rows separated (§6.4). |
+
+## 14. Decision for Paul: fault family F1
+
+F1 is "client bytes becoming trusted identity". It lives in one AWS state the edge cannot see, S3, and in the transitions next to it. Round 1 found S3 unguarded; rev 2 guarded the forward path and added a probe; round 2 found the reverse path (S2 to S1 to S0) unprovable with that probe, no detector outside the window, and an incident that cannot close forged connections promptly. Stopping rule 2 says not to write a third fix in the same family. The choices:
+
+**A. Cut: PROXY protocol is one-way (recommended).** Once a TG reaches S1, PPv2 never goes off again. Rollback ends at S1 (preservation back on, PPv2 on, the edge ignoring the header as in S1 today): that restores today's client addresses and today's collision behaviour, which is the whole of what a rollback needs. S1 to S0 and S2 to S0 are refused by the step script and removed from every card; the module refuses PPv2 off on a TG whose live attribute is on. Every unprovable transition is gone, since the only remaining moves are S0 to S1 (forward, proven by the marker), S1 to S2 (forward, proven by the marker plus per-node `proxied`) and S2 to S1 (reverse, safe whether converged or not: S1 and S2 both trust only the NLB's own header). S3 then needs someone to turn PPv2 off outside the tooling. Two small additions, still F1 but enforcing in one place rather than patching: the edge publishes `no_client_refused` and `marker_trusted` through the existing host metrics path (`CARLOS_HOST_METRICS`, `internal/host/memwatch.go:77`) with one alarm on either above zero (S3 turns every header-less client into a 503, so it is loud), and an edge control action that closes every trusted connection at once, without a drain, for the incident. Cost: an edge older than vN can never again run on an NLB target; that is already true from step A80 on.
+
+**B. Refuse up front with evidence.** Keep S1 to S0, gated on target-side evidence that preservation is back on every node: with the probe dialling both addresses every 2 s, `proxied` from each node address stays at 0 on every target for 5 minutes (in S2 every data connection from a node is `proxied`, so silence from both nodes means both preserve). Plus the alarm and the close-all action from A. This is a third fix in F1, which the stopping rule asks Paul to approve explicitly, and it keeps a transition whose safety rests on reading counters correctly under time pressure.
+
+**C. Stop the work.** Keep preservation on. Clients behind port-preserving NAT keep the rare 20-30 s connect hang on HA-pool names (§1). G6 opens with the known limit.
+
+Recommendation: **A**. It removes the unprovable transition rather than proving it, and costs nothing a rollback needs. If A is chosen, rev 4 writes it in and Astra round 3 reviews it, as the last round.
diff --git a/docs/superpowers/specs/ASTRA-FINDINGS-edge-ppv2-R2.md b/docs/superpowers/specs/ASTRA-FINDINGS-edge-ppv2-R2.md
new file mode 100644
index 000000000..d20b54fd9
--- /dev/null
+++ b/docs/superpowers/specs/ASTRA-FINDINGS-edge-ppv2-R2.md
@@ -0,0 +1,52 @@
+- **R1.1 P1 — S3 forgery: partly resolved.** The invariant is explicit, but rollback verification, detection coverage and incident containment remain incomplete.
+- **R1.2 P2 — Unknown identity across forwarding: resolved.** §4.6 refuses application requests before forwarding.
+- **R1.3 P2 — Empty analytics identity: resolved.** Those requests no longer reach analytics.
+- **R1.4 P2 — Deferred connection metadata: resolved.** The connection-owned state, nonblocking context hook and interruptible `Close` address the finding.
+- **R1.5 P2 — Cutover witness: partly resolved.** Persistent connections are covered, but the port-80 probe and drain-window conditions remain wrong.
+- **R1.6 P2 — ENI discovery: resolved.** Singular, zone-keyed interface lookups provide `private_ip`.
+- **R1.7 P2 — Bootstrap compatibility: resolved.** The bootstrap prerequisite and rollback ordering now cover the allowlist.
+
+1. **P1 — S3 is still neither excluded by the rollback procedure nor reliably bounded (§§3, 6.3–6.5).**
+
+ **Evidence:** The convergence predicates at [design:187](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:187) omit reverse B, although [design:199](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:199) requires it before reverse A. S1 and S2 have identical plain/marker answers. Rising `proxied` counters establish S2 activity; they do not establish that preservation has returned on every node.
+
+ **Failure scenario:** During rollback, one node still uses preservation-off when PPv2-off reaches it. That node enters S3 despite each requested move changing only one attribute. The prescribed probes cannot certify the preceding S2→S1 transition. A client-supplied address then becomes signed forwarding identity through [homemap.go:1685](/home/paulca/amadan.net/carlos/platform-ppv2/internal/edge/homemap.go:1685) and [forwardproof.go:51](/home/paulca/amadan.net/carlos/platform-ppv2/internal/edge/forwardproof.go:51).
+
+ Detection and recovery do not close this gap:
+
+ - The probe runs only during the window ([design:195](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:195)). Later S3 drift has no specified forgery detector. Forged requests increment `proxied`, not `no_client_refused`; [design:95](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:95) supplies journal output without an alarm. Thus S3 can occur without the promised detection.
+ - The incident procedure restores preservation, then performs serial graceful restarts ([design:202](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:202)). Existing forged connections remain usable. W6 explicitly keeps serving before closing ingress ([ingressdrain.go:370](/home/paulca/amadan.net/carlos/platform-ppv2/internal/host/ingressdrain.go:370)); member drains can stop with failure ([depart.go:321](/home/paulca/amadan.net/carlos/platform-ppv2/internal/grouproll/depart.go:321)). There is no incident-wide quarantine or closure deadline independent of successful maintenance.
+
+ AWS confirms that preservation changes affect only new TCP connections. [https://docs.aws.amazon.com/elasticloadbalancing/latest/network/edit-target-group-attributes.html](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/edit-target-group-attributes.html)
+
+ **Concrete fix:** Refuse PPv2-off rollback until fresh, correlated observations establish preserved socket peers on every node; the existing echo/marker pair cannot supply this evidence. Specify detection for the entire armed lifetime, and an incident action that blocks affected traffic and closes potentially forged connections before recovery, even when a normal roll fails.
+
+ **Fault family:** **F1 — client-controlled bytes becoming trusted identity**, carried forward from round 1.
+
+2. **P2 — The per-state probe table is wrong for port 80 (§§6.4, 10).**
+
+ **Evidence:** [Design:174](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:174) requires an echo-app response on both ports. Production port 80 instead redirects routable application requests to HTTPS at [edge.go:3840](/home/paulca/amadan.net/carlos/platform-ppv2/internal/edge/edge.go:3840).
+
+ **Failure scenario:** On port 80, ordinary requests in S0–S2 return a redirect, not `200` with an address. The S0 marker also redirects; an accepted S3 marker redirects without exposing its forged address. Following that redirect creates a separate TLS connection and loses the original marker identity. Literal enforcement therefore prevents the witness from passing; following redirects does not establish the claimed port-80 result.
+
+ **Concrete fix:** Define separate port-80 expectations with redirects disabled. Obtain port-80 identity and parse-state evidence through correlated target observations, or explicitly design a suitable diagnostic endpoint. Keep the echo-app table for port 443.
+
+ **Fault family:** **Rollout guarantees exceeding transition evidence**, carried forward from R1.5.
+
+3. **P2 — “Every target healthy all the time” contradicts the required drain witnesses (§§6.4, 10).**
+
+ **Evidence:** [Design:191](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:191) requires every target healthy throughout the window. [Design:276](/home/paulca/amadan.net/carlos/platform-ppv2/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md:276) requires drained restarts and a member replacement during that window. W6 deliberately fails health before withdrawing a target ([ingressdrain.go:385](/home/paulca/amadan.net/carlos/platform-ppv2/internal/host/ingressdrain.go:385)).
+
+ **Failure scenario:** A correctly functioning drain violates the probe’s pass condition and aborts the witness.
+
+ **Concrete fix:** Separate attribute-transition gates from maintenance-witness gates. During a named drain, permit only that target’s expected withdrawal while requiring healthy alternatives and successful traffic probes; restore the all-healthy gate before further attribute changes.
+
+ **Fault family:** **Rollout guarantees exceeding transition evidence**, carried forward from R1.5.
+
+No P3 findings.
+
+F1 has recurred in rounds 1 and 2, so stopping rule 2 applies. The choices are to refuse the unsafe rollback up front, cut mixed-state rollback, or enforce the invariant in one place with a guard test or simulation. I recommend the refusal until adequate transition evidence exists.
+
+Reviewed commit `9d1be70aafe46ce56d3b68adb3a70c55620a3b73` against the named `ae1b8cca` code and installed Go 1.26.10 sources. No files changed, subagents spawned, test suites run or AWS calls made.
+
+**NOT READY**
\ No newline at end of file