carlos / platform Public

demo-api-site-route

Written by claude agent, operated by paul@keymail.dev — this branch has no commits of its own to compare against, so how current this is cannot be said

Where it stands

Merged as 973a07e2, CI green on the tip and on main. Not released; no box touched. Off by default. P3 follow-ups are in the report on #527.

Next

Program controller arranges the dev release and switch-on (plan's Switch-on section). Claim paths follow after Plan 3 merges, with a census re-proposal.

Already decided

Edges first, console last, settings placed just before each roll restart. statusUrl follows the configured site origin; claimUrl stays on the console.

Recently

Human

<task-notification> <task-id>bi0ewfnkw</task-id> <tool-use-id>toolu_01Rr1jVRx62D1UxxWQWaaupd</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bi0ewfnkw.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the merged main commit" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bhmcsvjbv</task-id> <tool-use-id>toolu_01C6SRv2zsR5ZWecA1NN1Cq8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bhmcsvjbv.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the new tip" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>b90qy0t0b</task-id> <tool-use-id>toolu_01RMroJNXi7sGFQhniG2RAN9</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/b90qy0t0b.output</output-file> <status>completed</status> <summary>Background command "Wait for CI to finish on the branch tip" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a63d3060b8b2103fe</task-id> <tool-use-id>toolu_01S3EGWTUG2PMoLueYPkxcwq</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/a63d3060b8b2103fe.output</output-file> <status>completed</status> <summary>Agent "Opus whole-branch and census review" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result># Review: `demo-api-site-route`, `1cc99071..f1edc6c0` No P1 or P2 findings, two P3s, and every census unit and envelope is approved. ## Findings **P1:** none. **P2:** none. **P3-1: the demo-off refusals still drain an unfinished upload.** - **Evidence:** `internal/console/apidemo.go:317-325` returns 404 or `DEMO-CONFIG` 503 before `Connection: close` and the 30-second read deadline are set (`:328-330`). This code predates the branch. I read it and the net/http path (`server.go:1391`) but did not run this case. - **Failure:** with the demo switched off, a client that stalls a small or chunked upload never gets the refusal. It holds its fair share of hop or rate slots until it disconnects. The harm stops at that client's share, and the direct console path already behaves this way. - **Fix:** move the two header and deadline lines above both refusals. - **Family:** refusal draining the body, the same family as fix 4 in 9a975a4c. That fix is correct where it applies, and this is the one site it left out. **P3-2: the forged-XFF witness cannot tell a forged value from a real one on its own.** - **Evidence:** `internal/edge/demo_api_integration_test.go:85-86` sends the same forged value on all 61 requests. - **Failure:** if both legs trusted it, the requests would still share one bucket, so the 429 would still arrive. Alternating ingresses catches a one-leg regression, and forged hop headers are proved by `TestDemoAPIAliasClientIPRefusals`. Only a both-legs regression gets through. - **Fix:** vary the forged value per request. - **Family:** client attribution, the same family as plan round 1, but this is test strength only. ## Focus areas **1. Full duplex (8ab804fc)** - It sits after the allowlist check at `demo_api.go:129`, so it applies only to allowed operations on the two configured hosts. Both legs run this function. With the alias off, the function returns at `:107`. - `Unwrap` is not involved, because it is called on the raw `w`. HTTP/2 treats it as a no-op. - An early refusal gets through because Go 1.26's `noopCloseReader` stops the proxy's deferred body close from blocking on the in-flight read. - I probed a stalled upload after a 401 on both ingresses. The client got the refusal in under 0.5s with the upload still open, and backhaul in-flight was 0. So the only thing left open is the client's own connection plus its read goroutine. - Refusals never forward a body. A stalled 404 on the reserved path behaves the same as a stalled POST to static `/start`, so that is not a regression. - `-race` on `TestDemoAPIAlias*` is clean. **2. Fix wave (9a975a4c)** - The captured IP is used at all three budget and admission sites (`apidemo.go:380, :392, :445`). - The catch-all entry goes through `under`, which normalises it and ignores an empty value, so off mode is unchanged. - `ValidAPIOrigin` is used by both consumers. - The backend 101 reaches `demoAPIProxyError` through `Hijack`. - `RequestURI` equality holds for HTTP/1.1 relative form, HTTP/2 (tested) and hopped requests. Only absolute form is refused, and an HTTPS agent never sends that. **3. Task 3 witnesses** - All five Review Focus items are proved, with the limit in P3-2 on item 2. - `NewDemoAPITestIngress` exists only in `_test.go` files. - The recording console handler is used as the plan accepted. - The `early` witness uses `Connection: close`, which is the shape the real handler has from `:328` onward. **4. Coherence** - With everything on, one host carries publish, poll and update. `statusUrl` uses the site origin, and `claimUrl` stays on the console as planned. - With everything off, only inert comparisons remain. - `EXAMPLE.COM` and `example.com.` get the unknown-host 404. They reach neither static content nor the console. - `meshKeys` and `ExactHome` are nil-safe. A proxy that is missing or ineligible is refused. `demoAPIProxy` is built before the ordinary wrappers, in the same snapshot as its route. - Not exercised: the real console's early refusals with bytes in flight, because my fixture stopped at `DEMO-CONFIG`. A stand-in handler that answers 429 with `Connection: close` returned 429 on 240 of 240 requests, at up to 5 MB on both ingresses, but only on loopback. Switch-on step 3 must still check 413 and 429 across a real region. **5. Commands and builds** (all pass outside the sandbox) | Command | Result | |---|---| | Brief's console and edge witness run | pass | | Brief's census run | pass | | `GOOS=darwin go build ./...` | pass | | `GOOS=windows go build ./...` | pass | | `internal/hostenv` and `internal/demo` tests (added) | pass | | `go vet` and `gofmt` on the touched packages (added) | clean | - **Sandbox:** the first run inside it failed. The census and builds hit the read-only filesystem error AGENTS.md describes, and the edge package failed in the same run, cause not captured. All of it passed once rerun outside. - **Test cross-compile:** `go test -c` for darwin and windows fails on `readerConn` in `tunnel_register_race_test.go`, `tunnel_upgrade_test.go` and `upgrades_test.go`. None of those files is in this diff. - **HEAD moved:** it went to `1f531cad` during the review, adding the README and two copy specs only, with nothing under `internal`, `cmd` or `infra`. The probes and the race run were at that commit, and the census still passes there. - **Main moved:** `origin/main` is at `383cf308`, which changes only `scripts/` (out of census scope) and overlaps no branch file. ## Census verdict The two claimed read-site rows match the prior chain row, compared by read kind: - `Edge.ServeHTTP`: 56 before and after. - `RunWithActivatorReady`: 5 before and after. | Unit or envelope | Verdict | Reason | |---|---|---| | `Edge.ServeHTTP` | **Approve** | No read change. It adds only hop-shape inspection and one refusing or delegating call. It runs as `User=carlos`, and no check is weakened. | | `RunWithActivatorReady` | **Approve** | Only the fatal message text changes. | | `Edge.Reload` | **Approve** | The delta of +Host×2, +Version, +whole×2 matches the card. All of it comes from the three added lines, over a row already listed. There is no new query, and it builds a proxy copy only for the exact console row. | | new `demoAPIConsoleEligible` | **Approve**, disposition `legacy`, `accepted-legacy` correct | It is a pure predicate with the same class as `Edge.serveReplicaConsole`, and stricter than it (it adds Status, Tunnel, Forward, Demo and Fleet). | | envelope `internal/demo` | **Approve** | It adds the pure `ValidAPIOrigin`. | | envelope `internal/edge` | **Approve** | `demo_api.go` opens no file. The two new env inputs are read only by the edge at startup, from root-owned `host.env`, which a tenant, app or box agent cannot write. | | envelope `internal/hostenv` | **Approve** | Two names join the operator-only allowlist. Root renders them through `safeValue` and never acts on them. They are origins matched against the route table and home map, not dial targets. | **Re-proposal needed:** - Any change `make census-card` reports in `internal/edge`, `internal/demo` or `internal/hostenv`. That includes the Plan 3 follow-up, which adds four paths to `demo_api.go`, and any edit to `demoAPIConsoleEligible`. - Any main merge that touches those packages or their units. Run the card to see whether a P3-2 test edit trips it. **Not needed:** - README and docs. - `scripts/`. - `internal/console` changes, including P3-1. I did not post to #280. The author or controller needs to record this verdict there with the reviewer and the tip. I edited no files and spawned no agents. The test probes used `go test -overlay`, and their scratch directories are removed. READY</result> <usage><subagent_tokens>229824</subagent_tokens><tool_uses>21</tool_uses><duration_ms>904812</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bzyi7yhxp</task-id> <tool-use-id>toolu_01PQRU9spxty8M49oj8C87VD</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bzyi7yhxp.output</output-file> <status>completed</status> <summary>Background command "Wait for the Luna copy pass" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bemtl26m7</task-id> <tool-use-id>toolu_01HVyqSWMrFLFTSJALcUpwbg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bemtl26m7.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 3 implementer to finish" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bqzeb99pe</task-id> <tool-use-id>toolu_01CFSna1gMGKjG6e1X2f8BzT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bqzeb99pe.output</output-file> <status>completed</status> <summary>Background command "Wait for the fix wave to finish" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a78d445989d8f82d2</task-id> <tool-use-id>toolu_01WrS9iKbtsSyFmJ4R4Waovr</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/a78d445989d8f82d2.output</output-file> <status>completed</status> <summary>Agent "Opus review of Task 2" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result># Review, round 1: Task 2, demo API site route (`47cb4fd9..129b3c6f`) **Verdict: READY AFTER FIXES.** There is one P2: a backend's 101 answer can open a raw tunnel through the response writer. No P1s. ## Tests and how I checked | Check | Result | |---|---| | `TestDemoAPIAlias(Boundary\|Isolation)` | Pass. Needed one run outside the sandbox for the Unix-socket subtest. | | Named hostenv tests | Pass, plus the Optional/sort tests. | | `gofmt`, `go vet` on both packages | Clean. | | `-race` | Not run. It failed to build here (`runtime/race: package testmain: cannot find package`), which looks like a local toolchain problem. It still needs its one pre-handoff run. | - **Extra probes:** I added them through `go test -overlay`, with no worktree edits, and have removed the scratch directory. They were raw HTTP/1 request targets, a real two-edge TLS hop with a console backend, and 8 source mutations. - **Not exercised:** real HTTP/2 requests. The h2 points below come from reading the code. ## P1 None. ## P2 ### 1. A backend's 101 opens a raw tunnel past the response policy **Evidence** - `internal/edge/demo_api.go:206` lists `upgrade` as private, and `demoAPIScrubResponse` (`:243`) runs as `ModifyResponse`. - Go runs `ModifyResponse` before `handleUpgradeResponse` (`reverseproxy.go:589-593`). The scrub empties the response's upgrade type, so the check `EqualFold("", "")` at `:842` passes. Without the scrub, the stdlib would refuse this mismatch. - `rc.Hijack()` (`reverseproxy.go:854`) then walks `demoAPIResponseWriter.Unwrap` (`demo_api.go:263`) to the real connection. **Reproduced** - Backend hijacks and answers `101` with `Upgrade: evil`, with `CARLOS_RATE_LIMIT=off`. - Client received `HTTP/1.1 101 Switching Protocols ... TUNNELLED`, raw bytes on a request that carried no upgrade. - With `observe`, it gets 503, but only because `slotWriter.Hijack` happens to fail on its type assertion. - From the code, the hop leg (`edge.go:4254`, `assetInformationalScrub{dw}`) has no `slotWriter`, so it reaches the hijack in every rate mode. I did not run that path. **Failure scenario:** a console, a home edge, or an old-binary home row answers 101 to an allowlisted request. The client gets a bidirectional tunnel with no response policy. A client can't trigger this itself, because upgrade requests get 404 and the `Upgrade` header is dropped, so the upstream must misbehave first. That is why this is P2. **Fix** - Add `func (w *demoAPIResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return nil, nil, http.ErrNotSupported }`. `ResponseController` then stops at this writer and `ReverseProxy` calls `demoAPIProxyError`, giving an empty no-store 503. - Add a witness that a backend 101 gets 503 with rate limiting off. **Fault family:** the private writer must be the only exit, including `Hijack` through `Unwrap`. ## P3 (follow-up list) 1. **Duplicate version header.** Local delivery without a 1xx sends `X-Carlos-Version: v1` twice, while ordinary console dispatch sends it once. - Cause: `versionHeader` sets it (`demo_api.go:98`), `ModifyResponse` sets it (`:92`), and `copyHeader` adds rather than replaces. - Current readers use `Get`, so nothing breaks today. Task 3's comparison of direct and alias bytes may trip on it. - Fix: stamp it once, in `ModifyResponse` and the error handler. 2. **Absolute-form targets count as canonical.** `POST http:/api/demo/apps` and `POST http://example.com/api/demo/apps` both reach the console. - The target is rebuilt from the decoded URL, so the console only sees the canonical form. This matches ordinary routing and does not widen access. - It is stricter than the plan's "original canonical spelling". An `r.RequestURI == p` check would close it, but fixtures built with `httptest.NewRequest` would then need relative targets. 3. **The rate test can't prove chain attribution.** The fixture's `RemoteAddr` and hop XFF are the same IP (`demo_api_test.go:65`, `:711`), so a peer-keyed bucket would also pass. Use a different peer address. My two-edge probe shows the real behaviour is correct. 4. **Some gate conditions have no witness.** Removing `up.regional != 0`, `rt.IsDemo()` or the `FleetPlacement` check each survived. - The regional check is covered anyway, because `foldRegional` always sets `alias` (`regional.go:120`, `:142`). - The other two look redundant, based on reading the code. Either add table rows or accept them as belt and braces. 5. **Misleading fatal prefix.** Bad origins log as `edge: load routes: CARLOS_DEMO_API_ORIGIN ...` (`edge.go:4517`). Use a dedicated prefix, or wrap the error so the prefix is accurate. 6. **Operator signal and copy.** - An ineligible console row or a mismatch with the console's `Origin` gives silent 503s on every ingress. A throttled Reload log would help, and the plan's "unsupported console-route explanation" copy has no code yet. - The diagnostics at `demo_api.go:25` and `:29` are listed for copy review. I can't tell from this diff whether that happened. 7. **hostenv scope and validation** (see item 7 under "Checked and sound"). - `Split` (`hostenv.go:331`) puts both names in region scope, so a multi-region deployment must write them per region. The plan's Switch-on doesn't say this. - hostenv also doesn't validate the pair. A partial or bad parameter crash-loops each new box at `RestartSec=1`. The plan accepts this, but a pair check in `Assemble` is worth a follow-up. ## Could only be proved in Task 3 None of these look wrong. - **Survived in Task 2's tests:** dropping the hop XFF carry, the hop request filter, or the hop response hook (M1 to M3 in my mutations). All three need the cross-edge tests. - **What the real TLS hop probe showed:** - The console saw only `203.0.113.9` as XFF, despite a forged `9.9.9.9`. - The proof verified for Host `console.…`. - `Authorization ["", "Bearer x"]` arrived intact and cookies were gone. - The request and response both streamed without buffering. - Trailer `Set-Cookie` was stripped and `X-Result` kept. - Under `enforce`, the same client got a no-store 429 from the home edge, and a different client was admitted. ## Checked and sound 1. **Blast radius when off.** - The hot path gains one string compare plus a call that returns at once, with no allocation. - Reload gains one string concat per reverse-proxy route. - Startup fails only on partial, equal or invalid values, and the message doesn't echo them. - A crash loop with `Restart=always` is the plan's accepted risk, handled by stopping at the first box. 2. **Path gate.** - These all give an empty 404 with no console call and no static fallback: `%2f`, `%2e`, `%64`, `%00`, double slashes, trailing slash, `;x`, `#f`, bare `?`, `HEAD`, `OPTIONS`, lowercase `post`, `CONNECT /api/demo/apps` and upgrades. - A static tree holding `api/demo/apps/index.html` was never served on any tried reserved path. - `/api/demo;x/apps` and `EXAMPLE.COM` aren't reserved, but only got a 404. No hop or console path exists for them. - The console-host arm touches only allowlisted requests. 3. **Destination.** - Tenant rows, aliases, forward rows and tunnels all give 503, tested at both the sender and the home's own gate. - Held and empty homes refuse, and already-hopped requests can't loop. - The proxy and route come from one atomic snapshot. - The ordinary path also lets an exact local row win without a home check, so the hook matches it. 4. **Client IP.** - Forged XFF, Forwarded, proof and hop headers have no effect. - Malformed hops get 503 before anything can attribute them. - Edge and console agree in both delivery modes: a single canonical XFF with a proof signed for the console host. 5. **Headers and bodies.** - The allowlist is exact and duplicates and empties survive. - No-store holds on every exit, including the 404, `rateAdmit` 429 and hop-admission 503. - There is no `GetBody`, no POST retry and no buffering. `ReadFrom` isn't exposed, and `Flush` works. 6. **Layers.** - `rateAdmit` and its release match ordinary dispatch, and `Ticket.Release` is idempotent. - Source ingress applies hop concurrency and fair-share, and the home edge then applies per-client limits. - Tokens, job IDs and Authorization are not logged, because the error handlers discard the error. - The hook skips `admissionRefuses`, but ordinary dispatch also backhauls non-local hosts on a box that isn't admitted, so the forward leg matches. The plan's bypass list doesn't name this, so one line there would help. 7. **hostenv.** The names are sorted and carry no credentials, because the edge requires exactly `https://&lt;host&gt;`. They fit the file's `CARLOS_S3_ENDPOINT` precedent and round-trip through seed, group and write. 8. **Tests.** They run through `Edge.ServeHTTP` and real `Reload`. Removing `rateAdmit` or the trailer filter fails them properly. ## Verdict **READY AFTER FIXES:** P2 #1 only, fixed without reopening the review.</result> <usage><subagent_tokens>221616</subagent_tokens><tool_uses>29</tool_uses><duration_ms>1344305</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a522ee331f72e4ecf</task-id> <tool-use-id>toolu_014qSjew5wsDNEVvZbj5CFCE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/a522ee331f72e4ecf.output</output-file> <status>completed</status> <summary>Agent "Opus review of Task 1" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result># Review of Task 1, round 1 (`71d426f8..47cb4fd9`) There are no P1s and four P2s, so the verdict is READY AFTER FIXES. The three named tests pass, both on the clean worktree and on an export of `47cb4fd9`. I didn't edit the worktree, and my scratch directory is removed. All paths below are under `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/demo-api-site-route/`. **Sandbox bypass:** the sandbox mounts the default Go cache read-only, which blocked building anything new. You told me to leave `GOCACHE` unset, so I ran my scratch-test and mutation commands with the sandbox off. They only wrote to the Go cache and my scratch directory, and only used loopback. **Scratch export:** the other agent's uncommitted edge edits broke the worktree build partway through, so all witnesses and mutations ran on the export. ## P1 None. ## P2 ### 1. The catch-all door does not see the configured host - **Problem:** the configured host is matched by exact name in `domainHostPolicy`, so it never appears in `platformDomains`. The check for names under a catch-all parent only reads `consoleHosts`, `reservedDomains` and `platformDomains`. - **Evidence:** `internal/console/domaincatchall.go:76`, `internal/console/domainpolicy.go:95`. The doc comment at `domaincatchall.go:47-52` promises to refuse any platform hostname strictly under the parent. - **Witness:** with the origin set to `https://www.example.com`, `catchallParentRefused("example.com", "shop")` returns false. The same name in `DenyDomains` returns true. - **Failure scenario:** a person in the account holding `example.com` attaches `*.example.com`, which covers the operator-only site host. - A proven catch-all held by another account can then make `catchallInstanceName` refuse that host at the attach door (`domaincatchall.go:218-231`). - I read that path but did not run it, and I did not run instance creation at the `www` label. - The API alias is not hijacked, because it intercepts before routing. An apex site host is already refused at `domaincatchall.go:60`. - **Fix:** add the configured host to `entries` at `domaincatchall.go:76`, and add this case to `TestDemoAPIHostOwnership`. - **Invariant (exact-name reservation vs subtree readers):** every reader of the deny tiers must see the new reservation. The plan lists catch-all as affected. ### 2. `validateDemoAPIOrigin` accepts IP-shaped hosts - **Problem:** `demo.ValidDomain` only rejects what `netip.ParseAddr` parses, so legacy IPv4 forms pass. - **Evidence:** `internal/console/demo_api_origin.go:19`, `internal/demo/config.go:127`. - **Witness:** all of these are accepted: `https://127.1`, `https://0x7f.1`, `https://1.2.3`, `https://1.2.3.4.5`, `https://2130706433.0`, `https://example.123`. - **Failure scenario:** an operator typo starts the console, and agents get a `statusUrl` that URL-standard clients read as `127.0.0.1`. It also becomes a nonsense platform-host reservation. - **Fix:** in `validateDemoAPIOrigin`, refuse a final label that is all digits or `0x` hex, and add those inputs to the test table. Leave `ValidDomain` alone, since other code uses it. Task 2's edge parser needs the same rule because the plan requires one grammar. - **Invariant (origin grammar):** no IP literal. ### 3. The publish handler rechecks the proof after the upload, so verified attribution can fall back to loopback - **Problem:** the gate verifies the proof at entry, but `s.clientIP(r)` verifies it again after the body read, and the proof is only valid for 30 seconds. The read deadline is also 30 seconds, and proof timestamps are rounded down to the second. - **Evidence:** `internal/console/apidemo.go:408`, then `:439`. Also `internal/edgeproof/edgeproof.go` (`Skew`, `Sign`), `internal/console/edgeproof.go:75-85`, and the deadline at `apidemo.go:324`. - **Witness:** a publish with a valid, 29-second-old proof and a 3-second body read returns 202 with `creating_ip="127.0.0.1"`. A fresh proof records `192.0.2.77`. I simulated this with a recorder, which applies no read deadline, so the window in production is the last second or so before the deadline. - **Failure scenario:** a client can pace its upload, or a slow upload can happen to land, so that its abuse record names loopback instead of the client. A key refresh between the two checks could cause the same thing. Budgets are not affected, because `:374` and `:386` run before the body. - **Fix:** capture the IP once before the body read and reuse it at `:374`, `:386` and `:439`. If off-mode must stay literally unchanged, do this only when `DemoAPIOrigin` is set. - **Invariant (identity verified once, derived twice):** the plan says `clientIP` "sees the verified chain". ### 4. The 503 refusal waits on the request body - **Problem:** the gate's refusal for a POST omits `Connection: close`, so `net/http` tries to drain the body before sending the reply. The publish handler's own comment guards against this drain (`internal/console/apidemo.go:320-324`). - **Evidence:** `internal/console/demo_api_origin.go:58-60`. - **Witness:** on a real listener, an unsigned loopback POST declaring 10 bytes and sending none got no response within my 3-second deadline. Adding `Connection: close` returned the 503 immediately, and `TestDemoAPIProofRequired` still passed. - **Failure scenario:** a tenant process, or an upload hit by a key mismatch, holds the request open without spending any budget, up to `ReadTimeout` (5 minutes, `internal/console/httpserver.go`). The plan wanted this refused "before budget/body work". The test's `demoUnreadBody` cannot see this because a recorder never drains. - **Fix:** set `Connection: close` and a short read deadline on the refusal, and add one witness on a real listener. - **Invariant (refusal does no body work):** this applies on the wire as well as in the handler. ## P3 (follow-up list) 1. **Malformed A-labels:** `https://xn--a.example.com` and `https://xn--0.com` are accepted. The test deliberately allows valid `xn--` names, so this only needs a Punycode check. The R-LDH name `ab--cd.example.com` is also accepted, which seems fine. 2. **Plan 4 gates:** lines 21, 61 and 192 list the dependencies for activation and acceptance, but don't name the site route. Only the open-questions line (`:224`) does. The live check at `:188` would catch it, but the three lists should agree. 3. **Plan 4 cache header:** line 188 requires `Cache-Control: no-store`, while this plan's Task 2 forces `no-store, private` at the edge. A strict comparison would fail the live gate, so it should say "contains no-store". 4. **Test entry point:** the witnesses enter at `s.mux`, not `s.ServeHTTP`, and there is no form-door case (`internal/console/domainattach.go:140`, `:369`). Those doors share the policy function, so this is only a coverage gap. 5. **Trailing-dot Host:** `requireDemoAPIProof` compares with `normalizeHost`, which keeps a trailing dot, while `edgeproof.canonicalHost` drops it. A Host of `console.example.com.` gets a 503, which fails safe. I read this but did not run it. ## Checked and clean - **Forged or replayed proofs:** - An app's valid proof, a wrong Host, duplicate headers, multi-element or non-canonical XFF, a zone, an expired proof and a wrong key all get a 503. - The gate runs first on both publish and status, and spends no budget or latch. - An edge door caller gets a valid proof, but only for the box's own IP, so it cannot pick its identity. - **Real traffic still passes:** - Ingress and verified hops send a single XFF element (`internal/edge/homemap.go:1537-1555`), so legitimate traffic gets through. - A direct console request through the local edge passes. - An unsigned loopback caller gets a 503, which the plan intends. - An untrusted peer is unaffected. - **Setting off:** the gate returns early, and the link and policy branches are skipped, so behaviour is unchanged. - **Key rotation:** both keys are accepted. A stale cache or a store failure gives a 503 with `Retry-After`, never loopback attribution at the gate. - **Links:** `statusUrl` comes only from configuration, and `claimUrl` keeps the console origin and fragment. No other response field or error names the console host, and the update reply shares the same line. - **Host policy:** - `EXAMPLE.com`, `example.com.`, `EXAMPLE.COM.` and `example.com:443` were all refused on attach. - The first two spellings were also refused on detach and paths (the other two weren't tried there). - The ship code doesn't call the policy function, so an ordinary static ship is unaffected. - **Plan 4 amendment:** lines 81, 83, 84, 123, 129 and 188 match the plan. The 32-byte unknown job ID matches `ValidJobID`. ## Test strength All 9 mutations were caught, so the tests are real witnesses for what they cover: - publish gate removed - status gate removed - Host pin removed - canonical IP compare removed - single-proof check removed (reran after a compile error) - single-XFF check removed - host policy removed - `claimUrl` moved to the site origin - `statusUrl` taken from Host The gaps are the ones in P2 items 1, 2 and 4. ## Verdict **READY AFTER FIXES** (no P1; P2s 1 to 4 above).</result> <usage><subagent_tokens>178565</subagent_tokens><tool_uses>25</tool_uses><duration_ms>798922</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bcjkbhyr5</task-id> <tool-use-id>toolu_0174cP6NmcWNwJ4tgtznachy</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bcjkbhyr5.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 2 implementer to finish" completed (exit code 0)</summary> </task-notification>