fix: census rows, approved operator copy, demo HTTPS redirect
Pin the reviewed record-write sites and unchanged group-name classes. Apply the supplied operator copy and redirect eligible HTTP demos to HTTPS. Fix inline report styling and role recording, and let the integration witness use the runner's scratch filesystem. Generate the redirect census proposal with the repository tool. Validated targeted tests, census and CLI checks, touched-package vet, formatting, the native build and all five cross-compiles. No push.
README.md+25 −25docs/site/cli.md+6 −6docs/superpowers/notes/census-proposal-agent-start-demo-2-fix-wave.md+15 −0internal/console/apidemooperator.go+1 −1internal/console/apidemoreports.go+11 −2internal/console/demo_gate_test.go+0 −1internal/console/demo_operator_test.go+16 −1internal/console/demo_protections_e2e_test.go+2 −3internal/console/demo_reports_test.go+12 −1internal/console/svcroutes_test.go+26 −0internal/console/templates/demo_report.html+1 −2internal/edge/demo.go+19 −2internal/edge/demo_traffic_test.go+15 −5internal/edge/edge.go+1 −1internal/host/group_names_test.go+10 −8internal/provision/agent_start_demo_2_census_test.go+20 −0internal/provision/plan9_b8_census_test.go+1 −1internal/provision/testdata/plan14-root-reads-agent-start-demo-2-fix-wave.tsv+6 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0system_demos_test.go+3 −0
Intent
<task-notification> <task-id>bo8lkp069</task-id> <tool-use-id>toolu_01DuFdEcdws19G48i6d6LAgb</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/6e566fe9-9aca-47cb-9753-64e881b0d285/tasks/bo8lkp069.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 6 Codex run" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bms5929jh</task-id> <tool-use-id>toolu_013Gvkc1XHM4UpqXDZeYSKSE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/6e566fe9-9aca-47cb-9753-64e881b0d285/tasks/bms5929jh.output</output-file> <status>completed</status> <summary>Background command "Wait for Luna pass 2" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>aa2ee66dfd185e28d</task-id> <tool-use-id>toolu_019WTDK4htdG1B9HYmcuWUaC</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/6e566fe9-9aca-47cb-9753-64e881b0d285/tasks/aa2ee66dfd185e28d.output</output-file> <status>completed</status> <summary>Agent "Whole-branch + census review (Opus)" 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>**Verdict: READY AFTER FIXES.** One test fails at the tip; the rest of the branch looks sound. **Census verdict: APPROVE.** All 24 changed units and all 7 re-pinned envelopes are approved at `ed6a19ee`. `make census-card` reports the census clean at seal `4cbf6f01…`. Root's only demo consumer, the purge in `internal/instancectl`, is unchanged. The new signed early-retirement receipt is checked by the agent, never by root. **Counts:** P1 1, P2 0, P3 6. - **P1-1:** `TestPlan9B8RecordWriteCensus` fails at the tip, so CI's `go test ./...` will be red. This is the record-write census (a separate inventory from the census above), and the branch added no inventory rows for it. - `authcli.go` `Server.registerCLIRoutes` no longer matches its reviewed digest, because it now registers the demo operator routes. - `demo_traffic.go` `Edge.serveDemoTraffic` has an unlisted `sel:Put` site. It is a `gzipPool.Put`. - **Fix:** add a branch census test file that re-pins `registerCLIRoutes` as `key-site` and lists `serveDemoTraffic` as `nonrecord`. I'd approve both classifications. - The Task 6 report's census checks did not cover this test. Other results: - **Task 6 witnesses:** `TestDemoProtectionsSourceToLimitAndTakedown` passes outside the sandbox (the sandbox blocks unix sockets). `TestDemoMovedHookInert`, `TestDemoProtectionsOrdinaryUnchanged` and `TestDemoProtectionsNoBucketTraffic` pass. The `TestDemo` tests in edge, host, demo and demobuild pass, and so does `TestSystemDemos`. My broad console run hit the 10-minute timeout in an unrelated test and is inconclusive; it printed no failures. - **Wiring and safety:** the resident runs the planned order: identity and control, request debit, dispatch, policy and banner, compression, byte debit, output. Forwarding ingresses neither count nor rewrite. No path serves a demo without policy, a counter row and a live control. Plan 1 demos (R9) stay closed and can still be taken down. I found no new storage or polling on the traffic, status or switch paths; the report-path key cache is the ruled exception. - **Deferred minors:** none needs fixing before merge. - **P3s (follow-up list):** - Port 80 tells every demo visitor "try again shortly" forever. - The integration test wires the worker by hand rather than through `runAgent`. - Acknowledgements identify a revision only, not the control that carried it. - A console database restored to an older revision keeps boxes closed until it catches up. - Operator status runs several queries per demo row. - The `systemUsage` line for demos omits `reports`. Under the stopping rules this round has a P1, so round 2 should be a scoped check that `go test ./internal/provision -run Census` passes once the rows are added. The full review is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-2/.superpowers/sdd/2026-11-04-agent-start-demo-2-edge-protections/branch-review-r1.md`. Scratch logs are deleted.</result> <usage><subagent_tokens>291152</subagent_tokens><tool_uses>74</tool_uses><duration_ms>1511159</duration_ms></usage> </task-notification>
<task-notification> <task-id>bbz3blog3</task-id> <tool-use-id>toolu_01KPiHQ55CDzPPceNU1JSvnn</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/6e566fe9-9aca-47cb-9753-64e881b0d285/tasks/bbz3blog3.output</output-file> <status>completed</status> <summary>Background command "Ledger branch review, launch final fix wave" completed (exit code 0)</summary> </task-notification>
diff --git a/README.md b/README.md| index 457a93e0f..25a9e7ca9 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -603,50 +603,50 @@ This release adds the app policy (#328, #329). A system operator can let an app' |
| <!-- DEMO-OPERATOR-DOCS: approved by delegation, Luna copy pass, 2026-11-03 (R22). --> |
| ### Anonymous demo apps in development |
| -Anonymous demos accept a locked Go source archive and keep a local SQLite database for 24 hours. Updates keep the same expiry and database. There are no backups, and data is not recoverable after box loss. Demos cannot send mail, use object storage or schedules, run sidecars, or use custom domains. Claiming is not available in this release. |
| +Anonymous demos accept a locked Go source archive and keep a local SQLite database for 24 hours. Updates keep the same expiry and database. There are no backups, and data cannot be recovered after box loss. Demos cannot send mail, use object storage or schedules, run sidecars, or use custom domains. Claiming is not available in this release. |
| -Keep admission and serving off until the designated dev witness and branch review have passed. Local protocol tests do not prove systemd isolation, public DNS or TLS. Infrastructure work needs approval for its exact scope before you create or change anything. |
| +Keep admission and serving off until the designated dev witness and branch review pass. Local protocol tests do not prove systemd isolation, public DNS, or TLS. Infrastructure work needs approval for its exact scope before anything is created or changed. |
| -Use a dedicated non-ops holding account with no human members or service credentials. It must own only the demo fleet. The fleet must be empty when you first enable admission, with no ordinary apps or orphaned app objects. Demos stay on their assigned box. Run nested linux-arm64 boxes with host claims off. Root applies the small tier and denies outbound networking to every instance on a demo box. Do not share that fleet with ordinary apps. |
| +Use a dedicated non-ops holding account with no human members or service credentials. It must own only the demo fleet. The fleet must be empty when admission is first enabled. It must contain no ordinary apps or orphaned app objects. Demos stay on their assigned box. Run nested linux-arm64 boxes with host claims off. Root applies the small tier and denies outbound networking to every instance on a demo box. Do not share this fleet with ordinary apps. |
| Set these variables on the console: |
| | Variable | Setting | |
| | --- | --- | |
| -| `CARLOS_DEMO_APPS` | `1` enables admission; leaving it unset keeps admission off. | |
| +| `CARLOS_DEMO_APPS` | `1` enables admission. Leave it unset to keep admission off. | |
| | `CARLOS_DEMO_ACCOUNT` | The dedicated holding account's sqid. | |
| | `CARLOS_DEMO_FLEET` | The fleet owned by that account. | |
| -| `CARLOS_DEMO_DOMAIN` | Your bare demo domain, for example `demo.example.com`. It must not overlap the console, primary apps zone or another domain claim. | |
| +| `CARLOS_DEMO_DOMAIN` | Your bare demo domain, for example `demo.example.com`. It must not overlap the console, primary apps zone, or another domain claim. | |
| | `CARLOS_DEMO_CREATE_PER_IP_DAY` | Positive integer. Default `30`. IPv6 callers share their /64 budget. | |
| | `CARLOS_DEMO_CREATE_GLOBAL_DAY` | Positive integer. Default `100`. | |
| | `CARLOS_DEMO_MAX_LIVE` | Positive integer. Default `20`. Failed and retiring demos keep their place until cleanup completes. | |
| -| `CARLOS_DEMO_EDGE_PROTECTIONS` | `1` enables protections. Unset keeps demos closed. Set it on the console and every demo ingress and serving box. | |
| +| `CARLOS_DEMO_EDGE_PROTECTIONS` | `1` enables protections. Leave it unset to keep demos closed. Set it on the console and every demo ingress and serving box. | |
| | `CARLOS_DEMO_REQUEST_CAP` | Lifetime requests, from `1` to `1000000`. Default `2000`. | |
| | `CARLOS_DEMO_BANDWIDTH_CAP_BYTES` | Lifetime body bytes, from `1` to `10000000000`. Default `200000000` (200 MB, with 1 MB = 1,000,000 bytes). | |
| -Create the holding account and its demo fleet. Revoke all of the account's CLI and service tokens through its service pages, including expired tokens. Only an owner can revoke them, so do this before removing the last owner. Then run `console member -remove <address> "$CARLOS_DEMO_ACCOUNT"` on the console box for each member, leaving the owner until last. Use the console's environment with valid demo settings. You can leave `CARLOS_DEMO_APPS` unset while preparing the account. Only the configured holding account can lose its last owner. It must own `CARLOS_DEMO_FLEET`. The command refuses to remove the last owner while any tokens remain unrevoked and lists them. It reports when no members remain. |
| +Create the holding account and its demo fleet. Revoke all CLI and service tokens for the account through its service pages, including expired tokens. Only an owner can revoke them, so do this before removing the last owner. Then run `console member -remove <address> "$CARLOS_DEMO_ACCOUNT"` on the console box for each member, leaving the owner until last. Use the console's environment with valid demo settings. You can leave `CARLOS_DEMO_APPS` unset while preparing the account. Only the configured holding account can lose its last owner. It must own `CARLOS_DEMO_FLEET`. The command refuses to remove the last owner while any tokens remain unrevoked and lists them. It reports when no members remain. |
| -Put each demo box's settings in its root-owned `/etc/carlos/host.env`. Set `CARLOS_DEMO_BOX=1` and the same `CARLOS_DEMO_ACCOUNT`, `CARLOS_DEMO_FLEET` and `CARLOS_DEMO_DOMAIN` tuple as the console. Keep the box's existing `CARLOS_FLEET`, box identity, tunnel credentials and release public key consistent with that fleet. These are per-box authority settings. Preserve them through host.env rewrites, using the same per-box mechanism as `CARLOS_FLEET`; do not deliver them through shared or regional parameters. |
| +Put each demo box's settings in its root-owned `/etc/carlos/host.env`. Set `CARLOS_DEMO_BOX=1` and the same `CARLOS_DEMO_ACCOUNT`, `CARLOS_DEMO_FLEET`, and `CARLOS_DEMO_DOMAIN` tuple as the console. Keep the box's existing `CARLOS_FLEET`, box identity, tunnel credentials, and release public key consistent with that fleet. These are per-box authority settings. Preserve them through host.env rewrites with the same per-box mechanism as `CARLOS_FLEET`. Do not deliver them through shared or regional parameters. |
| -On each designated builder, also set `CARLOS_DEMO_BUILD_WORKER=1`, `CARLOS_DEMO_BUILD_CONCURRENCY=1`, `CARLOS_DEMO_TOOLCHAIN_DIR` to its absolute immutable bundle directory, and `CARLOS_DEMO_CONSOLE_URL` to the console's HTTPS origin, for example [https://console.example.com](https://console.example.com). Preserve these per-box values through rewrites too. Concurrency accepts values from `1` through `4`; each build needs a 1 GiB memory allowance, so keep `1` until the box has capacity for more. The console URL must be the console origin, not the tunnel hostname or the operator's CLI setting. |
| +On each designated builder, also set `CARLOS_DEMO_BUILD_WORKER=1`, `CARLOS_DEMO_BUILD_CONCURRENCY=1`, `CARLOS_DEMO_TOOLCHAIN_DIR` to its absolute immutable bundle directory, and `CARLOS_DEMO_CONSOLE_URL` to the console's HTTPS origin, for example [https://console.example.com](https://console.example.com). Preserve these per-box values through rewrites. Concurrency accepts values from `1` through `4`. Each build needs a 1 GiB memory allowance, so keep it at `1` until the box has capacity for more. The console URL must be the console origin, not the tunnel hostname or the operator's CLI setting. |
| -Build the toolchain bundle on the operator side before enabling a worker. Use native linux-arm64 Go 1.26.10 and the Rastrillo v0.30.2 dependency closure in `internal/demobuild/toolchain.lock.json`. Copy the Go distribution into the bundle root, the complete module cache into `mod/`, and a cache prewarmed by an offline build of `internal/console/testdata/demo` into `cache/`. Include Fiesta as embedded starter assets when needed; it is not a Go module. The starter contract permits only standard-library and pinned Rastrillo imports, exact locked module requirements and sums, and no vendor tree, toolchain directive, generator or alternate dependency inputs. |
| +Build the toolchain bundle on the operator side before enabling a worker. Use native linux-arm64 Go 1.26.10 and the Rastrillo v0.30.2 dependency closure in `internal/demobuild/toolchain.lock.json`. Copy the Go distribution into the bundle root, the complete module cache into `mod/`, and a cache prewarmed by an offline build of `internal/console/testdata/demo` into `cache/`. Include Fiesta as embedded starter assets when needed. It is not a Go module. The starter contract permits only standard-library and pinned Rastrillo imports, exact locked module requirements and sums, and no vendor tree, toolchain directive, generator, or alternate dependency inputs. |
| -Make the directory and its ancestors root-owned and safe from agent writes. Bundle files must be regular files with mode `0444` or `0555`; symlinks, hard links and unlisted files are refused. Write `MANIFEST` with LF endings and a final LF. Its first lines are `go<TAB>1.26.10` and `modules<TAB><Lock.ModulesDigest()>`. Follow them with one tab-separated row per file other than `MANIFEST`, sorted by relative path: relative path, four-digit octal mode, decimal size, lowercase SHA-256. `Lock.ModulesDigest()` hashes the canonical dependency lock; the worker's bundle digest separately hashes the exact manifest bytes. `host.CheckDemoToolchain` checks the entire bundle, then worker initialization must pass the nested isolation check and compile its trusted probe in the disposable offline service. There is no download fallback. To replace a bundle, drain builds, install a new immutable directory, update the per-box path and restart root control. |
| +Make the directory and its ancestors root-owned and safe from agent writes. Bundle files must be regular files with mode `0444` or `0555`. Symlinks, hard links, and unlisted files are refused. Write `MANIFEST` with LF endings and a final LF. Its first lines are `go<TAB>1.26.10` and `modules<TAB><Lock.ModulesDigest()>`. Follow them with one tab-separated row per file other than `MANIFEST`, sorted by relative path: relative path, four-digit octal mode, decimal size, lowercase SHA-256. `Lock.ModulesDigest()` hashes the canonical dependency lock. The worker's bundle digest separately hashes the exact manifest bytes. `host.CheckDemoToolchain` checks the entire bundle. Worker initialization must then pass the nested isolation check and compile its trusted probe in the disposable offline service. There is no download fallback. To replace a bundle, drain builds, install a new immutable directory, update the per-box path, and restart root control. |
| -On every ingress box for the demo domain and every box that can become the housekeeper, set the same `CARLOS_DEMO_ACCOUNT`, `CARLOS_DEMO_FLEET` and `CARLOS_DEMO_DOMAIN` in root-owned `/etc/carlos/host.env`, without `CARLOS_DEMO_BOX`. Preserve these per-box values through host.env rewrites. The housekeeper is the deployment's certificate issuer and orders the demo wildcard. Give every box that can hold that role the DNS-01 grant on the demo zone, even if it does not serve ingress traffic. The edge reads these settings at startup, so restart `carlos-edge` on each affected box as part of the rollout after changing them. |
| +On every ingress box for the demo domain and every box that can become the housekeeper, set the same `CARLOS_DEMO_ACCOUNT`, `CARLOS_DEMO_FLEET`, and `CARLOS_DEMO_DOMAIN` in root-owned `/etc/carlos/host.env`, without `CARLOS_DEMO_BOX`. Preserve these per-box values through host.env rewrites. The housekeeper is the deployment's certificate issuer and orders the demo wildcard. Give every box that can hold that role the DNS-01 grant on the demo zone, even if it does not serve ingress traffic. The edge reads these settings at startup. Restart `carlos-edge` on each affected box after changing them. |
| -For this protection rollout, keep admission off in the console drop-in and roll the console first. Old consoles reject the new worker heartbeat. Run `carlos system demos serving off`, then roll every public ingress, housekeeper and demo serving box. Remove or drain any old ingress before opening serving. Confirm the existing housekeeper wildcard certificate covers the demo names. Use the deployment's existing certificate workflow; this rollout needs no new DNS or certificate resources. |
| +For this protection rollout, keep admission off in the console drop-in and roll the console first. Old consoles reject the new worker heartbeat. Run `carlos system demos serving off`, then roll every public ingress, housekeeper, and demo serving box. Remove or drain any old ingress before opening serving. Confirm that the existing housekeeper wildcard certificate covers the demo names. Use the deployment's existing certificate workflow. This rollout needs no new DNS or certificate resources. |
| -Set `CARLOS_DEMO_CONSOLE_URL` on every demo edge to the exact HTTPS origin in the console's `CONSOLE_ORIGIN`. A mismatched origin can break reporting. Preserve the per-box settings through host.env rewrites and restart affected edges. Verify the worker's `anonymous-demo-v1` readiness and bundle digest, policy lease and change delivery. |
| +Set `CARLOS_DEMO_CONSOLE_URL` on every demo edge to the exact HTTPS origin in the console's `CONSOLE_ORIGIN`. A mismatched origin can break reporting. Preserve the per-box settings through host.env rewrites and restart affected edges. Verify the worker's `anonymous-demo-v1` readiness and bundle digest, policy lease, and change delivery. |
| -Take down every existing Plan 1 demo through `carlos system demos takedown --host <host>`. Check `takedown-status` until cleanup is complete. Their earlier traffic was never counted, so they cannot be grandfathered or backfilled with zero counters. Once every serving path runs the protected version, run `carlos system demos serving on` and restore admission. The intended first activation is the approved dev rollout when this slice lands; wider activation waits for the later /start plans. |
| +Take down every existing Plan 1 demo through `carlos system demos takedown --host <host>`. Check `takedown-status` until cleanup is complete. Their earlier traffic was never counted, so they cannot be grandfathered or given fresh counters. Once every serving path runs the protected version, run `carlos system demos serving on` and restore admission. The intended first activation is the approved dev rollout when this slice lands. Wider activation waits for the later /start plans. |
| -For the smoke check, gzip a tar archive of the locked starter's files without a wrapper directory. Submit it without logging in to `POST /api/demo/apps` as `application/gzip`; the compressed limit is 5,000,000 bytes. Keep the returned claim token private. Both create and update return `202` with `jobId`, `name`, `statusUrl` and `expiresAt` (Unix seconds). Create also returns `claimToken`, `claimUrl` and `claimAvailable:false`. Send your harness name in `X-Carlos-Client`; the stored value is trimmed to 100 bytes. Poll `statusUrl` (`GET /api/demo/jobs/<jobId>`) until its `state` is `live`. The other states are `building`, `starting`, `failed` and `superseded`. An earlier job becomes `superseded` when a newer update is accepted, even if the earlier job was live. Use the new update's `statusUrl` to follow its progress. Then GET its exact HTTPS URL and check `X-Carlos-Version`. Write a SQLite value, submit changed source to the same POST endpoint with `Authorization: Bearer <claimToken>`, and verify that a new version serves the saved value. An update must not extend the 24-hour lifetime. An unavailable worker or failed policy check must refuse admission. If a worker has not reconnected after a console restart, create and update return `503` with `Retry-After: 15`. Retry after that many seconds; this refusal does not spend a create or update attempt. |
| +For the smoke check, gzip a tar archive of the locked starter's files without a wrapper directory. Submit it without logging in to `POST /api/demo/apps` as `application/gzip`; the compressed limit is 5,000,000 bytes. Keep the returned claim token private. Both create and update return `202` with `jobId`, `name`, `statusUrl`, and `expiresAt` (Unix seconds). Create also returns `claimToken`, `claimUrl`, and `claimAvailable:false`. Send your harness name in `X-Carlos-Client`; the stored value is trimmed to 100 bytes. Poll `statusUrl` (`GET /api/demo/jobs/<jobId>`) until its `state` is `live`. The other states are `building`, `starting`, `failed`, and `superseded`. An earlier job becomes `superseded` when a newer update is accepted, even if the earlier job was live. Use the new update's `statusUrl` to follow its progress. Then GET its exact HTTPS URL and check `X-Carlos-Version`. Write a SQLite value, submit changed source to the same POST endpoint with `Authorization: Bearer <claimToken>`, and verify that a new version serves the saved value. An update must not extend the 24-hour lifetime. An unavailable worker or failed policy check must refuse admission. If a worker has not reconnected after a console restart, create and update return `503` with `Retry-After: 15`. Retry after that many seconds. This refusal does not spend a create or update attempt. |
| -Run `CARLOS_DEMO_DEV_WITNESS=1 go test ./internal/host -run '^TestDemoDevKernelAndPurge$' -count=1 -v` only on an explicitly designated disposable, idle linux-arm64 systemd sandbox. Install the built binary and this checkout's unit templates first. The application witness needs no pre-existing demo drop-ins; the builder witness needs root control active with its worker switch off, concurrency one, and `CARLOS_DEMO_TOOLCHAIN_DIR` pointing at the verified bundle. The root release/adoption gate must be available for the purge witness. The test exercises application and builder isolation, root stop-before-delete, and the local protocol and durability checks. A skipped test is outstanding evidence, not a rollout pass. Real DNS, TLS and fleet activation still need a separately recorded deployment check. |
| +Run `CARLOS_DEMO_DEV_WITNESS=1 go test ./internal/host -run '^TestDemoDevKernelAndPurge$' -count=1 -v` only on an explicitly designated disposable, idle linux-arm64 systemd sandbox. Install the built binary and this checkout's unit templates first. The application witness needs no pre-existing demo drop-ins. The builder witness needs root control active with its worker switch off, concurrency one, and `CARLOS_DEMO_TOOLCHAIN_DIR` pointing at the verified bundle. The root release/adoption gate must be available for the purge witness. The test exercises application and builder isolation, root stop-before-delete, and local protocol and durability checks. A skipped test is outstanding evidence, not a rollout pass. Real DNS, TLS, and fleet activation still need a separately recorded deployment check. |
| -After the smoke check, unset `CARLOS_DEMO_APPS` unless persistent dev admission was approved. Retain the account, fleet and domain settings and keep cleanup workers running. The next healthy five-minute expiry pass retires demos at 24 hours. Protected edges refuse new requests at the original expiry and cancel active responses. Cleanup may take longer. Local DB, WAL, SHM, runtime and build scratch must be removed before the assigned box acknowledges cleanup. Bucket content and the initialization marker must be gone before the place is released. A disconnected box keeps its cleanup obligation until reconnect. It must not restart the expired demo. Confirm that the job is expired, the host no longer serves, and cleanup has completed before dismantling witness resources. Never reuse public demo hostnames. Keep minimal host tombstones after detailed history ages out. |
| +After the smoke check, unset `CARLOS_DEMO_APPS` unless persistent dev admission was approved. Retain the account, fleet, and domain settings, and keep cleanup workers running. The next healthy five-minute expiry pass retires demos at 24 hours. Protected edges refuse new requests at the original expiry and cancel active responses. Cleanup may take longer. Local DB, WAL, SHM, runtime, and build scratch must be removed before the assigned box acknowledges cleanup. Bucket content and the initialization marker must be gone before the place is released. A disconnected box keeps its cleanup obligation until it reconnects. It must not restart the expired demo. Confirm that the job is expired, the host no longer serves, and cleanup is complete before dismantling witness resources. Never reuse public demo hostnames. Keep minimal host tombstones after detailed history ages out. |
| #### Demo traffic and operator controls |
| @@ -661,19 +661,19 @@ carlos system demos reports --limit 50 |
| carlos system demos reports resolve --id <id> |
| ``` |
| -Admission controls new creates and updates. Serving off also stops existing demos and refuses creates and updates, while cleanup and reporting remain available. Check serving confirmation separately from cleanup. A stop is pending until the box acknowledges it or its control expires. Protected workers renew through the existing authenticated stream every 10 seconds, with at most 30 seconds of validity from their probe. Output writes have a five-second bound, so confirmation can take 35 seconds. Bytes already handed to the network cannot be recalled. Old workers have no such bound. Keep them drained; do not downgrade an offline box after it has acknowledged initialization. |
| +Admission controls new creates and updates. Serving off also stops existing demos and refuses creates and updates. Cleanup and reporting remain available. Check serving confirmation separately from cleanup. A stop is pending until the box acknowledges it or its control expires. Protected workers renew through the existing authenticated stream every 10 seconds, with at most 30 seconds of validity from their probe. Output writes have a five-second bound, so confirmation can take 35 seconds. Bytes already handed to the network cannot be recalled. Old workers have no such bound. Keep them drained. Do not downgrade an offline box after it has acknowledged initialization. |
| -Caps are saved when a lifetime is created. Changes affect new demos only. Updates, restarts and serving off/on preserve counters and the original 24-hour expiry. The assigned box commits each request before dispatch and body bytes before output. Bytes include inserted markup and final compression, but exclude HTTP/TLS framing and uploads. App assets, errors, all app methods and readiness requests count. HEAD and bodyless responses spend no body bytes. The fixed warning stylesheet, platform refusals and console reports are excluded overhead. |
| +Caps are saved when a lifetime is created. Changes affect new demos only. Updates, restarts, and serving off/on preserve counters and the original 24-hour expiry. The assigned box commits each request before dispatch and body bytes before output. Bytes include inserted markup and final compression, but exclude HTTP/TLS framing and uploads. App assets, errors, all app methods, and readiness requests count. HEAD and bodyless responses spend no body bytes. The fixed warning stylesheet, platform refusals, and console reports are excluded overhead. |
| -Failed delivery and short writes can spend allowance that the visitor never receives. There are no refunds. This keeps crash overservice at zero requests and zero bytes. A stream that reaches the byte cap is cut without an appended page; later requests receive 429. Status reports saved caps and lifecycle, not estimated usage. Exhaustion keeps data and the private token until the original expiry. Claiming is not available yet. |
| +Failed delivery and short writes can spend allowance that the visitor never receives. There are no refunds. This keeps crash overservice at zero requests and zero bytes. A stream that reaches the byte cap is cut without an appended page. Later requests receive 429. Status reports saved caps and lifecycle, not estimated usage. Exhaustion keeps data and the private token until the original expiry. Claiming is not available yet. |
| -A missing or corrupt local traffic database refuses serving. Never delete or recreate counters to restore allowance. A corrupt traffic database also blocks local retirement, so cleanup can stay pending until storage is repaired. Confirm purge before treating the demo as removed. Data has no backup, and a replacement box cannot grant a fresh allowance. |
| +A missing or corrupt local traffic database refuses serving. Never delete or recreate counters to restore allowance. A corrupt traffic database also blocks local retirement, so cleanup can remain pending until storage is repaired. Confirm purge before treating the demo as removed. Data has no backup, and a replacement box cannot grant a fresh allowance. |
| -The warning is removable by the app's own scripts or CSS. The Content Security Policy limits forms, connections, images and scripts to the same origin. Inline scripts, eval, workers, upgrades and active document types other than supported HTML are refused. Server cookie Domain attributes are removed; a cookie with an unparseable Expires attribute is dropped. Script-written parent-domain cookies remain a known limit. Keep the private claim link out of pages and reports. |
| +The warning is removable by the app's own scripts or CSS. The Content Security Policy limits forms, connections, images, and scripts to the same origin. Inline scripts, eval, workers, upgrades, and active document types other than supported HTML are refused. Server cookie Domain attributes are removed. A cookie with an unparseable Expires attribute is dropped. Script-written parent-domain cookies remain a known limit. Keep the private claim link out of pages and reports. |
| -Reports do not trigger automatic takedown or notifications. Review the queue and resolve each report separately. POST attempts have durable IP, host and global limits. GET and HEAD form requests spend no report-attempt budget and still need ordinary ingress abuse protection. Forwarded reports use the login path's shared edge-proof key cache: a refresh reads two existing key objects, at most once per 30 seconds after a successful load. Traffic, counters, status and the serving switch add no bucket calls. Retirement keeps its existing receipt, tombstone and cleanup work. Identifying report data is removed seven days after confirmed purge. |
| +Reports do not trigger automatic takedown or notifications. Review the queue and resolve each report separately. POST attempts have durable IP, host, and global limits. GET and HEAD form requests spend no report-attempt budget and still need ordinary ingress abuse protection. Forwarded reports use the login path's shared edge-proof key cache. A refresh reads two existing key objects at most once per 30 seconds after a successful load. Traffic, counters, status, and the serving switch add no bucket calls. Retirement keeps its existing receipt, tombstone, and cleanup work. Identifying report data is removed seven days after confirmed purge. |
| -During the approved dev check, submit a fresh source fixture, check its version, banner and policy through every ingress, and verify a saved SQLite value after an update. Use small caps on that fresh lifetime to check stream truncation and 429. Submit, list and resolve a report, switch serving off, then take the demo down and confirm purge. Check Chromium, Firefox and Safari separately; an unrun browser is outstanding evidence. Verify an ordinary app too. If any check fails, leave serving off and admission off while keeping cleanup running. Never roll back to unprotected serving. |
| +During the approved dev check, submit a fresh source fixture, check its version, banner, and policy through every ingress, and verify a saved SQLite value after an update. Use small caps on that fresh lifetime to check stream truncation and 429. Submit, list, and resolve a report. Switch serving off, then take the demo down and confirm purge. Check Chromium, Firefox, and Safari separately. An unrun browser is outstanding evidence. Verify an ordinary app too. If any check fails, leave serving off and admission off while keeping cleanup running. Never roll back to unprotected serving. |
| <!-- End DEMO-OPERATOR-DOCS. --> |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index 15ca15a65..3a87806db 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -2747,7 +2747,7 @@ owns. |
| Manage anonymous demos through your configured console. Ops account owners and |
| listed system operators can stop serving or remove an exact public demo host. |
| Check serving confirmation and cleanup separately. A protected worker can take up to |
| -35 seconds to confirm a stop; cleanup stays pending until the box acknowledges |
| +35 seconds to confirm a stop. Cleanup stays pending until the box acknowledges |
| its purge. Old workers must be drained and upgraded before activation. |
| ```sh |
| @@ -2764,16 +2764,16 @@ carlos system demos reports resolve --id <id> |
| Caps apply to one lifetime: 2,000 requests and 200,000,000 body bytes by default. |
| Changing the configured caps affects new demos. Turning serving on preserves |
| existing counters and never restores a retired demo. Remove old Plan 1 demos |
| -before activation; they cannot be backfilled with a fresh allowance. |
| +before activation. They cannot be given a fresh allowance. |
| Reports are listed oldest first, including resolved reports. Use `--after` with |
| an ID from the preceding page and `--limit` from 1 to 100. Resolving a report does |
| -not take its demo down. Recheck the first page when reviewing new arrivals; |
| -pagination is not a fixed snapshot. |
| +not take its demo down. Recheck the first page when reviewing new arrivals. |
| +Pagination is not a fixed snapshot. |
| -`status`, `serving`, `takedown` and `takedown-status` accept `--console` to choose |
| +`status`, `serving`, `takedown`, and `takedown-status` accept `--console` to choose |
| a console. `--host` requires the exact public demo hostname. Successful commands |
| -and pending operations exit 0, remote failures exit 1, and invalid arguments exit 2. |
| +and pending operations exit 0. Remote failures exit 1. Invalid arguments exit 2. |
| #### carlos system managed-fleets show |
diff --git a/docs/superpowers/notes/census-proposal-agent-start-demo-2-fix-wave.md b/docs/superpowers/notes/census-proposal-agent-start-demo-2-fix-wave.md| new file mode 100644 |
| index 000000000..1e551d016 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-agent-start-demo-2-fix-wave.md |
| @@ -0,0 +1,15 @@ |
| +# Census approval: agent-start-demo-2-fix-wave |
| + |
| +Ruling `census-ruling-agent-start-demo-2-fix-wave`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +Envelopes re-pinned: `internal/edge`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/edge/demo.go:Edge.redirectDemoRequest`: reads +whole:Route ×3; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `4cbf6f0184656467ec5d636632672e1210925d984e9682d0d8cd60a22bfbc3f2` → `22534a1666c574d30f86da73e7f6708b6ab2ec79994f217958bdc7cc67853245`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-agent-start-demo-2-fix-wave.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/console/apidemooperator.go b/internal/console/apidemooperator.go| index 7f9406378..54b0d542d 100644 |
| --- a/internal/console/apidemooperator.go |
| +++ b/internal/console/apidemooperator.go |
| @@ -14,7 +14,7 @@ import ( |
| ) |
| func (s *Server) registerDemoOperatorRoutes() { |
| - if !s.cfg.Demo.BoxMode() { |
| + if s.cfg.HostClaim { |
| return |
| } |
| s.registerDemoReportOperatorRoutes() |
diff --git a/internal/console/apidemoreports.go b/internal/console/apidemoreports.go| index 60244b03a..4426c3494 100644 |
| --- a/internal/console/apidemoreports.go |
| +++ b/internal/console/apidemoreports.go |
| @@ -9,6 +9,7 @@ import ( |
| "encoding/base64" |
| "errors" |
| "fmt" |
| + "html/template" |
| "net/http" |
| "net/url" |
| "strconv" |
| @@ -91,15 +92,23 @@ func (s *Server) demoReportOrigin() bool { |
| return err == nil && u.Scheme == "https" && u.Hostname() != "" && u.User == nil && u.Opaque == "" && u.Path == "" && u.RawQuery == "" && !u.ForceQuery && u.Fragment == "" && !strings.ContainsAny(s.cfg.Origin, "\\\r\n\t ") |
| } |
| func (s *Server) renderDemoReport(w http.ResponseWriter, status int, host, token, message string) { |
| + // Allow only the embedded console stylesheet under the report's CSP. |
| + var css strings.Builder |
| + if err := templates.ExecuteTemplate(&css, "fiesta_day", nil); err != nil { |
| + http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| + return |
| + } |
| + styleHash := sha256.Sum256([]byte(css.String())) |
| w.Header().Set("Cache-Control", "no-store") |
| w.Header().Set("Referrer-Policy", "same-origin") |
| w.Header().Set("X-Content-Type-Options", "nosniff") |
| w.Header().Set("X-Frame-Options", "DENY") |
| - w.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'") |
| + w.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'sha256-"+base64.StdEncoding.EncodeToString(styleHash[:])+"'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'") |
| _ = s.writeTemplate(w, status, "demo_report", struct { |
| Copy map[string]string |
| Host, Token, Message string |
| - }{demoReportCopy, host, token, message}) |
| + Style template.CSS |
| + }{demoReportCopy, host, token, message, template.CSS(css.String())}) |
| } |
| func (s *Server) demoReportError(w http.ResponseWriter, err error) { |
| status, key := 400, "refused" |
diff --git a/internal/console/demo_gate_test.go b/internal/console/demo_gate_test.go| index a4b93d54f..5c7177474 100644 |
| --- a/internal/console/demo_gate_test.go |
| +++ b/internal/console/demo_gate_test.go |
| @@ -106,7 +106,6 @@ func TestDemoProtectionsClaimsMode(t *testing.T) { |
| fx := newConsoleFixture(t) |
| fx.srv.cfg.Demo = demoTestConfig(t) |
| fx.srv.registerDemoRoutes() |
| - fx.srv.registerDemoOperatorRoutes() |
| fx.srv.cfg.SystemOperators = []string{"operator@example.com"} |
| token := cliToken(t, fx, "operator@example.com", "demo-claims") |
| if code, _, body := rawReq(t, "GET", fx.ts.URL+"/api/cli/system/demos", token, ""); code != 200 { |
diff --git a/internal/console/demo_operator_test.go b/internal/console/demo_operator_test.go| index 47bbb1dea..437f8cde1 100644 |
| --- a/internal/console/demo_operator_test.go |
| +++ b/internal/console/demo_operator_test.go |
| @@ -137,7 +137,6 @@ func TestDemoKillFence(t *testing.T) { |
| func TestDemoOperatorAuthority(t *testing.T) { |
| fx := newConsoleFixture(t) |
| fx.srv.cfg.Demo = demoTestConfig(t) |
| - fx.srv.registerDemoOperatorRoutes() |
| fx.srv.cfg.SystemOperators = []string{"operator@example.com"} |
| owner := cliToken(t, fx, "owner@example.com", "demo-owner") |
| if err := fx.st.AddMember(OpsAccountID, "owner@example.com", RoleOwner, time.Now()); err != nil { |
| @@ -193,6 +192,22 @@ func TestDemoOperatorAuthority(t *testing.T) { |
| t.Fatalf("non-demo host %q: %d %s", host, st, body) |
| } |
| } |
| + fx.srv.cfg.Demo = demo.Config{} |
| + for _, tc := range []struct{ method, path, body string }{ |
| + {"GET", "/api/cli/system/demos", ""}, |
| + {"PUT", "/api/cli/system/demos/serving", `{"enabled":true}`}, |
| + {"POST", "/api/cli/system/demos/takedown", `{"host":"shop.example.com"}`}, |
| + {"GET", "/api/cli/system/demos/takedown?host=shop.example.com", ""}, |
| + {"GET", "/api/cli/system/demos/reports", ""}, |
| + {"POST", "/api/cli/system/demos/reports/report/resolve", ""}, |
| + } { |
| + for _, token := range []string{owner, listed, member, svc, app, "forged", ""} { |
| + status, _, body := rawReq(t, tc.method, fx.ts.URL+tc.path, token, tc.body) |
| + if status != http.StatusNotFound { |
| + t.Fatalf("disabled demo door %s %s: %d %s", tc.method, tc.path, status, body) |
| + } |
| + } |
| + } |
| } |
| func TestDemoServingStreamConsole(t *testing.T) { |
diff --git a/internal/console/demo_protections_e2e_test.go b/internal/console/demo_protections_e2e_test.go| index 3a907b461..21e0de539 100644 |
| --- a/internal/console/demo_protections_e2e_test.go |
| +++ b/internal/console/demo_protections_e2e_test.go |
| @@ -115,9 +115,8 @@ func demoProtectionBuilds(t *testing.T, dir string) ([][]byte, []string, []strin |
| } |
| func TestDemoProtectionsSourceToLimitAndTakedown(t *testing.T) { |
| - if os.Getenv("TMPDIR") == "" || filepath.Clean(os.Getenv("TMPDIR")) == "/tmp" { |
| - t.Fatal("disk TMPDIR required") |
| - } |
| + // Use the runner's scratch filesystem, as demo_e2e_test does. A short |
| + // directory keeps Unix socket paths below sockaddr_un's limit. |
| dir, err := os.MkdirTemp(os.Getenv("TMPDIR"), "dp-") |
| if err != nil { |
| t.Fatal(err) |
diff --git a/internal/console/demo_reports_test.go b/internal/console/demo_reports_test.go| index 9a9a2d1d5..cd67be575 100644 |
| --- a/internal/console/demo_reports_test.go |
| +++ b/internal/console/demo_reports_test.go |
| @@ -1,6 +1,8 @@ |
| package console |
| import ( |
| + "crypto/sha256" |
| + "encoding/base64" |
| "encoding/hex" |
| "errors" |
| "fmt" |
| @@ -336,7 +338,6 @@ func TestDemoReportBudgets(t *testing.T) { |
| func TestDemoReportOperatorAuthority(t *testing.T) { |
| fx := newConsoleFixture(t) |
| fx.srv.cfg.Demo = demoTestConfig(t) |
| - fx.srv.registerDemoOperatorRoutes() |
| fx.srv.cfg.SystemOperators = []string{"operator@example.com"} |
| owner := cliToken(t, fx, "owner@example.com", "report-owner") |
| if err := fx.st.AddMember(OpsAccountID, "owner@example.com", RoleOwner, time.Now()); err != nil { |
| @@ -395,6 +396,16 @@ func TestDemoReportEscapingAndUniformRefusal(t *testing.T) { |
| if strings.Contains(w.Body.String(), "<script>") || !strings.Contains(w.Body.String(), "<script>") || !strings.Contains(w.Header().Get("Content-Security-Policy"), "default-src 'none'") { |
| t.Fatalf("escape %s", w.Body.String()) |
| } |
| + _, afterStyle, ok := strings.Cut(w.Body.String(), "<style>") |
| + css, _, closed := strings.Cut(afterStyle, "</style>") |
| + if !ok || !closed || css == "" || strings.Contains(w.Body.String(), "<link ") { |
| + t.Fatal("report must inline the console stylesheet") |
| + } |
| + styleHash := sha256.Sum256([]byte(css)) |
| + wantPolicy := "default-src 'none'; style-src 'sha256-" + base64.StdEncoding.EncodeToString(styleHash[:]) + "'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'" |
| + if got := w.Header().Get("Content-Security-Policy"); got != wantPolicy { |
| + t.Fatalf("report stylesheet policy = %q, want %q", got, wantPolicy) |
| + } |
| c, v := reportForm(t, s, d.Host) |
| v.Set("details", strings.Repeat("a", 1000)) |
| if w := reportPost(s, c, v, s.cfg.Origin, "192.0.2.1"); w.Code != 200 { |
diff --git a/internal/console/svcroutes_test.go b/internal/console/svcroutes_test.go| index da8c032bd..3fa8c1bab 100644 |
| --- a/internal/console/svcroutes_test.go |
| +++ b/internal/console/svcroutes_test.go |
| @@ -392,6 +392,17 @@ func TestRunDoorsTakeOnlyTheRunRole(t *testing.T) { |
| } |
| } |
| +// Demo operators are recorded even without demo configuration. Host-claim |
| +// consoles cannot run demos and must not register these doors. |
| +var demoOperatorDoors = []string{ |
| + "GET /api/cli/system/demos", |
| + "PUT /api/cli/system/demos/serving", |
| + "POST /api/cli/system/demos/takedown", |
| + "GET /api/cli/system/demos/takedown", |
| + "GET /api/cli/system/demos/reports", |
| + "POST /api/cli/system/demos/reports/{id}/resolve", |
| +} |
| + |
| // TestEveryCLIDoorNamesItsRoles is the default-deny guarantee for the |
| // /api/cli/ half. A door registered with plain mux.HandleFunc would not |
| // appear in cliRoles at all; a door registered with an accidental empty Set |
| @@ -451,6 +462,9 @@ func TestEveryCLIDoorNamesItsRoles(t *testing.T) { |
| } |
| } |
| wantClosed := append([]string(nil), closedDoors...) |
| + if !tc.hostClaim { |
| + wantClosed = append(wantClosed, demoOperatorDoors...) |
| + } |
| roles := tc.hostClaim && tc.regionHA |
| if tc.hostClaim { |
| wantClosed = append(wantClosed, hostClaimDoors...) |
| @@ -507,6 +521,18 @@ func TestEveryCLIDoorNamesItsRoles(t *testing.T) { |
| t.Errorf("%s: present=%v empty=%v, want present=%v and a role set", pattern, present, set.Empty(), tc.moves) |
| } |
| } |
| + for _, pattern := range demoOperatorDoors { |
| + if !wantRegistered[pattern] { |
| + t.Errorf("demo operator route missing from source: %s", pattern) |
| + } |
| + if tc.hostClaim { |
| + delete(wantRegistered, pattern) |
| + } |
| + set, present := s.cliRoles[pattern] |
| + if present == tc.hostClaim || (present && !set.Empty()) { |
| + t.Errorf("%s: present=%v empty=%v, want present=%v and no service roles", pattern, present, set.Empty(), !tc.hostClaim) |
| + } |
| + } |
| for pattern := range wantRegistered { |
| if _, ok := s.cliRoles[pattern]; !ok { |
| t.Errorf("%s: the source registers it, the server did not record it", pattern) |
diff --git a/internal/console/templates/demo_report.html b/internal/console/templates/demo_report.html| index be788db83..2c96e58c9 100644 |
| --- a/internal/console/templates/demo_report.html |
| +++ b/internal/console/templates/demo_report.html |
| @@ -4,8 +4,7 @@ |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <title>{{.Copy.title}}</title> |
| -<link rel="stylesheet" href="{{asset "rastrillo/tokens.css"}}"> |
| -<link rel="stylesheet" href="{{asset "rastrillo/day.css"}}"> |
| +<style>{{.Style}}</style> |
| </head> |
| <body> |
| <main> |
diff --git a/internal/edge/demo.go b/internal/edge/demo.go| index 481bad843..6336b4c3a 100644 |
| --- a/internal/edge/demo.go |
| +++ b/internal/edge/demo.go |
| @@ -3,6 +3,7 @@ package edge |
| import ( |
| "net" |
| "net/http" |
| + "net/url" |
| "os" |
| "strconv" |
| "strings" |
| @@ -78,12 +79,28 @@ func demoRefusalNames(m map[string]upstream, routes []registry.Route, aliases [] |
| return names |
| } |
| -// refuseDemoRequest runs before any response exit, including HTTP fallback. |
| -// HTTP fallback remains closed until Task 4 adds its HTTPS redirect gate. |
| +// refuseDemoRequest runs before ordinary fallback responses. |
| func (e *Edge) refuseDemoRequest(w http.ResponseWriter, r *http.Request) bool { |
| return e.handleDemoRequest(w, r, false) |
| } |
| +// Port 80 never dispatches or debits demo traffic. HTTPS checks the serving |
| +// gate again when the visitor follows the redirect. |
| +func (e *Edge) redirectDemoRequest(w http.ResponseWriter, r *http.Request) bool { |
| + host, valid := demoAuthority(r.Host) |
| + up, ok := e.lookupUpstreamPath(host, r.URL.Path) |
| + if !valid || !ok || !up.route.IsDemo() || !e.demoRouteOK(host, up.route) || up.alias || up.platformAlias || !e.demo.EdgeProtections || !e.demoTrafficAllowed(up.route) { |
| + return e.refuseDemoRequest(w, r) |
| + } |
| + r = r.Clone(r.Context()) |
| + r.Host = host |
| + w = e.beginDemoResponse(w, r) |
| + target := url.URL{Scheme: "https", Host: host, Path: r.URL.Path, RawPath: r.URL.RawPath, RawQuery: r.URL.RawQuery, ForceQuery: r.URL.ForceQuery} |
| + w.Header().Set("Location", target.String()) |
| + w.WriteHeader(http.StatusPermanentRedirect) |
| + return true |
| +} |
| + |
| func (e *Edge) handleDemoRequest(w http.ResponseWriter, r *http.Request, serve bool) bool { |
| host, valid := demoAuthority(r.Host) |
| marked := false |
diff --git a/internal/edge/demo_traffic_test.go b/internal/edge/demo_traffic_test.go| index f2bc9ab6a..1c48d9a3e 100644 |
| --- a/internal/edge/demo_traffic_test.go |
| +++ b/internal/edge/demo_traffic_test.go |
| @@ -482,12 +482,16 @@ func TestDemoServingHTTPAndStartupHook(t *testing.T) { |
| t.Fatal("metrics label used for demo ownership") |
| } |
| for _, method := range []string{"GET", "HEAD", "POST"} { |
| - rec := httptest.NewRecorder() |
| - e.httpFallbackHandler().ServeHTTP(rec, httptest.NewRequest(method, "http://"+rt.Host+"/shop", nil)) |
| - if rec.Code != 503 { |
| - t.Fatalf("plain HTTP status %d", rec.Code) |
| + for _, authority := range []string{rt.Host, strings.ToUpper(rt.Host) + ":80"} { |
| + for _, path := range []string{"/shop", "/shop%2Fitem?next=%2Fbasket", "//example.com/shop", "/shop?"} { |
| + rec := httptest.NewRecorder() |
| + e.httpFallbackHandler().ServeHTTP(rec, httptest.NewRequest(method, "http://"+authority+path, nil)) |
| + if rec.Code != http.StatusPermanentRedirect || rec.Header().Get("Location") != "https://"+rt.Host+path || rec.Body.Len() != 0 { |
| + t.Fatalf("plain HTTP %s %s%s: status=%d location=%q body=%q", method, authority, path, rec.Code, rec.Header().Get("Location"), rec.Body.String()) |
| + } |
| + assertDemoPolicy(t, rec.Header()) |
| + } |
| } |
| - assertDemoPolicy(t, rec.Header()) |
| } |
| if c.requests != 0 || c.bytes != 0 { |
| t.Fatal("plain HTTP counted") |
| @@ -499,6 +503,12 @@ func TestDemoServingHTTPAndStartupHook(t *testing.T) { |
| if e.demoTrafficAllowed(rt) { |
| t.Fatal("second startup hook reset retired state") |
| } |
| + rec := httptest.NewRecorder() |
| + e.httpFallbackHandler().ServeHTTP(rec, httptest.NewRequest("GET", "http://"+rt.Host+"/shop", nil)) |
| + if rec.Code != http.StatusServiceUnavailable || rec.Header().Get("Location") != "" || c.requests != 0 || c.bytes != 0 { |
| + t.Fatalf("closed HTTP gate: status=%d headers=%v counters=%+v", rec.Code, rec.Header(), c) |
| + } |
| + assertDemoPolicy(t, rec.Header()) |
| } |
| func TestDemoTrafficCancelOnlyRevokedLifetime(t *testing.T) { |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index fcf5d0442..886f21804 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -3281,7 +3281,7 @@ func (e *Edge) unknownHost(w http.ResponseWriter, r *http.Request) { |
| // handler, so a challenge request never reaches lookupUpstream at all. |
| func (e *Edge) httpFallbackHandler() http.Handler { |
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| - if e.refuseDemoRequest(w, r) { |
| + if e.redirectDemoRequest(w, r) { |
| return |
| } |
| host := r.Host |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 1bb72b48a..63aa467fc 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -357,14 +357,16 @@ func unrelated() { println("before") } |
| } |
| var groupNameProducerInventory = map[string]string{ |
| - "../domains/aliases.go:ReconcileAliasesReport": "c022beb479d23f0be5f0cb1c591daf9f479507bb7acd2fb9262c1392357c0c61", |
| - "../domains/aliases.go:deriveInstanceAliases": "47b40b392927d9c50cab6c350083af24565e4e148cd1b5ddc257e9803153c0c2", |
| - "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| - "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| - "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| - "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| - "../edge/assetcatch.go:*Edge.serveAssetFar": "7d358ec272ae74c05764504550bad461096a09d0bfcc108dcbe5485f8f68d643", |
| - "../edge/edge.go:*Edge.Reload": "9d7cfd08d252cea261fadfe2297d9081e8cafe5f8b4e63bbcf09ae85842091a8", |
| + "../domains/aliases.go:ReconcileAliasesReport": "c022beb479d23f0be5f0cb1c591daf9f479507bb7acd2fb9262c1392357c0c61", |
| + "../domains/aliases.go:deriveInstanceAliases": "47b40b392927d9c50cab6c350083af24565e4e148cd1b5ddc257e9803153c0c2", |
| + "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| + "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| + "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| + "../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", |
| "../edge/platformalias.go:PlatformAliasFold": "a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f", |
| "../edge/regional.go:*Edge.foldRegional": "b413fad6a8e17530ce0e99c79c521e0a6782b82c04d61d256442b8defe6a427b", |
| "../provision/forward.go:forwardRowFor": "e7294d6a3c96e51646257200f5cedb26aaf491afea23be3d943b3e3f742c4db4", |
diff --git a/internal/provision/agent_start_demo_2_census_test.go b/internal/provision/agent_start_demo_2_census_test.go| new file mode 100644 |
| index 000000000..2a722cac3 |
| --- /dev/null |
| +++ b/internal/provision/agent_start_demo_2_census_test.go |
| @@ -0,0 +1,20 @@ |
| +package provision |
| + |
| +// Branch review R1 approved both classifications. registerCLIRoutes only |
| +// adds demo operator route registration; its record-key literals are unchanged. |
| +// serveDemoTraffic returns a gzip writer to sync.Pool, not a record store. |
| +func agentStartDemo2WriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), statelessFailedReleaseWriteCensusInventory()...) |
| + found := false |
| + for i, entry := range entries { |
| + if entry.File == "internal/console/authcli.go" && entry.Unit == "Server.registerCLIRoutes" { |
| + entries[i] = censusEntry{"internal/console/authcli.go", "Server.registerCLIRoutes", "key-site", "lit:instances,lit:sidecars", "ed1ee587a5ea0bd31ac70972e9a72e61402bb709f37699473e217f007ad5e28d"} |
| + found = true |
| + break |
| + } |
| + } |
| + if !found { |
| + panic("missing prior registerCLIRoutes census entry") |
| + } |
| + return append(entries, censusEntry{"internal/edge/demo_traffic.go", "Edge.serveDemoTraffic", "nonrecord", "sel:Put", "edae18eed837b95f5e416950bfd5eabfe222ebf60ba1a26f65a1593b64077e44"}) |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index 54dce76f4..a8aea2c8c 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 := statelessFailedReleaseWriteCensusInventory() |
| + inventory := agentStartDemo2WriteCensusInventory() |
| 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 ")) |
diff --git a/internal/provision/testdata/plan14-root-reads-agent-start-demo-2-fix-wave.tsv b/internal/provision/testdata/plan14-root-reads-agent-start-demo-2-fix-wave.tsv| new file mode 100644 |
| index 000000000..0651a4fe3 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-agent-start-demo-2-fix-wave.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay agent-start-demo-2-fix-wave, written by census-propose (#369). census-ruling-agent-start-demo-2-fix-wave, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-agent-start-demo-2-fix-wave.md. |
| +# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 8a64ae4bfb70691f705caacaa380cae317cfdaeb194f0076c73582696ae4090d internal/edge/demo.go Edge.redirectDemoRequest legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2-fix-wave;basis=Reads the already-loaded Route for exact demo identity, alias refusal, protection flag and local serving gate. Emits only a policy-bearing 308 to the canonical HTTPS host with the original escaped path and query; no proxy dispatch, counter debit, storage lookup or new root input. HTTP fallback calls this before ordinary handling. whole:Route@195,whole:Route@237,whole:Route@331 2d21dbdbfc661b2ddbfc51644401931f934d7bb188c1178e11df397dc48e6cf9 |
| +internal/edge/demo.go Edge.redirectDemoRequest legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2-fix-wave;basis=Reads the already-loaded Route for exact demo identity, alias refusal, protection flag and local serving gate. Emits only a policy-bearing 308 to the canonical HTTPS host with the original escaped path and query; no proxy dispatch, counter debit, storage lookup or new root input. HTTP fallback calls this before ordinary handling. whole:Route@195,whole:Route@237,whole:Route@331 2d21dbdbfc661b2ddbfc51644401931f934d7bb188c1178e11df397dc48e6cf9 |
| +@coverage internal/edge 976284b56ef0901ed3f3bded8e62d8ad26b0d37be49a432a050af65f55943520 |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 5e514269b..2eebf2d23 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -92,3 +92,4 @@ plan14-root-reads-stateless-failed-release-held.tsv 657f81eeea52785b75f92a42064f |
| plan14-root-reads-static-markdown-twins.tsv ec831d3206622f34511bfbc2ec0cccb131fbd3861ec4c6a33a2dc6dff9a1791e |
| plan14-root-reads-agent-start-demo-1-followups.tsv ec831d3206622f34511bfbc2ec0cccb131fbd3861ec4c6a33a2dc6dff9a1791e |
| plan14-root-reads-agent-start-demo-2.tsv 4cbf6f0184656467ec5d636632672e1210925d984e9682d0d8cd60a22bfbc3f2 |
| +plan14-root-reads-agent-start-demo-2-fix-wave.tsv 22534a1666c574d30f86da73e7f6708b6ab2ec79994f217958bdc7cc67853245 |
diff --git a/system_demos_test.go b/system_demos_test.go| index 52f50aa0d..2f61e5b5f 100644 |
| --- a/system_demos_test.go |
| +++ b/system_demos_test.go |
| @@ -50,6 +50,9 @@ func TestSystemDemosRemote(t *testing.T) { |
| t.Fatal(err) |
| return "", -1 |
| } |
| + if out, code := run("help"); code != 0 || out != "Manage anonymous demos: status, serving on or off, takedown, takedown-status, and reports. Commands use your configured console.\n" { |
| + t.Fatalf("approved help: code=%d output=%q", code, out) |
| + } |
| for _, tc := range []struct { |
| args []string |
| request string |