plan: serve the demo API on the site host
Plan and round 1 review brief. Paul's ruling on #527: one allowlisted host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-05-demo-api-site-route.md+162 −0docs/superpowers/plans/REVIEW-BRIEF-DEMO-API-SITE-ROUTE-R1.md+107 −0
CI passed — run details
Intent
<task-notification> <task-id>b57dms4u1</task-id> <tool-use-id>toolu_01Evoy2CZ1GzRPaycDR8Pe37</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ada77e36-2f79-4efb-88a5-c350ac2ffa6a/tasks/b57dms4u1.output</output-file> <status>completed</status> <summary>Background command "Wait for the Astra plan run to finish" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 10.1 g CO₂e (806,127 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/docs/superpowers/plans/2026-11-05-demo-api-site-route.md b/docs/superpowers/plans/2026-11-05-demo-api-site-route.md| new file mode 100644 |
| index 000000000..b0c6fbc4f |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-05-demo-api-site-route.md |
| @@ -0,0 +1,162 @@ |
| +# Demo API site route Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** An agent reads the site and publishes, polls and eventually claims a demo using that site's one allowlisted host. |
| + |
| +**Architecture:** An operator-configured edge alias reserves a small method/path allowlist on one existing site host. It reaches the deployment's console locally or through the existing signed backhaul; the console remains the API authority and constructs agent URLs from a separate configured public origin. The site remains a static release. |
| + |
| +**Tech Stack:** Existing Go, `net/http/httputil`, edge route snapshots, mesh authentication and systemd environment delivery. No new dependency or provider adapter. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-11-02-agent-start-demo-design.md:136`, refined by Paul's 2026-11-05 ruling in discussion #527 supplied with this task: the single API host becomes the site host. Read Plans 1, 2 and 4 and their rulings; Plan 3 supplies only the future path inventory below. Static Markdown negotiation is already present at `internal/edge/static.go:702`. |
| + |
| +## Global Constraints |
| + |
| +- Baseline: `demo-api-site-route`, `1cc99071afd0ea84e25f57cc6ccc73dd5e11e2cf`. Unqualified file:line citations refer to this worktree; new interfaces below are proposals. This session writes only this plan, with no product code, tests, agents, commits or pushes. |
| +- Provider-neutral, off by default, no new bucket object, per-box poller, credentials or tenant-facing configuration API. Reuse `Reload` and the existing home/key mirrors (`internal/edge/edge.go:841`; `internal/edge/homemap.go:1268`, `:1294`). |
| +- Preserve “24 hours, no extension without claiming”, “nothing is backed up” and “no outbound network at all”; this changes API reachability, not demo execution (`docs/superpowers/specs/2026-11-02-agent-start-demo-design.md:199`). Preserve the 5,000,000-byte source cap (`internal/demo/config.go:14`). |
| +- Three tasks, one branch and one visible merge. Paul is the requester. The build controller does not release or change boxes: after merge it hands the Switch-on steps to the program controller, which arranges the dev release and activation. Public activation accompanies the later website release after Plan 3's follow-up. No dormant scaffolding merge or flagship changes in this build. |
| +- No tenant names in new core code, tests or operator examples; use `shop` and `example.com`. Deployment hostnames occur only under Switch-on. Human-facing additions are inventoried in the one copy table below; no em dashes in their copy. |
| +- Follow `AGENTS.md:34` stopping rules, `:245` build gate and `:288` census. All commands below belong to implementation, not this authoring session. Keep default Go caches, disk scratch and loopback test listeners. |
| + |
| +## Review Focus |
| + |
| +1. Another host, path spelling or tenant-controlled alias reaches the console: Task 2's `TestDemoAPIAliasBoundary`. |
| +2. Cross-region forwarding loses the client IP or trusts a forged header: Task 3's `TestDemoAPIAliasClientIP`. |
| +3. A static redirect, cache hit, cookie trailer or informational response intercepts/leaks API traffic: Task 2's `TestDemoAPIAliasIsolation`. |
| +4. A partial upload or broken connection replays a create or changes its error: Task 3's `TestDemoAPIAliasStreaming`. |
| +5. Returned URLs still require the console host, or Host chooses their origin: Task 1's `TestDemoPublicAPIOrigin` and Task 3's `TestDemoAPIAliasJourney`. |
| + |
| +--- |
| + |
| +## Decisions and evidence |
| + |
| +All implementation choices below are **my call**. This is a general deployment capability for an operator's chosen site, not a tenant-defined arbitrary reverse proxy. |
| + |
| +### Paths and links |
| + |
| +| Forward on the configured site | Decision and evidence | |
| +|---|---| |
| +| `POST /api/demo/apps` | Create and bearer-token update share this handler (`internal/console/apidemo.go:276`, `:328`). | |
| +| `GET /api/demo/jobs/{jobID}` | Exactly one nonempty base64url-alphabet segment; leave token-length/existence validation and its response to the console (`internal/console/apidemo.go:280`, `:526`; `internal/demobuild/job.go:68`). | |
| +| Future: `POST /api/demo/claims`, `POST /api/demo/claims/verify`, `POST /api/demo/claims/select`, `GET /api/demo/claims/status` | Inventory only: `agent-start-demo-3:internal/console/apidemo.go:272`. Plan 3's declared contract is in `docs/superpowers/plans/2026-11-04-agent-start-demo-3-claim.md:72`. Add these four entries and contract tests in a small follow-up **after Plan 3 merges**. No review or implementation dependency on its unmerged code. | |
| + |
| +The reservation includes `/api/demo` and `/api/demo/`. An unlisted method/path, HEAD, OPTIONS, upgrade, query (including bare `?`), escaped path, dot segment, repeated slash or trailing slash gets an empty, uncached 404 on the site, without console dispatch or static fallback. Detect the reservation in both decoded and cleaned paths, then require the original canonical spelling; never redirect a malformed spelling into an allowed operation. The supported requests need no query. GET's implicit HEAD registration in Go does not enlarge this allowlist. |
| + |
| +Exclude `GET/POST /demo/report`, `GET /demo/claim`, all `/demo/claim/{intent,prove,select}` browser POSTs, every `/api/box/*` build/claim/retirement door, authenticated account/operator APIs, and `POST /api/demo/reports`. The last path is **not registered on this baseline**; actual reporting uses `/demo/report`, sets a cookie and checks console Origin (`internal/console/apidemo.go:273`; `internal/console/apidemoreports.go:144`, `:156`). Box doors are registered at `internal/console/apidemo.go:275`; browser claim inventory is `agent-start-demo-3:internal/console/apidemo.go:276`. Excluded paths outside the reserved prefix keep the site's ordinary behavior and never reach the console through this capability. |
| + |
| +Add console setting `CONSOLE_DEMO_API_ORIGIN`, represented by `Config.DemoAPIOrigin string`. Empty falls back to `Config.Origin`; otherwise it is one canonical HTTPS DNS origin, no port except implicit 443, credentials, path, query, fragment, wildcard or IP literal. Use it for `statusUrl` and any future **agent API** URL; do not rewrite JSON at the edge. Today both status and browser claim URLs use `s.cfg.Origin` (`internal/console/apidemo.go:455`). Keep `claimUrl` on `Config.Origin`, including its secret fragment: the agent validates and hands it to the human without fetching it. Live/permanent app URLs also remain unchanged. They are destinations to show the human, not additional API hosts to contact. |
| + |
| +Plan 4 must gain `StartConfig.demoAPIOrigin` and required enabled-build setting `CARLOS_START_DEMO_API_ORIGIN`, equal to `siteOrigin`. Retain `consoleOrigin` for browser claim validation and the later optional authenticated CLI workflow. Publish/update/poll and the merged claim API use `demoAPIOrigin`; validate returned agent endpoints against that exact HTTPS origin and allowed path, never follow redirects with credentials. Validate browser claim links against `consoleOrigin` plus `/demo/claim`, preserving the fragment. This replaces Plan 4's console-origin publishing and combined link check (`docs/superpowers/plans/2026-11-04-agent-start-demo-4-start-page.md:81`, `:84`, `:123`). The one-host promise covers the anonymous/claim API journey; normal CLI onboarding remains an explicit later choice (`:86`). |
| + |
| +### Operator authority and routing |
| + |
| +Edge settings are `CARLOS_DEMO_API_ORIGIN` (site) and `CARLOS_DEMO_API_CONSOLE_ORIGIN` (canonical console). Both unset disables the alias; partial, equal or invalid origins fail startup. Use the same origin grammar as the console setting. No wildcard, path, arbitrary destination address or operator-editable path list. Parse at edge construction (`internal/edge/edge.go:575`), then use current routing snapshots. Changing settings requires an edge restart; ordinary route changes use the existing reload. |
| + |
| +Deliver these settings in a root-owned `/etc/systemd/system/carlos-edge.service.d/40-demo-api.conf` with `[Service] Environment=` assignments, not an app config bundle. Deliver the console setting in `/etc/systemd/system/console.service.d/40-demo-api.conf` the same way. The edge runs the agent and already reads host settings (`internal/host/units/carlos-edge.service:15`). Do not add authority settings to `hostenv.Optional`, whose exclusion rule is explicit (`internal/hostenv/hostenv.go:53`). `Environment=` survives named-unit config delivery, while that delivery resets `EnvironmentFile=` (`AGENTS.md:550`). No new root file reader or unit generator is needed. |
| + |
| +Treat the configured public-origin host as `hostPlatform` in `domainHostPolicy`, after existing reserved-host checks. This makes later attach/repoint/path/detach writes operator-only, including a member of the site's own account; service credentials cannot be operators (`internal/console/domainpolicy.go:66`, `:117`, `:134`; `internal/console/apidomains.go:379`, `:966`, `:1145`). Configure the console reservation before enabling edges. A tenant can neither set process environment nor enable this feature with a route/alias/path record. Unconfigured hosts retain their own `/api/demo` handlers. |
| + |
| +Add the dispatch hook after `acceptHop` and inbound control-header scrubbing, before `lookupUpstreamPath` (`internal/edge/edge.go:1983`, `:1998`, `:2009`). It handles the configured source's reserved namespace and the configured console's allowlisted API requests. The latter gives remote deliveries the same cookie/cache policy. Do not invoke `ServeHTTP` recursively. Clone the request; set Host and URL authority to the configured console before signing or proxying. Client Host only selects an exact configured source; it never selects the destination or response links. Reject edge-local door callers rather than grant a tenant process a cross-app door exception. |
| + |
| +On the console box, use only the **exact** configured console route, ready, raw account empty, app `console`, unit `console.service`, non-alias, non-regional, non-tunnel and non-activator-owned, with a Unix socket or exclusively loopback addresses. This is the existing console-route authority test (`internal/edge/replicaconsole.go:8`), narrowed to one configured hostname. Build a dedicated proxy from the same socket/TCP/probed transport constructors in Reload, in the same atomic upstream entry; do not mutate the ordinary console proxy. Preserve its selected endpoint and version header. Missing/ineligible local target never falls through to another app. |
| + |
| +On another ingress, use `homes.ExactHome(consoleHost)` and existing `hopTo`/`backhaulTransport`, including TLS SNI/verification, hop concurrency and fair-share admission (`internal/edge/homemap.go:1067`; `internal/edge/edge.go:4196`, `:4252`, `:4303`). Reject an empty dial/box, absent key or an already-hopped request needing another hop with empty 503 and `Retry-After: 2`. A held home is not a usable destination. Do not resolve the console through public DNS, a tenant wildcard, forward row or tunnel. A wrong/stale destination refuses instead of trying a second box. |
| + |
| +This runs on every public ingress before the **site's** regional placement or fleet/static dispatch. A site may therefore be an attached platform host, reside in another region, or have no local console route. Static dispatch normally follows socket/address/fleet arms (`internal/edge/fleetforward.go:165`); `_headers`, slash redirects and Markdown negotiation run later (`internal/edge/static.go:590`, `:691`, `:702`). None runs for the reserved API. No static POST/read-only assumption reaches it. A host's ordinary page requests retain their existing placement and static behavior. |
| + |
| +Fleet workers do not receive mesh keys (`internal/edge/mesh.go:91`). Their tunnels carry site/app traffic; public ingresses intercept this API before sending anything down those tunnels. Do not distribute keys to make a directly exposed worker an API ingress. A self-hoster can use the same capability on platform ingresses and its existing store adapter; a deployment without signing/home readiness refuses until configured. Existing host aliases preserve incoming Host and are scoped to their tenant, while forward rows describe fleet placement, so neither is an adequate cross-app API proxy (`internal/edge/alias_test.go:27`; `internal/registry/aliassocket.go:24`; `internal/registry/forward.go:56`). |
| + |
| +### Client identity, headers and delivery |
| + |
| +The ingress derives XFF from the socket peer for direct traffic. For a valid existing hop it retains the authenticated chain; invalid client hop/proof headers cannot supply a chain. The outbound cross-box hop is TLS-authenticated and mesh-signed for the **console host**; its proxy deliberately removes the local edge-proof header. The console's receiving edge verifies the hop, preserves the original client's XFF, then signs that chain for the local console connection (`internal/edge/edge.go:4382`; `internal/edge/homemap.go:1379`, `:1537`; `internal/edge/forwardproof.go:26`, `:38`). Thus `clientIP` sees a trusted loopback peer, verifies the console-host proof and takes the final element, the real client (`internal/console/authcli.go:1200`). Same-box delivery performs only that final signature. |
| + |
| +Require a cached signing key even for local delivery; an invalid purported hop to the console gets 503, never attribution to the sending box. With `CONSOLE_DEMO_API_ORIGIN` set, gate the two anonymous handlers before budget/body work: a trusted proxy peer must carry exactly one valid proof and a canonical single-IP XFF, otherwise return empty no-store 503 with `Retry-After: 2`. An untrusted peer still uses its socket IP, ignoring forwarded headers. Verify through existing `edgeProofKeys` and `edgeproof.Verify`, as the strict report verifier does (`internal/console/apidemoreports.go:241`). Then ordinary `clientIP` sees the verified chain. This closes both initial unsigned trust and key-rotation degradation without changing limits or global login behavior (`internal/console/edgeproof.go:77`). Reuse the existing 30-second key cache (`:47`, `:138`); add no fetcher. |
| + |
| +| Surface | Exact policy | |
| +|---|---| |
| +| Request headers | Preserve all field values, including empty/duplicate values, of `Authorization`, `X-Carlos-Client`, `Content-Type`, `Content-Encoding`, `Accept`, `User-Agent`, `Origin`. Set outbound `Accept-Encoding: identity` on both legs. Drop all other client headers and request trailers. In particular drop Cookie, Forwarded, XFF, edge/mesh proof, client Host overrides, range/conditionals, idempotency, cache, CORS and internal Carlos headers; regenerate forwarding/control headers only from verified context. Preserve authenticated-hop XFF separately before filtering. | |
| +| Authorization | Do not validate away or coalesce malformed credentials. Presence selects update, so dropping an invalid/empty header could create a second app (`internal/console/apidemo.go:328`). The console gives its existing refusal. | |
| +| Request framing | Preserve method, body stream and ContentLength; let net/http manage framing and 100-continue. No archive decode, buffering, source-size check, `GetBody` replay or POST retry. Preserve cancellation. | |
| +| Response | Preserve upstream status, body bytes, Retry-After values, content metadata and ordinary end-to-end headers. Strip hop-by-hop/internal headers, every Set-Cookie (including 1xx, declared and late trailers), and cache validators/Age. Do not follow or rewrite Location. Force `Cache-Control: no-store, private`, `CDN-Cache-Control: no-store`, `Surrogate-Control: no-store`; strip conflicting cache policy trailers. | |
| +| Local failure | Empty 503, `Retry-After: 2`, the same no-store headers. Override proxy transport-error handlers, not received console 5xx responses. After response commitment, terminate the broken stream; do not append a page or replace its status. Existing hop admission may still return its own 429/503 (`internal/edge/edge.go:4252`). | |
| + |
| +Use a private-header streaming writer with `Unwrap()` and flush support to enforce policy on initial, informational and trailer headers; ModifyResponse alone misses 1xx (`internal/edge/cookiescope.go:49`, `:57`, `:63`). Never log bodies, Authorization, source archives or response tokens. |
| + |
| +The alias bypasses site/tenant probe-burst counters, request-protection catalogue, password gates, usage billing, asset cache, shared response cache, gzip and static tree caches. Its canonical method/path gate is the edge admission boundary; console create/status/claim limits remain authoritative, with existing cross-box containment retained. This is an intentional narrow security-policy choice, reviewed in Task 2, not an exemption transferable to other paths. Those layers normally run at `internal/edge/edge.go:2391`, `:2443`, `:2552`, `:2567`, `:2621`, `:2638`. Static kinds already bypass shared caching, but that alone does not cover the earlier asset catch. Explicit outbound identity encoding prevents transport-added gzip/decompression; skip edge recompression and keep the existing pooled transports. HTTP/2 clients stream through the existing HTTP/1.1 backhaul (`internal/edge/edge.go:4297`); no HTTP/2 hop or buffering is required. No body limit is duplicated; console timeout, archive cap and 413 body remain at `internal/console/apidemo.go:317`, `:389`. |
| + |
| +No CORS grant or Origin rewrite is added. The current anonymous handlers are directly registered, outside account/session/CSRF wrappers (`internal/console/apidemo.go:276`). Stripping cookies cannot confer account authority; a console bearer remains limited by the actual handler. Rewriting Host to the configured canonical console avoids retired-host redirects (`internal/console/server.go:2352`). Browser claim/report CSRF doors are excluded. The post-merge claim follow-up must apply the same proof gate and prove absent-Origin agent requests work and hostile Origin requests keep the merged console's refusal; never loosen its checks to accommodate this alias. |
| + |
| +## Task 1: Configure public agent links and operator ownership |
| + |
| +**Risk/review:** security gate and redirect/link authority; independent task review required. No root, termination, storage or billing behavior change. |
| + |
| +**Files:** Create `internal/console/demo_api_origin.go`, `internal/console/demo_api_origin_test.go`; modify `internal/console/server.go:568`, `:1769`, `internal/console/apidemo.go:455`, `internal/console/domainpolicy.go:66`, `cmd/console/main.go:483`, and Plan 4 at its lines 81, 84 and 123. No website-repo edits in this platform plan. |
| + |
| +**Interfaces:** New `validateDemoAPIOrigin(raw string) (string, error)` and `(*Server).demoAPIOrigin() string`; new `Config.DemoAPIOrigin string` and `(*Server).requireDemoAPIProof(w http.ResponseWriter, r *http.Request) bool` (true admits; false has written refusal). Call the proof gate at the start of publish/status when configured. `NewServer` validates the origin; command startup loads `CONSOLE_DEMO_API_ORIGIN`. The helper returns configured public origin or existing `Origin`. Plan 4 consumes the configuration contract above, not a new platform API. |
| + |
| +- [ ] **Step 1: Add failing tests.** `TestDemoPublicAPIOrigin`: unset preserves old status/claim links; configured status uses site; browser claim keeps console/fragment; forged Host/X-Forwarded-Host changes neither; invalid origins fail construction. `TestDemoAPIProofRequired`: before/after the first-proof latch, missing/duplicate/invalid proof, malformed XFF and a rotation mismatch get 503 without spending a budget; valid current/next proofs preserve clientIP; unconfigured behavior is unchanged. `TestDemoAPIHostOwnership`: ordinary members/service principals cannot attach, repoint, publish paths or detach this platform host; authorized platform operators retain existing account membership checks; unrelated hosts are unchanged. |
| +- [ ] **Step 2: Run** `go test ./internal/console -run 'TestDemo(PublicAPIOrigin|APIProofRequired|APIHostOwnership)' -count=1`; expect FAIL for missing behavior. |
| +- [ ] **Step 3: Implement** the named interfaces and Plan 4 amendment. Keep returned JSON shape and all other console-origin consumers unchanged. Do not add Plan 3 handlers. No website prose is approved by this amendment. |
| +- [ ] **Step 4: Rerun Step 2**, plus existing demo and platform-domain policy regressions; expect PASS. |
| +- [ ] **Step 5: Commit during implementation:** `feat: configure the public demo API origin`. |
| + |
| +## Task 2: Forward the operator-selected site API |
| + |
| +**Risk/review:** security gate, cache and production routing; independent task review required, including the deliberate middleware exclusions. Root-binary census scope changes; no new root filesystem access, termination, storage or billing rules. |
| + |
| +**Files:** Create `internal/edge/demo_api.go`, `internal/edge/demo_api_test.go`; modify `internal/edge/edge.go:504`, `:575`, `:841`, `:2009`. Keep registry schema and alias writers unchanged. |
| + |
| +**Interfaces:** New `demoAPIAliasConfig{Origin, ConsoleOrigin string}`, `parseDemoAPIAliasConfig(getenv func(string) string) (demoAPIAliasConfig, error)`, `demoAPIPath(r *http.Request) (reserved, allowed bool)`, and `(*Edge).serveDemoAPIAlias(w http.ResponseWriter, r *http.Request, host string, hopped, hopPresent bool) bool` (true includes refusal). Store immutable config on Edge and a dedicated `demoAPIProxy http.Handler` on the exact console upstream, built in Reload from the eligible local proxy. New `demoAPIResponseWriter` owns its header map and exposes `Unwrap() http.ResponseWriter`. Existing `hopTo` accepts error/response hooks (`internal/edge/edge.go:4196`); use them without changing ordinary hops. A false `hopTo` result can mean it already wrote admission refusal, not permission to write again. |
| + |
| +- [ ] **Step 1: Add failing tests.** `TestDemoAPIAliasBoundary`: both origins unset, partial/invalid settings, exact hosts, static/platform-attached source, unrelated tenant `/api/demo`, every listed/excluded method/path, encoded traversal/separators, queries, upgrades, forged target Host, wrong-account/alias/tunnel/forward console rows and missing target. `TestDemoAPIAliasIsolation`: cookies in both directions and 103/trailers; duplicate/empty Authorization; preserved Origin; preseeded shared/asset cache; `_headers` cache/cookie rules, static redirects and Markdown negotiation; gzip enabled; existing burst cooldown; no tenant usage debit. Verify each API request reaches the console once, ordinary pages stay unchanged, and all API exits are no-store. |
| +- [ ] **Step 2: Run** `go test ./internal/edge -run 'TestDemoAPIAlias(Boundary|Isolation)' -count=1`; expect FAIL. |
| +- [ ] **Step 3: Implement** the dispatch, configuration, proxy and header contracts above. Source and destination consume the same fixed allowlist. Require keys, exact eligible console identity and one-hop containment. Do not add a mesh key reader, persisted route type, public-HTTP redirect or tenant opt-in. |
| +- [ ] **Step 4: Rerun Step 2** plus existing alias, static Markdown, cookie and forward-proof regressions; expect PASS. Check removal/reload leaves no dedicated proxy reachable and route replacement selects the new console endpoint atomically. |
| +- [ ] **Step 5: Commit during implementation:** `feat: forward selected demo API paths from a site host`. |
| + |
| +## Task 3: Prove delivery, close census and switch on dev |
| + |
| +**Risk/review:** integration tests and release evidence; whole-branch review, with census approval. Any new security/root/termination/storage behavior returns to its owning task within the same review budget. |
| + |
| +**Files:** Create `internal/console/demo_api_alias_integration_test.go`, `internal/edge/demo_api_integration_test.go` (package `edge_test`) and `internal/edge/demo_api_export_test.go`; extend Task 2 tests; update the anonymous-demo operator section at `README.md:624` after copy review. Generate census proposal/card with repository tooling, not hand-edited seals. |
| + |
| +**Interfaces:** Consume real `edge.New`, `Edge.ServeHTTP`, `Reload`, console server and existing local test stores. Use `EnableStatic` and `ArmHomeMap` for real proof keys (`internal/edge/homemap.go:399`). Follow the test-only export pattern at `internal/edge/forwardha_export_test.go:22`: new `NewDemoAPITestIngress(t *testing.T, consoleHandler http.Handler) (*http.Client, string)` builds two ingresses and a console-home edge, returning a site-only client and site origin. Reuse loopback TLS/port seams from `internal/edge/backhaul_e2e_test.go:729`; clean up listeners/global overrides with `t.Cleanup`, no parallel use. External edge tests supply a real `console.NewServer`/`console.Open` (`internal/console/server.go:1749`; `internal/console/store.go:107`) without an import cycle or production test API. Console-package tests retain access to private budget fixtures. No public network or cloud account is required. Producer contract is unchanged JSON plus the configured origin. |
| + |
| +- [ ] **Step 1: Add integration witnesses.** `TestDemoAPIAliasClientIP` drives real console admission/status budgets through same-box and cross-box/region fixtures, with no console row on the source; attacker XFF, Forwarded, duplicate proof and forged hop headers cannot change attribution. Test key absence/rotation and stale homes, plus an already-hopped request requiring a second hop. Assert shared client budgets across ingresses and distinct real clients remain distinct. `TestDemoAPIAliasStreaming` uses HTTP/1.1 and HTTP/2 clients, unknown-length/chunked uploads, 100-continue, >5,000,000 bytes, slow upload, early console refusal, cancellation and mid-body failure; count one POST even on dropped connection. Compare console 202/400/401/409/413/429/503 bodies and Retry-After field values byte-for-byte through the alias. Assert no whole-upload buffer and first response bytes arrive before an open response stream finishes. |
| +- [ ] **Step 2: Add** `TestDemoAPIAliasJourney`: one configured site serves static `/start` and API publish/status/update; backend sees canonical console Host, real IP and no cookies; returned status never names console; claim link is handed off without a fetch. Deny the test client's access to the console hostname. Exercise route reload and setting removal with zero extra store reads beyond existing mirrors/console operations. Claims remain excluded until the post-merge follow-up proves all four APIs the same way. |
| +- [ ] **Step 3: Run** `go test ./internal/console ./internal/edge -run 'TestDemo(PublicAPIOrigin|APIProofRequired|APIHostOwnership|APIAlias)' -count=1`; expect PASS. Demonstrate the IP/cache/body witnesses fail when their respective protection is disconnected. Obtain approved operator copy before writing README changes. |
| +- [ ] **Step 4: Census and final gate.** Expect `make census-card` to report changed edge units/envelopes and new helper units because edge belongs to the root binary, even though only the unprivileged edge executes this feature (`AGENTS.md:300`, `:322`). Console-only files are excluded. No registry fields, root file opens, termination or production storage operations are added; new environment inputs and routing authority still require reviewer decisions. Write claims, run `make census-propose NAME=demo-api-site-route CLAIMS=<claims-file>`, and independently review every unit/envelope against amadan main. Record reviewer and tip on #280. Run the repository's build/vet/full-test/gofmt and prescribed cross-build gate once, then tip CI (`AGENTS.md:245`). None runs during plan authoring. |
| +- [ ] **Step 5: Commit during implementation:** `test: prove site demo API delivery and origin isolation`. Describe/push the branch to amadan, obtain whole-branch review and green tip CI, squash-land with the checked 40-character tip, inspect main CI, and follow Switch-on. No flagship activation. |
| + |
| +## Copy review required |
| + |
| +No new end-user response text: new refusals have empty bodies; existing console responses retain their text. Review these additions before implementation writes them into product/docs files. |
| + |
| +| Surface | Copy to review | |
| +|---|---| |
| +| Operator configuration diagnostics | Invalid/partial/equal origins and unsupported console-route explanation, without credentials. | |
| +| README operator documentation | Settings, ingress coverage, readiness, origin distinction, activation and rollback. | |
| +| Plan 4 consumer copy | Its existing copy-review task must replace the console-host allowlist instruction with the site-host instruction and explain browser-only claim links. No website copy ships in this plan. | |
| + |
| +## Rollback |
| + |
| +Restore Plan 4's previous build first if it has switched consumers. Clear `CONSOLE_DEMO_API_ORIGIN` and restart console so new job links again use its original origin; remove both edge settings and restart all participating ingresses. The site then owns `/api/demo/*` exactly as before. No registry migration, alias row, bucket object, cache entry or background worker remains. Previously returned URLs are not rewritten retrospectively, so complete or stop active test journeys before disabling. Leave the ordinary console/demo services running. |
| + |
| +## Switch-on |
| + |
| +1. **Dev, landing day:** inspect the current routes, fleet/ingress inventory and console configuration through console/CLI before choosing destinations. Checked-in evidence names dev console box `carlos-dev-ie` (`README.md:280`; the deployment file calls it sophie at `/home/paulca/amadan.net/carlos/platform-infrastructure/dev/region-ie.tf:24`). These are topology hints, not live verification. Set `SITE_ORIGIN` to the actual dev static-site origin and `CONSOLE_ORIGIN` to the configured canonical dev console origin, currently documented as `https://platform.dev.carlosframework.com` (`README.md:282`). Preserve the site's existing claim, static release and region placement. |
| +2. Roll the reviewed edge binary to **every public site ingress in every region and the console home edge**, then the console binary, following dev-first release ordering (`README.md:276`). No demo-worker roll or mesh-key grant is needed for this feature. Install root-owned console drop-in `40-demo-api.conf` containing `Environment="CONSOLE_DEMO_API_ORIGIN=<SITE_ORIGIN>"`; daemon-reload/restart through the deployment's existing operator workflow. Then install the edge drop-in of the same name on those ingresses with `Environment="CARLOS_DEMO_API_ORIGIN=<SITE_ORIGIN>"` and `Environment="CARLOS_DEMO_API_CONSOLE_ORIGIN=<CONSOLE_ORIGIN>"`; daemon-reload/restart. Settings ride this roll, not a new polling loop. Keep `CONSOLE_ORIGIN`, demo admission/protection and worker console URLs unchanged. |
| +3. Through each ingress, using the new binaries and actual TLS host, verify `/start`, an unknown API path's plain 404, create/status/update, console 413/429, no cookies/cache, actual originating IP and missing-console 503. Confirm a region without the console route forwards directly to its home. Keep cloud-agent egress allowlisted to the site only. Use an existing authorized dev demo and clean up this witness through existing APIs; do not create infrastructure under this plan without scoped approval (`AGENTS.md:129`). This authoring task grants no rollout permission. |
| +4. Amend Plan 4 as Task 1 specifies. Its later website build uses `CARLOS_START_SITE_ORIGIN=<SITE_ORIGIN>`, `CARLOS_START_DEMO_API_ORIGIN=<SITE_ORIGIN>` and retains `CARLOS_START_CONSOLE_ORIGIN=<CONSOLE_ORIGIN>`. Public claim instructions wait for Plan 3 to merge, the four-path follow-up, and its contract tests. That follow-up is code, not a mutable operator allowlist, and does not reopen Plan 3's design. |
| +5. **Flagship, later operator step only:** public site operator value is `https://carlosframework.com`; obtain the current canonical console origin from deployed configuration, never infer it from the site or historic DNS. Historical deployment files place the console in IE (`/home/paulca/github.com/carlosframework/carloku-infrastructure/region-ie.tf:64`) and describe old console names (`README.md:29` in that repo); do not treat those as current. After separately scoped rollout approval, repeat ingress-wide settings/readiness checks, set console `CONSOLE_DEMO_API_ORIGIN=https://carlosframework.com`, and use that same value for edge `CARLOS_DEMO_API_ORIGIN` and Plan 4's site/demo API origins. Apply release-tag/module rules where relevant (`AGENTS.md:515`). This removes the second host from the agent journey, not the console service or its human browser host. |
| + |
| +## Review budget and self-review |
| + |
| +Independent review rounds used: **0**. No agents ran. Carry this count and findings by invariant into briefs using `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md:12`; for a Codex author, use Opus or Fable for authority/census review. Stop at the first round with no P1, apply P2 fixes without another general round, retain the census/new-security checks, and list P3 follow-ups. Maximum three rounds; two consecutive rounds in one fault family invoke the stop-and-choose rule (`AGENTS.md:44`). Do not review against unmerged Plan 3. |
| + |
| +Self-review: requirements a/e/j map to Task 1 and the path/authority decisions; b/c/d/f/i to Task 2 and Task 3's real transport witnesses; g/h to Task 3 and Switch-on. Each Review Focus has a named test. Origin fields, allowlist and response policy agree across tasks. No product bodies are specified, no generic proxy framework is introduced, and every new runtime state is process-local. Existing Plan 1/2 rulings remain settled, including never-reused demo hosts and the shared edge-proof cache exception (`docs/superpowers/notes/agent-start-demo-1-rulings.md:27`; `docs/superpowers/notes/agent-start-demo-2-rulings.md:38`). |
| + |
| +## Open questions |
| + |
| +None for Paul. The topology inventory and scoped rollout approval are execution prerequisites, not undecided product behavior. |
diff --git a/docs/superpowers/plans/REVIEW-BRIEF-DEMO-API-SITE-ROUTE-R1.md b/docs/superpowers/plans/REVIEW-BRIEF-DEMO-API-SITE-ROUTE-R1.md| new file mode 100644 |
| index 000000000..923c0a2ce |
| --- /dev/null |
| +++ b/docs/superpowers/plans/REVIEW-BRIEF-DEMO-API-SITE-ROUTE-R1.md |
| @@ -0,0 +1,107 @@ |
| +# Review brief: demo API site route plan, round 1 of 3 |
| + |
| +Repo carlos/platform, branch `demo-api-site-route`, worktree |
| +`/home/paulca/amadan.net/carlos/platform/.claude/worktrees/demo-api-site-route`. |
| +Under review: `docs/superpowers/plans/2026-11-05-demo-api-site-route.md` |
| +(a plan, written by Astra). The commit is named in your prompt. |
| +Authorities: `docs/superpowers/specs/2026-11-02-agent-start-demo-design.md`, |
| +Plans 1, 2 and 4 under `docs/superpowers/plans/`, and |
| +`docs/superpowers/notes/agent-start-demo-{1,2}-rulings.md`, all merged on main. |
| +Plan 3 (`agent-start-demo-3`) is not merged. Do not review against it. The |
| +plan uses it only as a future path inventory, with claim paths arriving in a |
| +follow-up; that is the agreed shape, not a finding. |
| + |
| +You are an independent reviewer. Read the document, then the code it names, and |
| +check every claim against that code. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul's ruling, 2026-11-05, #527: "put the demo API under carlosframework.com |
| + itself, so the site host serves /api/demo/* (a platform route/alias from the |
| + website host to the console's demo endpoints, done the platform way, not a |
| + workaround in the website) and the second host goes away." |
| +- Requirements from the program controller: a general platform capability, not |
| + a special case for one site in core; configured as data or an operator |
| + setting; provider-neutral; off by default; only the anonymous demo and claim |
| + API forwarded, nothing authenticated or cookie-bearing; no cookies either way; |
| + X-Carlos-Client and Authorization bearer pass through; the real client IP, |
| + unspoofable, for per-IP limits; body and rate limits unchanged; status and |
| + Retry-After pass through; never cached. |
| +- Plan 1 and 2 rulings in the notes above. |
| + |
| +## What to check |
| + |
| +1. **The IP chain.** Walk it in code for same-box and cross-box delivery, and |
| + for a source ingress with no console route. Is the plan's description of the |
| + hop, the XFF handling and the edge signature true at |
| + `internal/edge/edge.go`, `homemap.go`, `forwardproof.go` and |
| + `internal/console/authcli.go:1200`? Can a client, or a tenant process on a |
| + box, spoof attribution or get a chain signed? Does the proof gate in Task 1 |
| + break a legitimate path (fixed boxes, keys not yet cached, a direct console |
| + request with the setting on, health checks)? |
| +2. **The dispatch point.** Does a hook after `acceptHop` and scrubbing, before |
| + `lookupUpstreamPath`, actually run first on every ingress? What runs earlier |
| + in `ServeHTTP` (ACME, redirect to HTTPS, regional gate, demo host handling) |
| + that would intercept or mis-handle these requests? Does the console-host arm |
| + ("the configured console's allowlisted API requests") change direct console |
| + behaviour for people who use the console host, or when the alias is on? |
| +3. **The destination.** Is `homes.ExactHome(consoleHost)` populated for the |
| + console's own host on an ingress in another region? Does `hopTo` take the |
| + hooks claimed? Does a console served by replicas, HA pools or more than one |
| + box still resolve? Is the local "exact console route" test real? |
| +4. **Authority.** Does `domainHostPolicy` treat a configured host as described, |
| + and does that break the site's existing attach, publish or deploy flow (the |
| + site's ordinary static deploys must keep working for its owner)? Is the |
| + console setting enough, or can a tenant still reach the alias host by another |
| + path? Can a tenant make their own host the alias? |
| +5. **Delivery.** Do `Environment=` drop-ins named `40-demo-api.conf` survive |
| + named-unit config delivery and rewrites as claimed? Does the plan mis-state |
| + `hostenv`? Do the units named exist under those names? Is the proof check |
| + of "edge restarts" honest about downtime (see AGENTS.md if relevant)? |
| +6. **Bypassed layers.** The plan bypasses burst limits, request protection, |
| + password gates, usage metering and caches for these paths. Is an abuser better |
| + off through the alias than through the console host today? Is any |
| + layer missed, such as `Accept` negotiation, analytics or edge request logs that |
| + might record a token in a path or header? Could a job ID or token leak? |
| +7. **Generality and scope.** Is this general enough to count as a platform |
| + capability? Is it over-built: can anything be cut (the plan is meant to be |
| + short, three tasks)? Is any test in the plan impossible to write as named, or |
| + any interface wrong (`hopTo`, `EnableStatic`, `ArmHomeMap`, |
| + `forwardha_export_test.go`, `console.NewServer`)? |
| +8. **The agent contract.** Does Plan 4's amendment actually mean an agent never |
| + needs the console host for create, update, status and (after follow-up) |
| + claim? What else in a response or error sends an agent to the console host? |
| + Does `verifyStartOrigin` or the starter need anything else? |
| +9. **Census and rollout.** Are the census expectation and the Switch-on steps |
| + right? Does anything need a roll order the plan misses, such as an edge with the |
| + setting on before the console has its reservation? The build controller does not |
| + release or touch boxes; the program controller does. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |