census: pin NewServer and Edge.Reload for the demo API route
NewServer validates one origin and writes nothing. Reload builds a proxy over an existing exact console row and publishes no name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/host/group_names_test.go+3 −2internal/provision/demo_api_site_route_census_test.go+18 −0internal/provision/plan9_b8_census_test.go+1 −1
CI passed — run details
Intent
<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>
<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>
Attributed to this commit: 27.7 g CO₂e (3,133,614 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on demo-api-site-route, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 5b1c153ab..85558b673 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -365,8 +365,9 @@ var groupNameProducerInventory = map[string]string{ |
| "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| "../edge/assetcatch.go:*Edge.serveAssetFar": "7d358ec272ae74c05764504550bad461096a09d0bfcc108dcbe5485f8f68d643", |
| // Demo protections wrap existing proxies and retain refusal-only names. |
| - // They do not derive or publish a new group-name class. |
| - "../edge/edge.go:*Edge.Reload": "1030be6dfba6a0737bc47a41d465376a03e5b3cd552dbbdb9026a1c60151d1b2", |
| + // They do not derive or publish a new group-name class. The site demo API |
| + // proxy is built over an existing exact console row and publishes no name. |
| + "../edge/edge.go:*Edge.Reload": "0bb4a15d656cc7428b47ea3debfa33e29c311d6db1fabb03785e0d37c3b21c8e", |
| "../edge/platformalias.go:PlatformAliasFold": "a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f", |
| "../edge/regional.go:*Edge.foldRegional": "b413fad6a8e17530ce0e99c79c521e0a6782b82c04d61d256442b8defe6a427b", |
| "../provision/forward.go:forwardRowFor": "e7294d6a3c96e51646257200f5cedb26aaf491afea23be3d943b3e3f742c4db4", |
diff --git a/internal/provision/demo_api_site_route_census_test.go b/internal/provision/demo_api_site_route_census_test.go| new file mode 100644 |
| index 000000000..726d0657a |
| --- /dev/null |
| +++ b/internal/provision/demo_api_site_route_census_test.go |
| @@ -0,0 +1,18 @@ |
| +package provision |
| + |
| +// Record-write census entry for demo-api-site-route, layered on |
| +// regionHAG3B10WriteCensusInventory. No record write is added, moved or |
| +// reclassified: NewServer keeps its key site. It now validates |
| +// CONSOLE_DEMO_API_ORIGIN once into the server's read-only config. It writes |
| +// nothing. |
| +func demoAPISiteRouteWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), regionHAG3B10WriteCensusInventory()...) |
| + replacement := censusEntry{"internal/console/server.go", "NewServer", "key-site", "lit:instances", "480ff98cbcd0ae3d4fc7cb9151d3f4a363a545860853dfdcb5e80b33230a5910"} |
| + for i, e := range entries { |
| + if e.File == replacement.File && e.Unit == replacement.Unit { |
| + entries[i] = replacement |
| + return entries |
| + } |
| + } |
| + panic("demo-api-site-route replacement of an unlisted unit " + replacement.File + ":" + replacement.Unit) |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index ebcf4407e..9e718fd1a 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := regionHAG3B10WriteCensusInventory() |
| + inventory := demoAPISiteRouteWriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |