carlos / platform Public

demo-api-claim-paths

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 25ca6faf, CI green on the tip and on main. Not released; no box touched. P3 follow-ups are in the report on #527.

Next

Program controller arranges the dev release and switch-on (plan's Switch-on section).

Already decided

Claim start and verify keep the admitted IP. hostenv refuses a bad origin pair at write time.

Recently

Human

<task-notification> <task-id>bmmcqklhl</task-id> <tool-use-id>toolu_01DuJR62dtshQyzM4ZUwYQ2T</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bmmcqklhl.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>bi1jym6kv</task-id> <tool-use-id>toolu_01G1AJKjmVFQhxKfuEbdzLZE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bi1jym6kv.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>bmdt2l6nu</task-id> <tool-use-id>toolu_01146VPmF5CECvmnMUvFhpVN</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/bmdt2l6nu.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the branch tip" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a05957af263acc65a</task-id> <tool-use-id>toolu_01SSGtSmrfLJpJAA3Soea1hu</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/a05957af263acc65a.output</output-file> <status>completed</status> <summary>Agent "Opus review of claim follow-up" 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: `e12fe9a1..b65f2b89`, demo claim API follow-up ## P1 None. ## P2 None. ## P3 (follow-up list only) **1. The plan's header list is false for merged code, and the extra header has no witness.** - **Evidence:** plan line 78 lists the preserved headers and says "drop all other client headers". `internal/edge/demo_api.go:186` also forwards `Sec-Fetch-Site`, added in e12fe9a1. Removing it from that list leaves every `TestDemoAPIAlias*` test passing. - **Invariant:** the alias forwards only a fixed set of headers. - **Failure scenario:** a later reader "corrects" the code to match the plan. I found no exploit: a cross-site POST still carries its hostile Origin, and a cross-site GET cannot send the bearer. - **Fix:** add the header to plan line 78. Send it in `TestDemoAPIAliasClaimPaths` and assert it arrives. - **Family:** new, plan against merged code. **2. The plan edit removes "never loosen" and doesn't mention the site-Origin admission.** - **Evidence:** the new sentence at plan line 88 is true but mentions only absent-Origin and hostile-Origin requests. `demo_claim_auth.go:30` admits the site Origin. - **Failure scenario:** a reader can't tell that this admission was deliberate, or why it is safe. - **Fix:** add one sentence: "Exact site Origin is admitted on the four API paths only; those paths honour no cookie, and `Sec-Fetch-Site` still applies." - **Family:** new. **3. The pair refusal doesn't name the settings.** - **Evidence:** `internal/hostenv/hostenv.go:241` returns bare `ErrValue`. Other `ErrValue` refusals in the package name the key (`hostenv.go:224`). - **Failure scenario:** an operator sees "a name or value host.env cannot hold" and has about 30 names to check. - **Fix:** `fmt.Errorf("%w: CARLOS_DEMO_API_ORIGIN, CARLOS_DEMO_API_CONSOLE_ORIGIN", ErrValue)`. - **Family:** new. **4. A claim refusal waits on a stalled body.** - **Evidence:** the claim handlers set no `Connection: close` or read deadline, unlike publish after this diff. In a scratch probe, a hostile-Origin `POST /api/demo/claims` with `Content-Length: 10` and no body got no reply within 3 s. I ran it with `DemoAPIOrigin` cleared, so it skipped the proof check, but the handler code after that check is the same. - **Invariant:** an early refusal should not depend on the client finishing its upload. - **Failure scenario:** a stalling client holds a console connection until the 5-minute `ReadTimeout` (`httpserver.go:20`). Only that client's own reply is delayed. Other console POSTs have the same limit, so this is not new exposure. - **Fix:** optionally set a short deadline and `Connection: close` in the claim handlers. - **Family:** stalled body, as in this diff's publish fix. **5. The switch-on and rollback steps don't mention the two-parameter window.** - **Evidence:** the parameters change one at a time, so a box launched in between now fails at `group-init.sh.tftpl:332` under `set -eu`. - **Failure scenario:** a box launched in that window doesn't come up. This is no regression: the box previously wrote the file, then `carlos-edge` refused to start with `Restart=no`, so it never served either. - **Fix:** add a sentence to the plan's rollback section and switch-on step 2. - **Family:** activation, like R1's every-public-ingress and activation-downtime findings. **6. The placement re-read can burn the one-time warning.** - **Evidence:** see item 2 below. A client with a real proved flow can stall its body and trigger the once-per-process log line at `edgeproof.go:80`, which could hide a later real edge rollback. - **Fix:** optional. Pass the captured IP into the region request. - **Family:** client attribution (R1), but no budget is involved. ## Answers to the checks **1. `demoClaimOrigin` site branch: not a loosening that matters.** I found no concrete scenario. - The branch covers only the four API paths. `/demo/claim*` and the email link stay console-only, and `TestDemoClaimAPIOrigin` checks the `/demo/claim*` paths. - The console session cookie has no effect on these handlers. They authorise from the claim token or flow token, and the account comes from `flow.Person` (`demo_claim_target.go:50-55`). - Through the public edge, console-host requests on these paths also take the alias (`demo_api.go:119`), and the filter drops `Cookie` (`:186`). - A site page calling the console directly sends `Sec-Fetch-Site: same-site` or `cross-site`, which is refused (`demo_claim_auth.go:47-50`). - In a browser without that header, the request gets through but still has no cookie authority. - Script on the operator-only site origin gains nothing beyond what an agent with no Origin already has, and it still needs the tokens. **2. Attribution: correct.** - The IP is captured after the proof gate and before the body read in Start (`demo_claim_auth.go:127-130`) and Verify (`:227-230`). - Submission, send, guess and signup all use that captured IP. - Off-mode reads it at the original point (`:157-159`, `:249-251`). - Select and Status have no IP budget: `demo_claim_target.go` has no `limits.`, `clientIP` or `personIP` use. **Placement re-read: not a real fault.** - `newAppRegionReq` at `demo_claim_auth.go:367` re-reads `clientIP` through `personIP`. On an expired proof, `forwardedByEdge` returns false, so `clientIP` returns the loopback peer. - From there, either GeoIP should find no location and the guess becomes home, or the guess fails and `resolveNewAppRegion` returns the default. I read this path but did not run it. - The client can only give up a nearest-region guess and land on the default, which any address with no GeoIP match already gets. No budget or authority is involved, and `rq.ip` has no other reader. **3. `apidemo.go`: acceptable.** - Status and body are unchanged; only connection handling differs, and a stalled body no longer delays the refusal. The witness shows this. - `Connection` is hop-by-hop, and publish already closes the connection on its on-mode paths. - The off branch runs only when the route is registered, meaning box mode. With demo fully off, the route doesn't exist and nothing changes. - A writer without deadline support would turn the 404 into a 503. Production uses the same mux path the on-mode already relies on, though I did not trace every wrapper. All console tests matching `Demo` pass. **4. hostenv pair check: safe.** - All consumers: `Fetch` (`hostenv.go:380`), `FetchGroup` (`group.go:161`), `validateGroupEnvironment` (`group_boot.go:155`), maintenance `localConfiguration` (`group_maintenance_prepare.go:60`). - The check mirrors `parseDemoAPIAliasConfig` (`demo_api.go:19-33`). It refuses only configurations the edge also refuses at startup, so no configuration the edge accepts breaks. - A failed check stops before `host-env write` replaces the file. - A half-removed pair is refused, including a shared name left behind for another region. The new edge would refuse that state too. - `internal/demo` is already in the root binary (`go list -deps .`), has its own census coverage pin, imports only the standard library and has no `init`. - No new human-facing text: it reuses the existing `ErrValue` string and prints no value. - `internal/hostenv` still builds for darwin and windows. **5. Witnesses: production-wired, and they fail when disconnected.** I ran 13 mutations on a scratch copy. | Disconnected | Result | |---|---| | Start or Verify IP capture (2 mutations) | `TestDemoAPIProofRequiredClaimExpiry` fails | | Select or Status proof gate (2 mutations) | `TestDemoAPIProofRequired` fails; Select also fails the stalled-body test | | Site branch accepts any Origin; `Sec-Fetch-Site` check removed (2 mutations) | `TestDemoClaimAPIOrigin` fails | | Publish code moved back below the refusals | `TestDemoPublishEarlyRefusesStalledBody` fails, both modes | | Check removed from `Assemble` or `AssembleGroup` (2 mutations) | `TestDemoAPIOriginPair` fails | | Status path removed from `demoAPIPath` | `TestDemoAPIAliasClaimPaths` fails | | Client XFF trusted (filter and `setForwarded`) | `TestDemoAPIAliasClientIP` fails at request 61, the one the varied XFF exercises; `TestDemoAPIAliasClaimPaths` also fails | | Filter alone keeps XFF | Survives: `setForwarded` overwrites it, so this is two layers and not a test gap | | Edge drops `Sec-Fetch-Site` | Survives: P3 1 | **Requested test runs: all pass.** - `./internal/console`, `./internal/edge`, `./internal/hostenv` and `./internal/provision` with your patterns. - `./internal/host -run Census`. The first provision run failed on read-only cache errors, so I reran it outside the sandbox. The mutations also ran outside it. **Extra targeted runs: all pass.** - `./internal/console -run Demo` - all of `./internal/hostenv` - `./internal/host -run Group` **6. Plan doc: the edits are true.** - I checked the path and gate claim against e12fe9a1. - The wider plan still has P3 1, P3 2 and P3 5 outstanding. - Plan line 54's "fail startup" still holds; the write now refuses first as well. **Commit on the branch:** 23dba183 landed while I worked. It changes only `README.md` and two copy-brief specs, so I treated it as out of scope. Your commit is the one reviewed. I did not check whether the census runs included it. ## Census verdict (tip b65f2b89) **Envelope `internal/hostenv`: APPROVED.** - **Changed functions:** `Assemble` and `AssembleGroup` gain a call to `validateDemoAPIOrigins`, which reaches only `demo.ValidAPIOrigin` and `ValidDomain`. Those are pure string checks. - **Root's reads:** root opens, runs and follows nothing new. The only effect is an added refusal, and no existing check is weakened. - **Inputs:** the values come from the operator-only parameter store or the root-owned `host.env`. **Units: no unit changed.** - `Assemble`, `AssembleGroup` and the new helper have no census rows and no read sites. - The hostenv units I checked (`installGroup`, `runHostEnv`, `checkedDir`) are unchanged in the diff. **Scope: unchanged.** The new import was already in the root binary. **Card and overlay: complete.** - `make census-card` reports clean, and `TestPlan14RootReadCensus` and the scope guard pass with the single `@coverage` line. - The record-write and group-name pins pass in `./internal/host`. - The unchanged seal is correct for a change that only re-pins an envelope. The verdict still needs recording on #280, since I was told not to edit anything. The scratch directory has been removed, and the worktree was clean at my last check. READY</result> <usage><subagent_tokens>151126</subagent_tokens><tool_uses>21</tool_uses><duration_ms>1114186</duration_ms></usage> </task-notification>

Human

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