carlos / platform Public

fix: whole-branch review round 1 for anonymous demos

codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev a2091e3961fb2b5765c886db3e85deac825ef1d0 parent e84d011
30 files changed, +835 −90
  • README.md +3 −1
  • docs/superpowers/notes/census-agent-start-demo-1-claims.md +3 −3
  • docs/superpowers/notes/census-proposal-agent-start-demo-1.md +3 −3
  • docs/superpowers/notes/copy-agent-start-demo-1.md +1 −1
  • internal/console/apidemo.go +73 −6
  • internal/console/apidemo_test.go +80 −7
  • internal/console/demo_e2e_test.go +139 −16
  • internal/console/demo_expiry.go +2 −1
  • internal/console/demo_expiry_test.go +47 −0
  • internal/console/demo_finishing_test.go +1 −1
  • internal/console/demo_jobs_test.go +136 −4
  • internal/console/demo_live_test.go +1 −1
  • internal/console/demo_settlement_r2_test.go +4 −4
  • internal/console/demo_settlement_test.go +4 −4
  • internal/console/server.go +2 −0
  • internal/console/testdata/demo-stdlib/main.go +36 −0
  • internal/host/agent.go +1 −1
  • internal/host/demo_cleanup.go +2 −2
  • internal/host/demo_jobs.go +71 −2
  • internal/host/demo_jobs_test.go +10 −4
  • internal/host/demo_policy.go +8 −1
  • internal/host/demo_policy_test.go +37 −2
  • internal/host/demo_retirement_stream_test.go +84 −9
  • internal/instancectl/client.go +10 −3
  • internal/instancectl/client_test.go +34 −0
  • internal/instancectl/demo_policy.go +5 −6
  • internal/instancectl/demo_policy_test.go +27 −0
  • internal/instancectl/server.go +3 −0
  • internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv +7 −7
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1

Intent

Human

<task-notification> <task-id>bgzrkxdsx</task-id> <tool-use-id>toolu_01ELd6UT4hJEXvYWiCpiYuHU</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/cd1b6de2-ac77-426f-a77d-fc5436969c88/tasks/bgzrkxdsx.output</output-file> <status>completed</status> <summary>Background command "Wait for delta apply and census refresh" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>ae1b3cd48a7d2c7e2</task-id> <tool-use-id>toolu_014SmVYUQwW5iudjBPGem4bq</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/cd1b6de2-ac77-426f-a77d-fc5436969c88/tasks/ae1b3cd48a7d2c7e2.output</output-file> <status>completed</status> <summary>Agent "Whole-branch review: wire area" 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** P1: none. P2: - P2-1: The README tells operators to set the `CARLOS_DEMO_ACCOUNT`/`CARLOS_DEMO_FLEET`/`CARLOS_DEMO_DOMAIN` settings on the console and the demo boxes, but not on the ingress box. That box's edge reads them from its own `/etc/carlos/host.env` (`internal/edge/demo.go:13-15`). Without them it drops every demo forward row (`demoRouteOK`, `edge.go:914`) and never sets up the wildcard certificate for the demo domain, so no demo is reachable. The fix is a README addition: the same three settings in the ingress box's host.env, without `CARLOS_DEMO_BOX`, kept through rewrites, then an edge restart. The end-to-end test hides this because it sets the settings for the whole test process (`demo_e2e_test.go:71-77`). Full review: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-1/.superpowers/sdd/2026-11-02-agent-start-demo-1-anonymous-apps/branch-review-r1-wire.md`</result> <usage><subagent_tokens>218340</subagent_tokens><tool_uses>71</tool_uses><duration_ms>931190</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a56285748861a9e97</task-id> <tool-use-id>toolu_01Uq8W4B4xx9Rx8xip4Tjr7J</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/cd1b6de2-ac77-426f-a77d-fc5436969c88/tasks/a56285748861a9e97.output</output-file> <status>completed</status> <summary>Agent "Whole-branch review: console area" 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>READY AFTER FIXES - P2-1: Every expiry pass bumps the deployment serial (a bucket PUT that wakes every box) for each retirement still waiting on its box (`demo_expiry.go:196`). With an offline or removed demo box, that repeats every five minutes with no end. Fix: bump only on the pass that writes the trash marker and receipt, and once after purge. - P2-2: With `CARLOS_DEMO_APPS=1`, a temporary bucket or registry error at boot kills the whole console. `validateDemoConfig` lists the domain claims and fleets, and `NewServer` failing is fatal (`apidemo.go:114-141`, `main.go:622`). Fix: keep the static checks fatal and move these live checks into the admission-readiness check. - P2-3: Create and update attempts are charged before the server checks for a connected worker and the policy writer lease (`apidemo.go:333-347` vs `:388-395`). During a worker outage, retrying agents can use up the 100/day global, per-IP and per-demo update budgets. Fix: check both read-only before charging. - P2-4: The create/update reply differs from the plan, with no ruling recorded: - It has no `name`, `expiresAt` or `statusUrl`. - It uses the keys `jobID` and `status` where the plan has `jobId` and `state`. - It stores `User-Agent` where the plan and spec say `X-Carlos-Client` (`apidemo.go:400`, `:418-422`, `:533`).</result> <usage><subagent_tokens>280464</subagent_tokens><tool_uses>77</tool_uses><duration_ms>1172952</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a7c7215d95b6cfa2b</task-id> <tool-use-id>toolu_014kmZPyXYt7qLjjK1erF2LT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/cd1b6de2-ac77-426f-a77d-fc5436969c88/tasks/a7c7215d95b6cfa2b.output</output-file> <status>completed</status> <summary>Agent "Whole-branch review: root area" 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 P1: none. P2-1 (box authority / root enforcement precondition): the agent decides it is on a demo box without checking that root control is in demo mode. Suppose a host.env rewrite drops the `CARLOS_DEMO_*` keys, which R16 warns about. The hourly root adopt pass then restarts root control in ordinary mode and removes the demo drop-ins (`systemunits.go:149,203`, `host/demo_policy.go:36-43`). The edge keeps its old environment until it restarts. Until then, existing demos wake under the ordinary template, with internet egress. The fix is either or both: - the agent refuses demo spawns unless root reports demo mode; - root in ordinary mode refuses a start for a host whose registry row is a demo. Census: all units and all 13 envelopes on the card approved, with cited lines. The census tests pass at e84d0114. Rerun `make census-propose` after the P2-1 fix. Full review: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-1/.superpowers/sdd/2026-11-02-agent-start-demo-1-anonymous-apps/branch-review-r1-root.md`</result> <usage><subagent_tokens>316926</subagent_tokens><tool_uses>113</tool_uses><duration_ms>2138940</duration_ms></usage> </task-notification>

Human

Still going?

Human

We definitely want to make Rastrillo fetchable. Do we mirror it on GitHub? Or can we use its Amadan https://amadan.net/rastrillo/rastrillo?

Human

<paseo-system version="1" kind="agent-message" source-agent-id="32157efb-ed29-443f-b428-8c9e3320fa50" message-id="38b1ed47-82ea-4bf3-be7e-cad8fec1b3e7"> From the design session (platform-f6), correcting Ruling R23&apos;s premise: Rastrillo is NOT private. amadan.net/rastrillo/rastrillo serves a go-import meta tag, anonymous git ls-remote works, and proxy.golang.org + sum.golang.org already serve v0.30.2 and money/v0.1.0 (checked 2026-11-03 18:05Z). So the CI failure of TestDemoSourceToLiveAndUpdate is an empty module cache under the deliberately offline build (GOPROXY=off), not access. Please replace the R23 stdlib stand-in: before the offline build, the test (or a CI pre-step) populates the module cache from the locked closure with a normal online &apos;go mod download&apos; (default proxy and sumdb, verifying the lock&apos;s sums), then the real starter builds offline as in production. If the download fails, the test fails loudly; no substitute fixture. Fold this into the current fix wave or the next commit; ledger it as R23b. </paseo-system>

Attributed to this commit: 29.9 g CO₂e (3,831,911 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on agent-start-demo-1, 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/README.md b/README.md
index 4360b62a2..65d75a52b 100644
--- a/README.md
+++ b/README.md
@@ -627,9 +627,11 @@ Build the toolchain bundle on the operator side before enabling a worker. Use na
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.
+On every ingress box that fronts the demo domain, 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. Configure the ingress DNS provider for the wildcard parent. The edge reads these settings at startup, so restart `carlos-edge` as part of the rollout after changing them.
+
For an approved rollout, point wildcard DNS for your demo domain at the existing ingress and install wildcard TLS through the deployment's existing certificate workflow. The edge includes `CARLOS_DEMO_DOMAIN` among its explicit wildcard parents. Roll out the built boxes and ingress first, then the console. Confirm the box reports `anonymous-demo-v1` with the expected verified bundle digest, the policy writer can acquire its lease, and change delivery is working before enabling admission. Verify an ordinary app through its own hostname as well.
-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. Poll `GET /api/demo/jobs/<jobID>` until it reports live. 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.
+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` and `failed`. 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.
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.
diff --git a/docs/superpowers/notes/census-agent-start-demo-1-claims.md b/docs/superpowers/notes/census-agent-start-demo-1-claims.md
index cf052a245..5eb450e4f 100644
--- a/docs/superpowers/notes/census-agent-start-demo-1-claims.md
+++ b/docs/superpowers/notes/census-agent-start-demo-1-claims.md
@@ -47,7 +47,7 @@ internal/edge/demo.go:Edge.lookupDemoAware Reads the current map and config; res
internal/edge/edge.go:Edge.Reload Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query.
internal/edge/edge.go:RunWithActivatorReady Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.
internal/edge/wildcard.go:newWildcardFromEnv Includes the configured demo domain in the existing wildcard manager's explicit parent input.
-internal/host/agent.go:runAgent Passes the existing registry, data store and hibernation prefix into the demo worker; no alternate data store.
+internal/host/agent.go:runAgent Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop.
internal/host/bootstrap.go:bootstrapWith Uses demo settings from the existing host.env parser; refuses malformed demo config and installs the fixed template drop-ins.
internal/host/claimstop_run.go:RunInstanceControl Wires demo registry views and existing root release/adoption guard into instance control.
internal/host/claimstop_run.go:instanceDemoPurgeGuard Uses existing root release/census state and adopt-pass lock before root deletion.
@@ -56,7 +56,7 @@ internal/host/claimunit.go:readClaimUnitSettings Reads worker/concurrency/toolch
internal/host/demo_cleanup.go:demoWorker.retireDemo Agent reads signed receipt, matching tombstone and registry binding; holds route, invokes root, acknowledges and removes only its remote initialization marker.
internal/host/demo_jobs.go:demoWorker.pickupHTTP Reads a bounded console pickup response; no bucket write or caller-selected execution input.
internal/host/demo_policy.go:demoDisabledFor Reads startup box configuration and the activator-held Route.IsDemo marker in memory, then the existing disabled-route predicate. Refuses a marked ordinary-box route without querying the registry.
-internal/host/demo_policy.go:demoPolicyHook Returns the original hook unchanged outside explicit demo mode, including nil: no registry read or new spawn refusal. In demo mode reads the route by host and the existing verified policy cache before the original hook.
+internal/host/demo_policy.go:demoPolicyHook Returns the original hook unchanged outside explicit demo mode. In demo mode reads the existing route and requires a fresh ReadyDemo verdict from the existing root control socket before checking the verified policy cache and calling the original hook. Missing capability, ordinary root mode, failed probe and stale build refuse the spawn.
internal/host/demo_policy.go:demoRouteGate Reads startup box/claims configuration and the caller-held route plus existing verified policy cache. Covers backend acquisition/probe preparation through ConfigGate without a new registry or bucket read.
internal/host/demo_policy.go:installDemoUnitsIn Reads the same fixed drop-in files in demo mode. Outside demo mode removes the same two fixed managed filenames; ENOENT is silent, other removal errors are logged and retried next pass without aborting ordinary installation or skipping the second file. Successful removal still signals daemon-reload. Enabled-demo read/write failures still refuse.
internal/host/demo_units/demo.conf:external Retains read-only /run and /var tmpfs overlays and all network/size restrictions. Resets InaccessiblePaths and restates /etc/carlos -/run/carlos-control so the hidden control directory need not exist during namespace setup; /etc/carlos remains required. No new source or bind.
@@ -67,7 +67,7 @@ internal/host/units/carlos-demo-builds.slice:external New aggregate compiler bud
internal/instancectl/demo_build.go:Client.DemoBuildReadiness Reads bounded root readiness and verifies capability, slots, digest and service build identity.
internal/instancectl/demo_cleanup.go:Server.purgeDemoWithJobs Checks root config and current registry identity/hold; reads derived unit/cgroup/exe/drop-in state, stops and proves emptiness before no-follow removal. Fix round 1: passes the descriptor host to the root build-scratch cleaner; same registry, cgroup and derived path reads.
internal/instancectl/demo_policy.go:Server.demoCgroup Reads memory.max, cpu.weight, cpu.max and io.weight beneath root cgroupfs using platform-generated slice/unit names; checks both slice and unit before reporting started.
-internal/instancectl/demo_policy.go:Server.demoHandler Serializes demo starts with purge and refuses missing/non-demo/held current routes.
+internal/instancectl/demo_policy.go:Server.demoHandler Serializes demo-mode starts with demo purge; ordinary starts retain their existing unit locking. Uses the existing HostDemo callback to read the fixed service registry for a valid requested host in ordinary mode too; read errors and any demo-marked row refuse that start. Demo mode retains missing/non-demo/held-row refusals. No caller-named filesystem path is opened.
internal/instancectl/demo_versions.go:Server.purgeDemoVersions Derives account/app from root config and host; reads registry/live/generation pins and staged entries; deletes only unreferenced demo app files. Fix round 1: logs and skips ENOENT resolving another live link; other errors still refuse, same pin and symlink reads.
internal/instancectl/gen.go:Server.handleParent Reads fixed DemoBox and clamps the existing parent memory writer to small.
internal/instancectl/rootfs.go:Server.runRootfsProbe Reads DemoBox and refuses before preparing or launching a rootfs probe; ordinary probe behavior unchanged.
diff --git a/docs/superpowers/notes/census-proposal-agent-start-demo-1.md b/docs/superpowers/notes/census-proposal-agent-start-demo-1.md
index 1e8a69ca7..b956a2876 100644
--- a/docs/superpowers/notes/census-proposal-agent-start-demo-1.md
+++ b/docs/superpowers/notes/census-proposal-agent-start-demo-1.md
@@ -12,7 +12,7 @@ Ruling `census-ruling-agent-start-demo-1`. The independent reviewer approves or
| `internal/activator/size.go` `SizedLimit` | body | unchanged (6) | Reads Route.IsDemo before ordinary size selection; returns the existing small table row for any demo marker. |
| `internal/edge/edge.go` `RunWithActivatorReady` | body | unchanged (5) | Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop. |
| `internal/edge/wildcard.go` `newWildcardFromEnv` | body | unchanged (3) | Includes the configured demo domain in the existing wildcard manager's explicit parent input. |
-| `internal/host/agent.go` `runAgent` | body | unchanged (6) | Passes the existing registry, data store and hibernation prefix into the demo worker; no alternate data store. |
+| `internal/host/agent.go` `runAgent` | body | unchanged (6) | Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. |
| `internal/host/bootstrap.go` `bootstrapWith` | body | unchanged (3) | Uses demo settings from the existing host.env parser; refuses malformed demo config and installs the fixed template drop-ins. |
| `internal/host/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Wires demo registry views and existing root release/adoption guard into instance control. |
| `internal/host/claimunit.go` `readClaimUnitSettings` | body | unchanged (3) | Reads worker/concurrency/toolchain settings from the existing host.env parser; requires box mode and refuses claims coexistence. |
@@ -125,7 +125,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/instancectl/demo_build.go:Client.DemoBuildReadiness`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
- new `internal/instancectl/demo_cleanup.go:Server.purgeDemoWithJobs`: reads +file:Lstat, +file:ReadDir, +registry:Account, +registry:App, +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime, +registry:HoldOp, +registry:Status, +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/instancectl/demo_policy.go:Server.demoCgroup`: reads +file:ReadFile; written legacy, accepted-legacy, frozen
-- new `internal/instancectl/demo_policy.go:Server.demoHandler`: reads +file:Query ×2, +registry:Status, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/instancectl/demo_policy.go:Server.demoHandler`: reads +file:Query ×2, +registry:Status, +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/instancectl/demo_versions.go:Server.purgeDemoVersions`: reads +file:EvalSymlinks, +file:ReadDir ×2, +registry:Account, +registry:App, +registry:Host, +whole:Route ×7; written legacy, accepted-legacy, frozen
- new `internal/provision/demo_policy.go:PolicyCache.AssertDemoRoute`: reads +registry:Account ×2, +registry:App ×2, +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime ×2, +registry:Host ×2, +registry:Kind, +registry:Moved, +registry:Region, +registry:Replica, +registry:Replicas, +registry:Runtime, +registry:Seed, +registry:SeedSource, +registry:Socket, +registry:Unit; written legacy, accepted-legacy, frozen
- new `internal/provision/demo_policy.go:stampDemoRoute`: reads +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime; written legacy, accepted-legacy, frozen
@@ -141,6 +141,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- reads `internal/registry/registry.go:routeArgs`: +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime; keeps authority, task E3
- reads `internal/registry/registry.go:scanRoute`: +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime; keeps legacy, task accepted-legacy
-Seal: `c61b055182bf84e822fab92199432bd2d462c268c03ead17c3cfa18f09bd82cd` → `f3328a22e4d406134595d9c4ae8b28f7af17568f6a6092949386227b8b857e5c`.
+Seal: `c61b055182bf84e822fab92199432bd2d462c268c03ead17c3cfa18f09bd82cd` → `39197c39b76e49a8e06c46a8b42c091d842710ffed16fa67cdd283fd93da5033`.
Overlay: `internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/copy-agent-start-demo-1.md b/docs/superpowers/notes/copy-agent-start-demo-1.md
index 53f37dab3..0ac3841da 100644
--- a/docs/superpowers/notes/copy-agent-start-demo-1.md
+++ b/docs/superpowers/notes/copy-agent-start-demo-1.md
@@ -21,7 +21,7 @@ Copy IDs added beyond the plan table: `DEMO-BUILD-FAILED`, `DEMO-BUILD-FINISHING
| DEMO-BUILD-LIVE | API refusal relayed to a person | The demo is live. | none | internal/console/apidemo.go:46 |
| DEMO-BUILD-FAILED | API refusal relayed to a person | The demo could not start. Send another update with the same token. | none | internal/console/apidemo.go:47 |
| DEMO-ROLLED-BACK | API refusal relayed to a person | The update failed, but the previous version is still running. Send another update with the same token. | none | internal/console/apidemo.go:48 |
-| DEMO-CHECK-FAILED | API refusal relayed to a person | The service could not check this demo. Try again shortly. | none | internal/console/apidemo.go:49 |
+| DEMO-CHECK-FAILED | API refusal relayed to a person (R24: guard requires an explicit failed check; overrides the Luna row) | Could not check this demo. Try again shortly. | none | internal/console/apidemo.go:49 |
| DEMO-COMPILE-FAILED | API refusal relayed to a person | The demo build failed. Send another update with the same token. | none | internal/console/apidemo.go:50 |
| DEMO-BUILD-TIMEOUT | API refusal relayed to a person | The demo was not ready within 60 seconds. Send another update with the same token. | none | internal/console/apidemo.go:51 |
| DEMO-SOURCE | API refusal relayed to a person | Send a gzip tar archive no larger than 5,000,000 bytes within 30 seconds. | none | internal/console/apidemo.go:52 |
diff --git a/internal/console/apidemo.go b/internal/console/apidemo.go
index 510acbc11..e58118a54 100644
--- a/internal/console/apidemo.go
+++ b/internal/console/apidemo.go
@@ -21,6 +21,7 @@ import (
"github.com/carlosframework/platform/internal/demo"
"github.com/carlosframework/platform/internal/demobuild"
"github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/lease"
"github.com/carlosframework/platform/internal/release"
)
@@ -44,7 +45,7 @@ var demoCopy = map[string]string{
"DEMO-BUILD-LIVE": "The demo is live.",
"DEMO-BUILD-FAILED": "The demo could not start. Send another update with the same token.",
"DEMO-ROLLED-BACK": "The update failed, but the previous version is still running. Send another update with the same token.",
- "DEMO-CHECK-FAILED": "The service could not check this demo. Try again shortly.",
+ "DEMO-CHECK-FAILED": "Could not check this demo. Try again shortly.",
"DEMO-COMPILE-FAILED": "The demo build failed. Send another update with the same token.",
"DEMO-BUILD-TIMEOUT": "The demo was not ready within 60 seconds. Send another update with the same token.",
"DEMO-SOURCE": "Send a gzip tar archive no larger than 5,000,000 bytes within 30 seconds.",
@@ -111,6 +112,10 @@ func validateDemoConfig(cfg Config, st *Store) error {
return demoConfigFailure(check.name, err)
}
}
+ return nil
+}
+
+func validateDemoLiveConfig(ctx context.Context, cfg Config, acct *Account) error {
reg, err := openRegistry(cfg.Registry)
if err != nil {
return demoConfigFailure("registry open", err)
@@ -131,8 +136,6 @@ func validateDemoConfig(cfg Config, st *Store) error {
if !found {
return demoConfigFailure("fleet ownership", nil)
}
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
// Check keys rather than the forgiving ListClaims fold: an unreadable claim
// must still reserve its domain, including a parent or child of the demo zone.
keys, err := cfg.Releases.List(ctx, domains.ClaimsPrefix)
@@ -167,6 +170,9 @@ func validateDemoAdmissionState(ctx context.Context, cfg Config, st *Store) erro
if cfg.Registry == "" || cfg.Releases == nil {
return errors.New("admission registry or release store is missing")
}
+ if err := validateDemoLiveConfig(ctx, cfg, acct); err != nil {
+ return err
+ }
reg, err := openRegistry(cfg.Registry)
if err != nil {
return fmt.Errorf("fleet routes registry: %w", err)
@@ -329,6 +335,10 @@ func (s *Server) handleDemoPublish(w http.ResponseWriter, r *http.Request) {
jsonError(w, 503, demoCopy["DEMO-CONFIG"])
return
}
+ if err := s.demoPublishReady(r.Context(), row.AssignedBox); err != nil {
+ demoError(w, err)
+ return
+ }
update = &row
err = s.withDemoLocked(r.Context(), row.ID, func(row DemoRow, _ AppLife) error { return s.store.SpendDemoUpdate(r.Context(), row.ID, time.Now()) })
} else {
@@ -344,6 +354,10 @@ func (s *Server) handleDemoPublish(w http.ResponseWriter, r *http.Request) {
jsonError(w, 503, demoCopy["DEMO-CONFIG"])
return
}
+ if err := s.demoPublishReady(r.Context(), ""); err != nil {
+ demoError(w, err)
+ return
+ }
err = s.store.SpendDemoCreate(r.Context(), s.clientIP(r), time.Now(), s.cfg.Demo)
}
if err != nil {
@@ -397,7 +411,7 @@ func (s *Server) handleDemoPublish(w http.ResponseWriter, r *http.Request) {
var identity demo.Identity
if update == nil {
sum := sha256.Sum256(src.Archive)
- in := DemoAdmission{Config: s.cfg.Demo, IP: s.clientIP(r), Now: time.Now(), SourceSHA256: sum, Client: r.Header.Get("User-Agent")}
+ in := DemoAdmission{Config: s.cfg.Demo, IP: s.clientIP(r), Now: time.Now(), SourceSHA256: sum, Client: r.Header.Get("X-Carlos-Client")}
in.job = func(ctx context.Context, tx *sql.Tx, d DemoRow, life AppLife) error {
_, err := s.insertDemoJob(ctx, tx, d, life, src)
return err
@@ -415,8 +429,9 @@ func (s *Server) handleDemoPublish(w http.ResponseWriter, r *http.Request) {
demoError(w, err)
return
}
- response := map[string]any{"jobID": job.ID, "status": "building", "claimAvailable": false}
+ response := map[string]any{"jobId": job.ID, "name": row.Name, "statusUrl": strings.TrimRight(s.cfg.Origin, "/") + "/api/demo/jobs/" + job.ID, "expiresAt": row.CreatedAt + 86400}
if update == nil {
+ response["claimAvailable"] = false
response["claimToken"] = identity.Token
response["claimUrl"] = strings.TrimRight(s.cfg.Origin, "/") + "/demo/claim#" + identity.Token
}
@@ -530,7 +545,7 @@ func (s *Server) handleDemoStatus(w http.ResponseWriter, r *http.Request) {
} else if stage == "rolled-back" || stage == "settlement-failed" {
state = "failed"
}
- response := map[string]any{"jobID": id, "status": state, "diagnostics": diagnostics, "diagnosticsTruncated": truncated}
+ response := map[string]any{"jobId": id, "state": state, "diagnostics": diagnostics, "diagnosticsTruncated": truncated}
publishedStage := strings.TrimPrefix(stage, "timeout:")
shipped := publishedStage == "shipped" || publishedStage == "promoted" || publishedStage == "starting"
if shipped {
@@ -652,3 +667,55 @@ func (s *Server) reserveFreshDemoWith(ctx context.Context, in DemoAdmission, gen
}
return zero, demo.Identity{}, ErrDemoLiveLimit
}
+
+// demoPublishReady observes availability before charging an attempt. The
+// writer still acquires and checks its lease after source validation.
+func (s *Server) demoPublishReady(ctx context.Context, assigned string) error {
+ found := false
+ for _, p := range s.demoEligiblePeers() {
+ if assigned == "" || p.box() == assigned {
+ found = true
+ break
+ }
+ }
+ if !found {
+ return errDemoJob
+ }
+ if s.cfg.Bucket == "" {
+ return nil
+ }
+ if s.cfg.PolicyLease == nil {
+ return errDemoJob
+ }
+ s.policyStateMu.Lock()
+ stopping := s.policyStopping
+ cur := s.policyCur
+
+ healthy := false
+ if cur != nil {
+ _, err := policyLeaseHealth(cur.h.lease, time.Now())
+ healthy = err == nil
+ }
+ s.policyStateMu.Unlock()
+ if stopping {
+ return errDemoJob
+ }
+ if healthy {
+ return nil
+ }
+
+ read := s.demoLeaseState
+ if read == nil {
+ read = lease.LockState
+ }
+ ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
+ defer cancel()
+ held, _, _, err := read(ctx, s.cfg.Bucket, appPolicyLeasePrefix, "")
+ if err != nil {
+ return err
+ }
+ if held {
+ return errDemoJob
+ }
+ return nil
+}
diff --git a/internal/console/apidemo_test.go b/internal/console/apidemo_test.go
index b769d74b6..63e7077f2 100644
--- a/internal/console/apidemo_test.go
+++ b/internal/console/apidemo_test.go
@@ -18,6 +18,7 @@ import (
"testing"
"time"
+ "github.com/carlosframework/platform/internal/demobuild"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
)
@@ -26,9 +27,21 @@ func demoTestServer(t *testing.T) *Server {
t.Helper()
st, _ := demoTestStore(t)
s := &Server{store: st, cfg: demoTestDeploymentConfig(t), mux: http.NewServeMux()}
+ demoTestWorker(t, s)
s.registerDemoRoutes()
return s
}
+func demoTestWorker(t *testing.T, s *Server) {
+ t.Helper()
+ s.demoJobs.peers = map[string]*demoPeer{"box": {name: "demo/box", token: "worker-token", ready: demobuild.WorkerReady{Capability: "anonymous-demo-v1", GOARCH: "arm64", BundleSHA256: strings.Repeat("a", 64), Slots: 1}, seen: time.Now()}}
+ reg, err := openRegistry(s.cfg.Registry)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.AddFleetBox(registry.FleetBox{Fleet: "demo", Label: "box", TokenHash: hashToken("worker-token"), Status: "active"}); err != nil {
+ t.Fatal(err)
+ }
+}
func demoRequest(s *Server, token, ip string) *demoRecorder {
r := httptest.NewRequest("POST", "/api/demo/apps", strings.NewReader("not an archive"))
r.RemoteAddr = ip + ":1234"
@@ -193,7 +206,7 @@ func TestDemoConfigStartup(t *testing.T) {
}
bad = cfg
bad.Demo.Fleet = "missing"
- if err := validateDemoConfig(bad, st); err == nil {
+ if err := validateDemoAdmissionState(t.Context(), bad, st); err == nil {
t.Fatal("missing fleet accepted")
}
bad = cfg
@@ -211,7 +224,7 @@ func TestDemoConfigStartup(t *testing.T) {
if _, err := cfg.Releases.Put(t.Context(), "domains/demo.example.com.json", []byte("unreadable"), ""); err != nil {
t.Fatal(err)
}
- if err := validateDemoConfig(cfg, st); err == nil {
+ if err := validateDemoAdmissionState(t.Context(), cfg, st); err == nil {
t.Fatal("customer claim overlap accepted")
}
cfg.Demo.Enabled = false
@@ -351,7 +364,7 @@ func TestDemoConfigCatchallClaims(t *testing.T) {
if _, err := cfg.Releases.Put(t.Context(), "domains/"+tc.host+".json", []byte("unreadable"), ""); err != nil {
t.Fatal(err)
}
- if err := validateDemoConfig(cfg, st); (err != nil) != tc.refuse {
+ if err := validateDemoAdmissionState(t.Context(), cfg, st); (err != nil) != tc.refuse {
t.Fatalf("refuse=%v: %v", tc.refuse, err)
}
})
@@ -490,6 +503,7 @@ func TestDemoConfigDynamicStateRefusesAdmission(t *testing.T) {
if err != nil {
t.Fatalf("restart blocked by dynamic state: %v", err)
}
+ demoTestWorker(t, srv)
if !strings.Contains(logs.String(), "DEMO-CONFIG") || !strings.Contains(logs.String(), kind) {
t.Errorf("startup log lacks check: %s", &logs)
}
@@ -565,8 +579,8 @@ func TestDemoConfigOperatorDiagnostics(t *testing.T) {
previous := log.Writer()
log.SetOutput(&logs)
defer log.SetOutput(previous)
- if _, err := NewServer(cfg, st); err == nil {
- t.Fatal("static config must remain fatal")
+ if srv, err := NewServer(cfg, st); err != nil || srv.demoAdmissionReady(t.Context()) == nil {
+ t.Fatal("fleet failure must refuse admission without killing boot")
}
if !strings.Contains(logs.String(), "DEMO-CONFIG") || !strings.Contains(logs.String(), "fleet ownership") {
t.Fatalf("missing check diagnostic: %s", &logs)
@@ -574,7 +588,7 @@ func TestDemoConfigOperatorDiagnostics(t *testing.T) {
logs.Reset()
cfg.Demo.Fleet = "demo"
cfg.Releases = demoFailStore{}
- if err := validateDemoConfig(cfg, st); err == nil {
+ if err := validateDemoAdmissionState(t.Context(), cfg, st); err == nil {
t.Fatal("unreadable claims accepted")
}
if !strings.Contains(logs.String(), "domain claims") || !strings.Contains(logs.String(), "injected") {
@@ -582,7 +596,7 @@ func TestDemoConfigOperatorDiagnostics(t *testing.T) {
}
}
-// Count only the dynamic holding-account scan, not static domain claims.
+// Count only the holding-account scan, not the separate domain-claims scan.
type demoCountingListStore struct {
release.Store
calls atomic.Int64
@@ -750,6 +764,7 @@ func TestDemoAdmissionStartupCache(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ demoTestWorker(t, s)
for range 20 {
if w := demoRequest(s, "", "192.0.2.1"); w.Code != 400 {
t.Fatalf("response=%d", w.Code)
@@ -834,3 +849,61 @@ func TestDemoAdmissionUpdateListBounded(t *testing.T) {
t.Fatalf("updates: LIST calls=%d, want 1", got)
}
}
+
+func TestDemoTransientBootChecks(t *testing.T) {
+ for _, kind := range []string{"claims", "registry"} {
+ t.Run(kind, func(t *testing.T) {
+ st, _ := demoTestStore(t)
+ cfg := demoTestDeploymentConfig(t)
+ if kind == "claims" {
+ cfg.Releases = demoFailStore{cfg.Releases}
+ } else {
+ cfg.Registry = filepath.Join(t.TempDir(), "missing", "registry.db")
+ }
+ srv, err := NewServer(cfg, st)
+ if err != nil {
+ t.Fatalf("transient %s failure killed boot: %v", kind, err)
+ }
+ if err := srv.demoAdmissionReady(t.Context()); err == nil {
+ t.Fatal("admission accepted unavailable state")
+ }
+ })
+ }
+}
+func TestDemoWorkerOutagePreservesAttempts(t *testing.T) {
+ for _, update := range []bool{false, true} {
+ t.Run(fmt.Sprint(update), func(t *testing.T) {
+ s, _ := demoJobServer(t)
+ token := ""
+ var id string
+ if update {
+ in := demoTestAdmission(t, s.cfg.Demo)
+ d, err := s.store.ReserveDemo(t.Context(), in)
+ if err != nil {
+ t.Fatal(err)
+ }
+ id, token = d.ID, "Bearer "+in.Identity.Token
+ if _, err := s.store.db.Exec(`UPDATE demo_apps SET assigned_box='offline' WHERE demo_id=?`, id); err != nil {
+ t.Fatal(err)
+ }
+ } else {
+ s.demoJobs.peers = nil
+ }
+ for range 3 {
+ w := demoRequest(s, token, "192.0.2.1")
+ if w.Code != 503 {
+ t.Errorf("outage status=%d want 503", w.Code)
+ }
+ }
+ var n int
+ if err := s.store.db.QueryRow(`SELECT count(*) FROM demo_admissions`).Scan(&n); err != nil || n != 0 {
+ t.Fatalf("create attempts=%d err=%v", n, err)
+ }
+ if update {
+ if err := s.store.db.QueryRow(`SELECT update_attempts FROM demo_apps WHERE demo_id=?`, id).Scan(&n); err != nil || n != 0 {
+ t.Fatalf("update attempts=%d err=%v", n, err)
+ }
+ }
+ })
+ }
+}
diff --git a/internal/console/demo_e2e_test.go b/internal/console/demo_e2e_test.go
index 73d93d94b..fb6b08bbf 100644
--- a/internal/console/demo_e2e_test.go
+++ b/internal/console/demo_e2e_test.go
@@ -32,18 +32,24 @@ import (
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
+ "golang.org/x/mod/module"
"golang.org/x/net/websocket"
)
// Only the compiler and root launcher are substituted in this local witness.
// Admission, box authentication, grants, uploads, release signing, record and
-// policy reconciliation, exact-host edge requests and SQLite use real code.
-func TestDemoSourceToLiveAndUpdate(t *testing.T) {
+// policy reconciliation and exact-host edge requests use real code. SQLite is
+// covered when the locked dependency closure is cached (R23).
+func TestDemoSourceToLiveAndUpdate(t *testing.T) { testDemoSourceToLiveAndUpdate(t, false) }
+func TestDemoSourceToLiveAndUpdateWithoutClosure(t *testing.T) {
+ testDemoSourceToLiveAndUpdate(t, true)
+}
+func testDemoSourceToLiveAndUpdate(t *testing.T, forceFileFixture bool) {
if os.Getenv("CARLOS_DEMO_TOOLCHAIN_DIR") != "" {
t.Fatal("local witness requires an absent toolchain bundle; run the designated dev witness for root compilation")
}
- t.Log("R6: no real toolchain bundle: fake builder returns prebuilt linux-arm64 output; native build uses the same application source with a local-only Go 1.26.0 directive. Submitted source retains the locked Go version. This is not kernel or dev deployment evidence.")
- archives, arm, native := demoE2EBuilds(t)
+ t.Log("R6: no real toolchain bundle: fake builder returns prebuilt linux-arm64 output; native build uses a local-only Go 1.26.0 directive; R23 permits a stdlib file-persistence fixture when the locked closure is absent. Submitted source retains the locked Go version. This is not kernel or dev deployment evidence.")
+ archives, arm, native := demoE2EBuilds(t, forceFileFixture)
started := time.Now()
s, _ := demoJobServer(t)
// Configuration fixtures may create an account and box, but no demo rows,
@@ -68,13 +74,15 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
if err := WriteAccountManifest(t.Context(), s.cfg.Releases, acct.ID, acct.Sqid, acct.Name, acct.CreatedAt); err != nil {
t.Fatal(err)
}
- for k, v := range map[string]string{"CARLOS_DEMO_ACCOUNT": s.cfg.Demo.Account, "CARLOS_DEMO_FLEET": s.cfg.Demo.Fleet, "CARLOS_DEMO_DOMAIN": s.cfg.Demo.Domain, "CARLOS_FLEET": "", "CARLOS_TUNNEL_HOST": ""} {
- t.Setenv(k, v)
+ // Each edge receives its own host.env tuple only while it is constructed.
+ for _, k := range []string{"CARLOS_DEMO_ACCOUNT", "CARLOS_DEMO_FLEET", "CARLOS_DEMO_DOMAIN", "CARLOS_DEMO_BOX", "CARLOS_FLEET", "CARLOS_TUNNEL_HOST"} {
+ t.Setenv(k, "")
}
+
api := httptest.NewServer(s.mux)
defer api.Close()
// Use the real authenticated store door for source and release downloads.
- hub, err := edge.New(reg, nil)
+ hub, err := demoE2EEdge(t, "ingress", s.cfg.Demo, reg, nil)
if err != nil {
t.Fatal(err)
}
@@ -194,7 +202,7 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
} else if accepted["claimToken"] != nil {
t.Fatal("update reissued token")
}
- jobID, _ := accepted["jobID"].(string)
+ jobID, _ := accepted["jobId"].(string)
var j demobuild.Job
ws.SetReadDeadline(time.Now().Add(10 * time.Second))
for {
@@ -298,6 +306,31 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
if err := provision.Reconcile(ctx, boxStore, boxReg, provision.ReconcileConfig{Region: "fleet/" + j.Fleet, FleetBox: j.Box, DataDir: data, ReleasePub: s.cfg.ReleasePub, Policies: policies}); err != nil {
t.Fatal(err)
}
+
+ if err := provision.Reconcile(ctx, s.cfg.Releases, reg, provision.ReconcileConfig{Region: "home", DataDir: opt, FleetOwners: func() (map[string]string, error) { return map[string]string{j.Fleet: j.Account}, nil }}); err != nil {
+ t.Fatal(err)
+ }
+ t.Run("ingress-routing", func(t *testing.T) {
+ t.Setenv("CARLOS_TUNNEL_HOST", "127.0.0.1")
+ if err := hub.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if !hub.Allowed(j.Host) {
+ t.Fatal("configured ingress refused demo host")
+ }
+ unconfigured, err := edge.New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ unconfigured.EnableTunnels(edge.NewTunnelHub("127.0.0.1", nil))
+ if err := unconfigured.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if unconfigured.Allowed(j.Host) {
+ t.Fatal("ingress inherited another component's demo tuple")
+ }
+ })
+
row, err := boxReg.Get(j.Host)
if err != nil || row == nil {
t.Fatalf("missing demo route: %v", err)
@@ -321,7 +354,7 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- localEdge, err := edge.New(boxReg, &demoLiveProcess{socket: socket, version: version})
+ localEdge, err := demoE2EEdge(t, "demo-box", s.cfg.Demo, boxReg, &demoLiveProcess{socket: socket, version: version})
if err != nil {
t.Fatal(err)
}
@@ -332,15 +365,15 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
for {
req, _ = http.NewRequestWithContext(ctx, "GET", api.URL+"/api/demo/jobs/"+j.ID, nil)
status = demoE2EJSON(t, api.Client(), req, 200)
- if status["status"] == "live" {
+ if status["state"] == "live" {
break
}
- if status["status"] == "failed" || time.Now().After(deadline) {
+ if status["state"] == "failed" || time.Now().After(deadline) {
t.Fatalf("not live: %v", status)
}
time.Sleep(500 * time.Millisecond)
}
- if status["status"] != "live" || status["version"] != version || status["url"] != "https://"+host+"/" {
+ if status["state"] != "live" || status["version"] != version || status["url"] != "https://"+host+"/" {
t.Fatalf("not live: %v", status)
}
client := &http.Client{Transport: transport, Timeout: 5 * time.Second}
@@ -351,20 +384,20 @@ func TestDemoSourceToLiveAndUpdate(t *testing.T) {
req, _ = http.NewRequestWithContext(ctx, "GET", "https://"+host+"/", nil)
want := []string{"one:saved", "two:saved"}[generation]
if got := string(demoE2EHTTP(t, client, req, 200)); got != want {
- t.Fatalf("SQLite after generation %d: %q want %q", generation+1, got, want)
+ t.Fatalf("persisted value after generation %d: %q want %q", generation+1, got, want)
}
}
if elapsed := time.Since(started); elapsed >= 5*time.Minute {
t.Fatalf("live elapsed %s", elapsed)
} else {
- t.Logf("anonymous source -> live -> updated, SQLite preserved, elapsed %s", elapsed)
+ t.Logf("anonymous source -> live -> updated, stored value preserved, elapsed %s", elapsed)
}
// Advance only the existing expiry pass's injected clock. The API exposes
// no TTL override, and the box must receive the signed retirement on stream.
now := time.Unix(expires, 0)
s.expiryPass(ctx, now.Add(-time.Second))
req, _ := http.NewRequestWithContext(ctx, "GET", api.URL+"/api/demo/jobs/"+lastJob.ID, nil)
- if got := demoE2EJSON(t, api.Client(), req, 200); got["status"] != "live" {
+ if got := demoE2EJSON(t, api.Client(), req, 200); got["state"] != "live" {
t.Fatal("retired before 24 hours")
}
s.expiryPass(ctx, now)
@@ -432,8 +465,26 @@ func demoE2EJSON(t *testing.T, c *http.Client, r *http.Request, want int) map[st
return value
}
-func demoE2EBuilds(t *testing.T) (archives [2][]byte, arm [2][]byte, native [2]string) {
+func demoE2EBuilds(t *testing.T, forceFileFixture bool) (archives [2][]byte, arm [2][]byte, native [2]string) {
t.Helper()
+ cmd := exec.CommandContext(t.Context(), "go", "env", "GOMODCACHE")
+ rawCache, err := cmd.Output()
+ if err != nil {
+ t.Fatal(err)
+ }
+ lock, err := demobuild.DefaultLock()
+ if err != nil {
+ t.Fatal(err)
+ }
+ cached := demoE2EClosureCached(strings.TrimSpace(string(rawCache)), lock)
+ if forceFileFixture {
+ cached = false
+ t.Log("R23: forcing the missing-closure path for covering-test evidence")
+ }
+ if !cached {
+ t.Log("R23 FALLBACK: locked Rastrillo closure unavailable or deliberately excluded; compiling stdlib file-persistence fixture. SQLite internals are NOT covered. Submitted archive remains the locked starter.")
+ }
+
for i, revision := range []string{"one", "two"} {
dir := t.TempDir()
var packed bytes.Buffer
@@ -476,6 +527,20 @@ func demoE2EBuilds(t *testing.T) (archives [2][]byte, arm [2][]byte, native [2]s
if len(archives[i]) > demo.SourceMaxBytes {
t.Fatal("fixture exceeds compressed cap")
}
+
+ if !cached {
+ raw, err := os.ReadFile("testdata/demo-stdlib/main.go")
+ if err != nil {
+ t.Fatal(err)
+ }
+ raw = bytes.ReplaceAll(raw, []byte(`const revision = "one"`), []byte(`const revision = "`+revision+`"`))
+ if err := os.WriteFile(filepath.Join(dir, "main.go"), raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte("module demo.local/app\n\ngo 1.26.0\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
for _, arch := range []string{"arm64", runtime.GOARCH} {
output := filepath.Join(t.TempDir(), "app")
cmd := exec.CommandContext(t.Context(), "go", "build", "-mod=readonly", "-trimpath", "-buildvcs=false", "-o", output, ".")
@@ -605,3 +670,61 @@ func (s *demoDisabledStore) Delete(ctx context.Context, key string) error {
s.deletes.Add(1)
return s.Store.Delete(ctx, key)
}
+
+func demoE2EEdge(t *testing.T, component string, cfg demo.Config, reg *registry.Registry, act edge.Activator) (*edge.Edge, error) {
+ t.Helper()
+ var e *edge.Edge
+ var err error
+ t.Run(component+"-environment", func(t *testing.T) {
+ t.Setenv("CARLOS_DEMO_ACCOUNT", cfg.Account)
+ t.Setenv("CARLOS_DEMO_FLEET", cfg.Fleet)
+ t.Setenv("CARLOS_DEMO_DOMAIN", cfg.Domain)
+ t.Setenv("CARLOS_DEMO_BOX", "")
+ if component == "demo-box" {
+ t.Setenv("CARLOS_DEMO_BOX", "1")
+ }
+ e, err = edge.New(reg, act)
+ })
+ return e, err
+}
+func demoE2EClosureCached(cache string, lock demobuild.Lock) bool {
+ for _, m := range lock.Modules {
+ path, err := module.EscapePath(m.Path)
+ if err != nil {
+ return false
+ }
+ version, err := module.EscapeVersion(m.Version)
+ if err != nil {
+ return false
+ }
+ for _, name := range []string{filepath.Join(cache, path+"@"+version, "go.mod"), filepath.Join(cache, "cache/download", path, "@v", version+".mod")} {
+ if st, err := os.Stat(name); err != nil || !st.Mode().IsRegular() {
+ return false
+ }
+ }
+ }
+ return true
+}
+func TestDemoE2EClosureSelection(t *testing.T) {
+ cache := t.TempDir()
+ lock := demobuild.Lock{Modules: []demobuild.Module{{Path: "example.com/module", Version: "v1.0.0"}}}
+ if demoE2EClosureCached(cache, lock) {
+ t.Fatal("absent closure accepted")
+ }
+ for _, name := range []string{"example.com/module@v1.0.0/go.mod", "cache/download/example.com/module/@v/v1.0.0.mod"} {
+ file := filepath.Join(cache, name)
+ if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(file, []byte("module example.com/module\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if !demoE2EClosureCached(cache, lock) {
+ t.Fatal("cached closure ignored")
+ }
+ lock.Modules = append(lock.Modules, demobuild.Module{Path: "example.com/missing", Version: "v1.0.0"})
+ if demoE2EClosureCached(cache, lock) {
+ t.Fatal("partial closure accepted")
+ }
+}
diff --git a/internal/console/demo_expiry.go b/internal/console/demo_expiry.go
index 3b7ca31c3..0619bb6ec 100644
--- a/internal/console/demo_expiry.go
+++ b/internal/console/demo_expiry.go
@@ -192,8 +192,8 @@ func (s *Server) expireDemoLocked(ctx context.Context, d DemoRow, now time.Time)
if _, err = s.store.db.ExecContext(ctx, `UPDATE demo_retirements SET delivered=1 WHERE demo_id=?`, d.ID); err != nil {
return err
}
+ s.bumpSerial(ctx)
}
- s.bumpSerial(ctx)
s.NotifyDemoBox(d.AssignedBox)
if !r.Acknowledged || !r.InitializedClean {
if now.Unix()-receipt.Tombstone >= 3600 {
@@ -261,6 +261,7 @@ func (s *Server) finishDemoPurge(ctx context.Context, d DemoRow, now time.Time)
return err
}
s.audit(&Account{ID: d.AccountID, Sqid: d.AccountSqid}, d.App, expiryActor, "demo-purge", demoCopy["DEMO-EXPIRED-PURGED"])
+ s.bumpSerial(ctx)
return nil
}
diff --git a/internal/console/demo_expiry_test.go b/internal/console/demo_expiry_test.go
index e6790fa4d..0d4b75a2f 100644
--- a/internal/console/demo_expiry_test.go
+++ b/internal/console/demo_expiry_test.go
@@ -334,3 +334,50 @@ func TestDemoExpiryTrashRowHasNoGrace(t *testing.T) {
t.Fatalf("demo grace=%d", life.PurgeAfter-life.DeletedAt)
}
}
+
+type demoSerialStore struct {
+ release.Store
+ serials int
+}
+
+func (s *demoSerialStore) Put(ctx context.Context, key string, body []byte, tag string) (string, error) {
+ if key == "control/serial" {
+ s.serials++
+ }
+ return s.Store.Put(ctx, key, body, tag)
+}
+func TestDemoWaitingRetirementSerial(t *testing.T) {
+ s, d, _, _ := demoPublishFixture(t)
+ counted := &demoSerialStore{Store: s.cfg.Releases}
+ s.cfg.Releases = counted
+ life, _ := s.store.AppLife(d.AccountID, d.App)
+ now := time.Unix(life.ExpiresAt, 0)
+ for i := range 5 {
+ s.expiryPass(t.Context(), now.Add(time.Duration(i)*5*time.Minute))
+ }
+ if counted.serials != 1 {
+ t.Fatalf("offline box: serial writes=%d, want 1", counted.serials)
+ }
+ r, err := s.demoRetirement(t.Context(), d.ID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := s.ackDemoRetirement(t.Context(), d.Fleet+"/"+d.AssignedBox, r.Wire); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.completeDemoRetirement(t.Context(), d.Fleet+"/"+d.AssignedBox, r.Wire); err != nil {
+ t.Fatal(err)
+ }
+ s.expiryPass(t.Context(), now.Add(time.Hour))
+ got, err := s.store.demoByID(t.Context(), d.ID)
+ if err != nil || got.PurgedAt == 0 {
+ t.Fatalf("not purged: %+v %v", got, err)
+ }
+ if counted.serials != 2 {
+ t.Fatalf("after purge: serial writes=%d, want 2", counted.serials)
+ }
+ s.expiryPass(t.Context(), now.Add(2*time.Hour))
+ if counted.serials != 2 {
+ t.Fatal("purged demo bumped again")
+ }
+}
diff --git a/internal/console/demo_finishing_test.go b/internal/console/demo_finishing_test.go
index 53228c8f6..10985d127 100644
--- a/internal/console/demo_finishing_test.go
+++ b/internal/console/demo_finishing_test.go
@@ -11,7 +11,7 @@ func TestDemoSettlementStatusFinishing(t *testing.T) {
t.Fatal(err)
}
got := demoSettlementStatus(t, s, j)
- if got["status"] != "starting" || got["message"] != "The update is finishing. Try again shortly." || got["url"] != nil {
+ if got["state"] != "starting" || got["message"] != "The update is finishing. Try again shortly." || got["url"] != nil {
t.Errorf("%s: misleading settlement response: %v", stage, got)
}
}
diff --git a/internal/console/demo_jobs_test.go b/internal/console/demo_jobs_test.go
index c4b8b0f57..edcf2d750 100644
--- a/internal/console/demo_jobs_test.go
+++ b/internal/console/demo_jobs_test.go
@@ -12,6 +12,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
+ "fmt"
"github.com/carlosframework/platform/internal/edge"
"io"
"mime/multipart"
@@ -35,6 +36,9 @@ import (
func demoJobServer(t *testing.T) (*Server, *demoCountingStore) {
t.Helper()
s := demoTestServer(t)
+ s.demoLeaseState = func(context.Context, string, string, string) (bool, string, time.Time, error) {
+ return false, "", time.Time{}, nil
+ }
_, s.cfg.Key, _ = ed25519.GenerateKey(rand.Reader)
s.cfg.ReleasePub = s.cfg.Key.Public().(ed25519.PublicKey)
store := &demoCountingStore{Store: s.cfg.Releases}
@@ -44,9 +48,7 @@ func demoJobServer(t *testing.T) (*Server, *demoCountingStore) {
t.Fatal(err)
}
defer reg.Close()
- if err := reg.AddFleetBox(registry.FleetBox{Fleet: "demo", Label: "box", TokenHash: hashToken("worker-token"), Status: "active"}); err != nil {
- t.Fatal(err)
- }
+
s.demoJobs.peers = map[string]*demoPeer{"box": {name: "demo/box", token: "worker-token", ready: demobuild.WorkerReady{Capability: "anonymous-demo-v1", GOARCH: "arm64", BundleSHA256: hex.EncodeToString(make([]byte, 32)), Slots: 1}, wake: make(chan struct{}, 1), seen: time.Now()}}
return s, store
}
@@ -345,7 +347,7 @@ func TestDemoJobAdmissionWiring(t *testing.T) {
status.RemoteAddr = "192.0.2.1:1"
sw := newDemoRecorder()
s.mux.ServeHTTP(sw, status)
- if sw.Code != 200 || !strings.Contains(sw.Body.String(), `"status":"building"`) || strings.Contains(sw.Body.String(), response.ClaimToken) {
+ if sw.Code != 200 || !strings.Contains(sw.Body.String(), `"state":"building"`) || strings.Contains(sw.Body.String(), response.ClaimToken) {
t.Fatalf("status: %d %s", sw.Code, sw.Body.String())
}
if _, err := s.store.db.Exec(`UPDATE demo_jobs SET deadline=0 WHERE id=?`, response.JobID); err != nil {
@@ -1232,3 +1234,133 @@ func TestDemoJobAnonymousLeaseRefusal(t *testing.T) {
})
}
}
+
+func TestDemoAnonymousWireContract(t *testing.T) {
+ for _, client := range []string{"", " harness/" + strings.Repeat("x", 120) + " "} {
+ t.Run(client, func(t *testing.T) {
+ s, _ := demoJobServer(t)
+ token := ""
+ var firstName string
+ var firstExpiry float64
+ for generation := range 2 {
+ r := httptest.NewRequest("POST", "/api/demo/apps", bytes.NewReader(demoHTTPSource(t)))
+ r.RemoteAddr = "192.0.2.1:1"
+ r.Header.Set("Content-Type", "application/gzip")
+ r.Header.Set("User-Agent", "http-library")
+ r.Header.Set("X-Carlos-Client", client)
+ if token != "" {
+ r.Header.Set("Authorization", "Bearer "+token)
+ }
+ w := newDemoRecorder()
+ s.mux.ServeHTTP(w, r)
+ if w.Code != 202 {
+ t.Fatalf("publish: %d %s", w.Code, w.Body.String())
+ }
+ var got map[string]any
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatal(err)
+ }
+ job, ok := got["jobId"].(string)
+ if !ok || !demobuild.ValidJobID(job) {
+ t.Fatalf("jobId missing: %v", got)
+ }
+ wantFields := 4
+ if generation == 0 {
+ wantFields = 7
+ }
+ if len(got) != wantFields || got["statusUrl"] != s.cfg.Origin+"/api/demo/jobs/"+job {
+ t.Fatalf("reply contract: %v", got)
+ }
+ jr, err := s.readDemoJob(t.Context(), job)
+ if err != nil {
+ t.Fatal(err)
+ }
+ d, err := s.store.demoByID(t.Context(), jr.Job.DemoID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ life, err := s.store.AppLife(d.AccountID, d.App)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got["name"] != d.Name || got["expiresAt"] != float64(life.ExpiresAt) {
+ t.Fatalf("identity/expiry: %v", got)
+ }
+ wantClient := strings.TrimSpace(client)
+ if len(wantClient) > 100 {
+ wantClient = wantClient[:100]
+ }
+ if d.Client != wantClient {
+ t.Fatalf("client=%q want %q", d.Client, wantClient)
+ }
+ if generation == 0 {
+ token, _ = got["claimToken"].(string)
+ firstName = d.Name
+ firstExpiry = got["expiresAt"].(float64)
+ if token == "" || got["claimAvailable"] != false || got["claimUrl"] != s.cfg.Origin+"/demo/claim#"+token {
+ t.Fatalf("claim reply: %v", got)
+ }
+ } else if got["name"] != firstName || got["expiresAt"] != firstExpiry {
+ t.Fatal("update changed identity or expiry")
+ }
+ status := demoSettlementStatus(t, s, jr.Job)
+ if status["state"] != "building" || status["jobId"] != job || status["status"] != nil || status["jobID"] != nil {
+ t.Fatalf("status contract: %v", status)
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_jobs SET state='failed' WHERE id=?`, job); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_apps SET active_job_id='' WHERE demo_id=?`, d.ID); err != nil {
+ t.Fatal(err)
+ }
+ }
+ })
+ }
+}
+
+func TestDemoLeaseOutagePreservesAttempts(t *testing.T) {
+ for _, update := range []bool{false, true} {
+ for _, failedRead := range []bool{false, true} {
+ t.Run(fmt.Sprintf("update=%v/read-error=%v", update, failedRead), func(t *testing.T) {
+ s, _ := demoJobServer(t)
+ leaser := &fakePolicyLeaser{}
+ s.cfg.Bucket = "deployment"
+ s.cfg.PolicyLease = leaser.leaser
+ s.demoLeaseState = func(_ context.Context, bucket, prefix, region string) (bool, string, time.Time, error) {
+ if bucket != "deployment" || prefix != appPolicyLeasePrefix || region != "" {
+ t.Error("wrong lease read location")
+ }
+ if failedRead {
+ return false, "", time.Time{}, errors.New("offline")
+ }
+ return true, "another-console", time.Now().Add(time.Minute), nil
+ }
+ token, id := "", ""
+ if update {
+ in := demoTestAdmission(t, s.cfg.Demo)
+ d, err := s.store.ReserveDemo(t.Context(), in)
+ if err != nil {
+ t.Fatal(err)
+ }
+ token, id = "Bearer "+in.Identity.Token, d.ID
+ }
+ w := demoRequest(s, token, "192.0.2.1")
+ if w.Code != 503 {
+ t.Fatalf("status=%d", w.Code)
+ }
+ var n int
+ if err := s.store.db.QueryRow(`SELECT count(*) FROM demo_admissions`).Scan(&n); err != nil || n != 0 {
+ t.Fatalf("creates=%d err=%v", n, err)
+ }
+ if update {
+ if err := s.store.db.QueryRow(`SELECT update_attempts FROM demo_apps WHERE demo_id=?`, id).Scan(&n); err != nil || n != 0 {
+ t.Fatalf("updates=%d err=%v", n, err)
+ }
+ }
+ if leaser.callCount() != 0 {
+ t.Fatal("read-only precheck acquired a lease")
+ }
+ })
+ }
+ }
+}
diff --git a/internal/console/demo_live_test.go b/internal/console/demo_live_test.go
index f0ee22a27..951eb59c7 100644
--- a/internal/console/demo_live_test.go
+++ b/internal/console/demo_live_test.go
@@ -243,7 +243,7 @@ func TestDemoUsesRealReleasePathGET(t *testing.T) {
status.SetPathValue("jobID", j.ID)
w := httptest.NewRecorder()
s.handleDemoStatus(w, status)
- if w.Code != 200 || !strings.Contains(w.Body.String(), `"status":"live"`) || !strings.Contains(w.Body.String(), j.Host) {
+ if w.Code != 200 || !strings.Contains(w.Body.String(), `"state":"live"`) || !strings.Contains(w.Body.String(), j.Host) {
t.Fatalf("live status: %d %s", w.Code, w.Body.String())
}
// A failed update retains the signed current pointer and local SQLite value.
diff --git a/internal/console/demo_settlement_r2_test.go b/internal/console/demo_settlement_r2_test.go
index 91936b0ec..7d74b9dae 100644
--- a/internal/console/demo_settlement_r2_test.go
+++ b/internal/console/demo_settlement_r2_test.go
@@ -65,7 +65,7 @@ func demoStartPublication(t *testing.T, s *Server, j, previous demobuild.Job) (D
func demoAssertPlainFailure(t *testing.T, s *Server, j demobuild.Job) {
t.Helper()
status := demoSettlementStatus(t, s, j)
- if status["status"] != "failed" || status["url"] != nil || status["message"] != demoCopy["DEMO-BUILD-FAILED"] || status["version"] != nil {
+ if status["state"] != "failed" || status["url"] != nil || status["message"] != demoCopy["DEMO-BUILD-FAILED"] || status["version"] != nil {
t.Errorf("not a plain failure: %v", status)
}
d, err := s.store.demoByID(t.Context(), j.DemoID)
@@ -150,7 +150,7 @@ func TestDemoPublishSettlementStatusTruth(t *testing.T) {
t.Fatal(err)
}
status := demoSettlementStatus(t, s, j)
- if status["status"] != "starting" || status["url"] != nil || status["version"] != nil || status["message"] != demoCopy["DEMO-BUILD-FINISHING"] {
+ if status["state"] != "starting" || status["url"] != nil || status["version"] != nil || status["message"] != demoCopy["DEMO-BUILD-FINISHING"] {
t.Errorf("misleading %s status: %v", stage, status)
}
}
@@ -159,7 +159,7 @@ func TestDemoPublishSettlementStatusTruth(t *testing.T) {
t.Fatal(err)
}
status := demoSettlementStatus(t, s, j)
- if status["status"] != "failed" || status["version"] != nil || status["message"] != demoCopy["DEMO-ROLLED-BACK"] {
+ if status["state"] != "failed" || status["version"] != nil || status["message"] != demoCopy["DEMO-ROLLED-BACK"] {
t.Errorf("misleading restored status: %v", status)
}
}
@@ -299,7 +299,7 @@ func TestDemoPublishSettlementLastReadyGeneration(t *testing.T) {
t.Fatalf("did not restore last ready generation: %+v %v", ptr, err)
}
status := demoSettlementStatus(t, s, third)
- if status["status"] != "failed" || status["version"] != nil || status["message"] != demoCopy["DEMO-ROLLED-BACK"] {
+ if status["state"] != "failed" || status["version"] != nil || status["message"] != demoCopy["DEMO-ROLLED-BACK"] {
t.Fatalf("restoration: %v", status)
}
}
diff --git a/internal/console/demo_settlement_test.go b/internal/console/demo_settlement_test.go
index ac06529ca..5639bf3d3 100644
--- a/internal/console/demo_settlement_test.go
+++ b/internal/console/demo_settlement_test.go
@@ -109,7 +109,7 @@ func TestDemoPublishSettlement(t *testing.T) {
t.Fatalf("failed publication channel: %+v %v", ptr, err)
}
status := demoSettlementStatus(t, s, j)
- if status["status"] != "failed" || status["url"] != nil || strings.Contains(status["message"].(string), "previous version is still running") != update {
+ if status["state"] != "failed" || status["url"] != nil || strings.Contains(status["message"].(string), "previous version is still running") != update {
t.Fatalf("status: %v", status)
}
current, err := s.store.demoByID(t.Context(), d.ID)
@@ -173,7 +173,7 @@ func TestDemoPublishSettlementRestart(t *testing.T) {
t.Fatal(err)
}
status := demoSettlementStatus(t, s, j)
- if status["status"] != "starting" || status["message"] != demoCopy["DEMO-BUILD-FINISHING"] || status["version"] != nil || status["url"] != nil || strings.Contains(status["message"].(string), "previous version is still running") {
+ if status["state"] != "starting" || status["message"] != demoCopy["DEMO-BUILD-FINISHING"] || status["version"] != nil || status["url"] != nil || strings.Contains(status["message"].(string), "previous version is still running") {
t.Fatalf("premature restoration claim: %v", status)
}
s = reopenDemoJobs(t, s)
@@ -182,7 +182,7 @@ func TestDemoPublishSettlementRestart(t *testing.T) {
t.Fatal(err)
}
status = demoSettlementStatus(t, s, j)
- if status["status"] != "failed" || !strings.Contains(status["message"].(string), "previous version is still running") {
+ if status["state"] != "failed" || !strings.Contains(status["message"].(string), "previous version is still running") {
t.Fatalf("settled status: %v", status)
}
ptr, err := release.Channel(t.Context(), base, s.cfg.ReleasePub, j.Account, j.App, "edge")
@@ -238,7 +238,7 @@ func TestDemoPublishSettlementReadinessDeadline(t *testing.T) {
t.Fatal(err)
}
status := demoSettlementStatus(t, s, j)
- if status["status"] != "failed" || !strings.Contains(status["message"].(string), "previous version is still running") {
+ if status["state"] != "failed" || !strings.Contains(status["message"].(string), "previous version is still running") {
t.Fatalf("readiness failure: %v", status)
}
}
diff --git a/internal/console/server.go b/internal/console/server.go
index 563965de6..b1236ddc8 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1178,6 +1178,8 @@ type Server struct {
// by ReleasePolicyWriter. policyLog is a test seam (nil: log.Printf), and
// so is policyAttemptEnding, run inside an attempt's cancel between its
// two steps (nil in production). The zero Server needs no setup.
+ // demoLeaseState substitutes the read-only lease observation in tests.
+ demoLeaseState func(context.Context, string, string, string) (bool, string, time.Time, error)
policyLeaseMu sync.Mutex
policyStateMu sync.Mutex
policyN uint64
diff --git a/internal/console/testdata/demo-stdlib/main.go b/internal/console/testdata/demo-stdlib/main.go
new file mode 100644
index 000000000..41a1a8b4c
--- /dev/null
+++ b/internal/console/testdata/demo-stdlib/main.go
@@ -0,0 +1,36 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "net"
+ "net/http"
+ "os"
+)
+
+const revision = "one"
+
+func main() {
+ listener, err := net.Listen("unix", os.Getenv("CARLOS_SOCKET"))
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer listener.Close()
+ handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ db := os.Getenv("CARLOS_DB")
+ if r.Method == http.MethodPost {
+ if err := os.WriteFile(db, []byte(r.URL.Query().Get("value")), 0600); err != nil {
+ http.Error(w, "write failed", 500)
+ return
+ }
+ }
+ value, err := os.ReadFile(db)
+ if err != nil && !os.IsNotExist(err) {
+ http.Error(w, "read failed", 500)
+ return
+ }
+ fmt.Fprintf(w, "%s:%s", revision, value)
+ })
+ log.Fatal(http.Serve(listener, handler))
+}
diff --git a/internal/host/agent.go b/internal/host/agent.go
index b8dac91c0..1ca3a4682 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -625,7 +625,7 @@ func runAgent(args []string, buildClaims ClaimFactory) {
// instance's database, the build state names it, under the lease. A
// store that failed to start refuses every spawn (never "run
// unrecorded"). Set before Start, like Routes.
- svc.BeforeExec = demoPolicyHook(os.Getenv, reg, buildStateHook(bs, bsErr))
+ svc.BeforeExec = demoPolicyHook(os.Getenv, reg, eb.Control, buildStateHook(bs, bsErr))
// The held wake check (settings spec §4.3 rule 3): a held instance
// never wakes on an installed build other than its target. The copy
// is refreshed before every wake that could be held (wakeTarget), and
diff --git a/internal/host/demo_cleanup.go b/internal/host/demo_cleanup.go
index c534d7c26..8b28fb4a7 100644
--- a/internal/host/demo_cleanup.go
+++ b/internal/host/demo_cleanup.go
@@ -118,7 +118,7 @@ func (w *demoWorker) acknowledgeDemoPhaseHTTP(ctx context.Context, wire []byte,
return nil
}
-// The stream is serial, and this state survives reconnects. Only verified IDs
+// Retirement delivery is serial, and this state survives reconnects. Only verified IDs
// occupy it; idle entries expire after the maximum backoff to bound retention.
type demoRetirementRetry struct {
next time.Time
@@ -143,7 +143,7 @@ func (w *demoWorker) deliverDemoRetirement(ctx context.Context, wire []byte, now
}
}
started := time.Now()
- attempt, cancel := context.WithTimeout(ctx, 30*time.Second)
+ attempt, cancel := context.WithTimeout(ctx, 60*time.Second)
err = w.retireDemo(attempt, wire)
cancel()
delay := 5 * time.Minute
diff --git a/internal/host/demo_jobs.go b/internal/host/demo_jobs.go
index da4e9c877..84cf6af9e 100644
--- a/internal/host/demo_jobs.go
+++ b/internal/host/demo_jobs.go
@@ -333,6 +333,8 @@ func (w *demoWorker) drain(ctx context.Context, in <-chan []byte) {
}
func (w *demoWorker) Connect(ctx context.Context) error {
+ w.clearReady()
+ defer w.clearReady()
h, err := w.headers()
if err != nil {
return err
@@ -355,6 +357,58 @@ func (w *demoWorker) Connect(ctx context.Context) error {
defer ws.Close()
ctx, cancel = context.WithCancel(ctx)
defer cancel()
+
+ type retirementDelivery struct {
+ id string
+ wire []byte
+ }
+ var retirementMu sync.Mutex
+ var retirements []retirementDelivery
+ queuedRetirements := make(map[string]bool)
+ retirementWake := make(chan struct{}, 1)
+ queueRetirement := func(wire []byte) {
+ receipt, err := demobuild.VerifyRetirement(w.pub, wire)
+ if err != nil || receipt.Box != w.box || w.cfg.ValidateBinding(receipt.Demo, receipt.Account, receipt.App, receipt.Demo.Host, receipt.Demo.Lifetime, receipt.Fleet) != nil {
+ return
+ }
+ retirementMu.Lock()
+ if !queuedRetirements[receipt.Demo.ID] {
+ queuedRetirements[receipt.Demo.ID] = true
+ retirements = append(retirements, retirementDelivery{receipt.Demo.ID, wire})
+ }
+ retirementMu.Unlock()
+ select {
+ case retirementWake <- struct{}{}:
+ default:
+ }
+ }
+ retirementDone := make(chan struct{})
+ go func() {
+ defer close(retirementDone)
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-retirementWake:
+ }
+ for ctx.Err() == nil {
+ retirementMu.Lock()
+ if len(retirements) == 0 {
+ retirementMu.Unlock()
+ break
+ }
+ delivery := retirements[0]
+ retirements[0] = retirementDelivery{}
+ retirements = retirements[1:]
+ retirementMu.Unlock()
+ w.deliverDemoRetirement(ctx, delivery.wire, time.Now())
+ retirementMu.Lock()
+ delete(queuedRetirements, delivery.id)
+ retirementMu.Unlock()
+ }
+ }
+ }()
+
in := make(chan []byte, demobuild.QueueLimit)
done := make(chan struct{})
go func() { defer close(done); w.drain(ctx, in) }()
@@ -406,7 +460,14 @@ func (w *demoWorker) Connect(ctx context.Context) error {
}
}
}()
- defer func() { cancel(); ws.Close(); <-done; <-stopped; <-readinessDone }()
+ defer func() {
+ cancel()
+ ws.Close()
+ <-done
+ <-stopped
+ <-readinessDone
+ <-retirementDone
+ }()
for {
_ = ws.SetReadDeadline(time.Now().Add(30 * time.Second))
var raw []byte
@@ -418,7 +479,9 @@ func (w *demoWorker) Connect(ctx context.Context) error {
return errors.New("demo-build: malformed stream")
}
if len(msg.Retirement) > 0 {
- w.deliverDemoRetirement(ctx, msg.Retirement, time.Now())
+ // Keep one pending or running receipt per signed demo ID. Cleanup
+ // cannot block the stream, and repeated delivery cannot fill its queue.
+ queueRetirement(msg.Retirement)
}
if msg.Reconcile && w.notify != nil {
w.notify()
@@ -483,3 +546,9 @@ func (w *demoWorker) buildReady() demobuild.WorkerReady {
defer w.readyMu.RUnlock()
return w.ready
}
+
+func (w *demoWorker) clearReady() {
+ w.readyMu.Lock()
+ w.ready = demobuild.WorkerReady{}
+ w.readyMu.Unlock()
+}
diff --git a/internal/host/demo_jobs_test.go b/internal/host/demo_jobs_test.go
index c6a77a742..52d1faeef 100644
--- a/internal/host/demo_jobs_test.go
+++ b/internal/host/demo_jobs_test.go
@@ -247,10 +247,13 @@ func TestDemoJobsWorkerDelivery(t *testing.T) {
if err := websocket.JSON.Receive(ws, &ready); err != nil {
return
}
- if !ready.Valid() {
- t.Error("invalid readiness")
- return
+
+ for !ready.Valid() {
+ if websocket.JSON.Receive(ws, &ready) != nil {
+ return
+ }
}
+
if err := websocket.JSON.Send(ws, demobuild.StreamMessage{Job: wire}); err != nil {
return
}
@@ -355,8 +358,11 @@ func TestDemoJobsWorkerDelivery(t *testing.T) {
built++
return demobuild.BuildOutput{Binary: []byte("output")}, nil
}}
+ w.readiness = func(context.Context) (demobuild.WorkerReady, error) {
+ return demobuild.WorkerReady{Capability: "anonymous-demo-v1", GOARCH: "arm64", Slots: 1, BundleSHA256: j.BundleSHA256}, nil
+ }
w.pickup = w.pickupHTTP
- ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
+ ctx, cancel := context.WithTimeout(t.Context(), 15*time.Second)
done := make(chan struct{})
go func() { defer close(done); _ = w.Connect(ctx) }()
defer func() { cancel(); <-done }()
diff --git a/internal/host/demo_policy.go b/internal/host/demo_policy.go
index 1ca344171..ab393e513 100644
--- a/internal/host/demo_policy.go
+++ b/internal/host/demo_policy.go
@@ -61,7 +61,7 @@ func installDemoUnitsIn(unitDir string, cfg demo.Config) (bool, error) {
// demoPolicyHook shares the changed-app cache. It never fetches an object or
// starts a watcher; an unverified or not-yet-cached demo waits for reconcile.
-func demoPolicyHook(getenv func(string) string, reg *registry.Registry, next func(context.Context, string, string) error) func(context.Context, string, string) error {
+func demoPolicyHook(getenv func(string) string, reg *registry.Registry, control any, next func(context.Context, string, string) error) func(context.Context, string, string) error {
cfg, configErr := demo.BoxConfig(getenv)
if configErr == nil && !cfg.BoxMode() {
return next
@@ -78,6 +78,13 @@ func demoPolicyHook(getenv func(string) string, reg *registry.Registry, next fun
if rt == nil {
return demo.ErrPolicy
}
+ root, ok := control.(interface{ ReadyDemo(context.Context) error })
+ if !ok {
+ return demo.ErrPolicy
+ }
+ if err := root.ReadyDemo(ctx); err != nil {
+ return err
+ }
if err := armedPolicyCache.Load().AssertDemoRoute(cfg, *rt, claims, time.Now()); err != nil {
return err
}
diff --git a/internal/host/demo_policy_test.go b/internal/host/demo_policy_test.go
index 02af7858a..27d7b1788 100644
--- a/internal/host/demo_policy_test.go
+++ b/internal/host/demo_policy_test.go
@@ -160,7 +160,7 @@ func TestDemoPolicyBoxInstallers(t *testing.T) {
func TestDemoPolicyOrdinarySpawn(t *testing.T) {
calls := 0
- hook := demoPolicyHook(func(string) string { return "" }, nil, func(context.Context, string, string) error { calls++; return nil })
+ hook := demoPolicyHook(func(string) string { return "" }, nil, nil, func(context.Context, string, string) error { calls++; return nil })
if err := hook(t.Context(), "shop.example.com", "v1"); err != nil || calls != 1 {
t.Fatalf("ordinary spawn %v calls %d", err, calls)
}
@@ -221,7 +221,7 @@ func TestDemoPolicyExistingRouteGate(t *testing.T) {
if !demoDisabledFor(getenv, func(registry.Route) bool { return true })(registry.Route{}) {
t.Fatal("lost existing disabled gate")
}
- if demoPolicyHook(getenv, nil, nil) != nil {
+ if demoPolicyHook(getenv, nil, nil, nil) != nil {
t.Fatal("ordinary nil hook changed")
}
}
@@ -338,3 +338,38 @@ func TestDemoPolicyOrdinaryInstallersIgnoreRemovalFailure(t *testing.T) {
t.Fatalf("ordinary apply: %v", err)
}
}
+
+type demoModeProbe struct {
+ calls int
+ err error
+}
+
+func (p *demoModeProbe) ReadyDemo(context.Context) error { p.calls++; return p.err }
+func TestDemoPolicyRequiresRootMode(t *testing.T) {
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer reg.Close()
+ if err := reg.Upsert(registry.Route{Host: "shop.example.com", DemoID: "demo"}); err != nil {
+ t.Fatal(err)
+ }
+ getenv := func(k string) string {
+ return map[string]string{"CARLOS_DEMO_BOX": "1", "CARLOS_DEMO_ACCOUNT": "shop", "CARLOS_DEMO_FLEET": "demo", "CARLOS_DEMO_DOMAIN": "example.com"}[k]
+ }
+ rootErr := errors.New("root is in ordinary mode")
+ root := &demoModeProbe{err: rootErr}
+ calls := 0
+ hook := demoPolicyHook(getenv, reg, root, func(context.Context, string, string) error { calls++; return nil })
+ for range 2 {
+ if err := hook(t.Context(), "shop.example.com", "v1"); !errors.Is(err, rootErr) {
+ t.Fatalf("missing root refusal: %v", err)
+ }
+ }
+ if calls != 0 || root.calls != 2 {
+ t.Fatalf("spawn=%d root probes=%d", calls, root.calls)
+ }
+ if err := demoPolicyHook(getenv, reg, nil, nil)(t.Context(), "shop.example.com", "v1"); !errors.Is(err, demo.ErrPolicy) {
+ t.Fatalf("missing capability: %v", err)
+ }
+}
diff --git a/internal/host/demo_retirement_stream_test.go b/internal/host/demo_retirement_stream_test.go
index 389638e3c..1556159bf 100644
--- a/internal/host/demo_retirement_stream_test.go
+++ b/internal/host/demo_retirement_stream_test.go
@@ -13,6 +13,7 @@ import (
"net/http/httptest"
"path/filepath"
"strings"
+ "sync"
"sync/atomic"
"testing"
"time"
@@ -38,10 +39,11 @@ func (s *retirementReadStore) Get(ctx context.Context, key string) ([]byte, stri
func TestDemoRetirementStreamFailureIsolation(t *testing.T) {
for _, ready := range []bool{false, true} {
- t.Run(fmt.Sprint(ready), func(t *testing.T) { testDemoRetirementStream(t, ready) })
+ t.Run(fmt.Sprint(ready), func(t *testing.T) { testDemoRetirementStream(t, ready, false) })
}
}
-func testDemoRetirementStream(t *testing.T, builderReady bool) {
+func TestDemoRetirementSlowStream(t *testing.T) { testDemoRetirementStream(t, true, true) }
+func testDemoRetirementStream(t *testing.T, builderReady, slow bool) {
t.Setenv("CARLOS_DEMO_ACCOUNT", "shop")
t.Setenv("CARLOS_DEMO_FLEET", "demo")
t.Setenv("CARLOS_DEMO_DOMAIN", "example.com")
@@ -56,7 +58,11 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
cfg := demo.Config{Account: "shop", Fleet: "demo", Domain: "example.com", BuildConcurrency: 1}
var wires [][]byte
var ids []string
- for range 2 {
+ retirementCount := 2
+ if slow {
+ retirementCount = demobuild.QueueLimit + 5
+ }
+ for range retirementCount {
id, _ := demo.NewIdentity(rand.Reader)
d := demo.Descriptor{ID: id.ID, Host: id.Name + ".example.com", Lifetime: "life", ExpiresAt: time.Now().Add(-time.Hour).Unix()}
r := demobuild.Retirement{Demo: d, Account: "shop", App: id.App, Fleet: "demo", Box: "box", Tombstone: d.ExpiresAt}
@@ -82,8 +88,11 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
if err != nil {
t.Fatal(err)
}
+ releasePurge := make(chan struct{})
+ var releaseOnce sync.Once
+ defer releaseOnce.Do(func() { close(releasePurge) })
var failed, completed atomic.Int32
- reached := make(chan struct{}, 4)
+ reached := make(chan struct{}, retirementCount*2)
w := &demoWorker{reg: reg, store: store, data: release.NewDirStore(t.TempDir()), cfg: cfg, pub: pub, box: "box", credentials: func() (string, string, bool) { return "demo/box", "token", true },
purge: func(ctx context.Context, in instancectl.DemoPurgeRequest) error {
row, err := reg.Get(in.Demo.Host)
@@ -103,6 +112,17 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
if !act.ServeHTTP(out, req, *row, http.HandlerFunc(func(http.ResponseWriter, *http.Request) { t.Error("expired route reached app") })) || out.Code != 503 {
t.Errorf("activator accepted expired route: %d", out.Code)
}
+ if slow {
+ deadline, ok := ctx.Deadline()
+ if !ok || time.Until(deadline) <= 30*time.Second {
+ t.Error("retirement budget does not exceed root wait")
+ }
+ select {
+ case <-releasePurge:
+ case <-ctx.Done():
+ return ctx.Err()
+ }
+ }
if in.Demo.ID == ids[0] {
failed.Add(1)
return errors.New("cgroup populated")
@@ -137,6 +157,13 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
if websocket.JSON.Receive(ws, &ready) != nil {
return
}
+ if builderReady {
+ for !ready.Valid() {
+ if websocket.JSON.Receive(ws, &ready) != nil {
+ return
+ }
+ }
+ }
for range 3 {
for _, wire := range wires {
if websocket.JSON.Send(ws, demobuild.StreamMessage{Retirement: wire}) != nil {
@@ -155,11 +182,19 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
ctx, cancel := context.WithCancel(t.Context())
done := make(chan error, 1)
go func() { done <- w.Connect(ctx) }()
+ if slow && attempt == 0 {
+ select {
+ case <-picked:
+ case <-time.After(15 * time.Second):
+ t.Error("slow retirement blocked job pickup")
+ }
+ releaseOnce.Do(func() { close(releasePurge) })
+ }
// One hold + removal notification for the healthy demo, one for the failed
// demo, and the final stream hint on the first connection.
want := 1
if attempt == 0 {
- want = 4
+ want = retirementCount * 2
}
for range want {
select {
@@ -167,13 +202,13 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
case err := <-done:
cancel()
t.Fatalf("stream stopped at failed retirement: %v", err)
- case <-time.After(3 * time.Second):
+ case <-time.After(15 * time.Second):
cancel()
<-done
t.Fatal("stream did not pass failed retirement")
}
}
- if builderReady {
+ if builderReady && !(slow && attempt == 0) {
select {
case <-picked:
case <-time.After(time.Second):
@@ -182,14 +217,17 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
}
cancel()
<-done
+ if w.buildReady().Valid() {
+ t.Fatal("readiness retained after disconnect")
+ }
}
if !builderReady && len(picked) != 0 {
t.Fatal("unready worker picked a build")
}
- if failed.Load() != 1 || completed.Load() != 1 {
+ if failed.Load() != 1 || completed.Load() != int32(retirementCount-1) {
t.Fatalf("failed=%d completed=%d", failed.Load(), completed.Load())
}
- if store.reads.Load() != 4 {
+ if store.reads.Load() != int32(retirementCount*2) {
t.Fatalf("receipt/tombstone re-read inside backoff: %d", store.reads.Load())
}
w.notify = nil
@@ -207,3 +245,40 @@ func testDemoRetirementStream(t *testing.T, builderReady bool) {
}
}
}
+
+func TestDemoConnectClearsReadiness(t *testing.T) {
+ ready := demobuild.WorkerReady{Capability: "anonymous-demo-v1", GOARCH: "arm64", Slots: 1, BundleSHA256: strings.Repeat("b", 64)}
+ first := make(chan demobuild.WorkerReady, 1)
+ server := httptest.NewServer(interactive.NewServer(func(ws *websocket.Conn) {
+ defer ws.Close()
+ var got demobuild.WorkerReady
+ if websocket.JSON.Receive(ws, &got) == nil {
+ first <- got
+ }
+ }))
+ defer server.Close()
+ w := &demoWorker{base: server.URL, box: "box", ready: ready, cfg: demo.Config{Fleet: "demo", BuildConcurrency: 1}, credentials: func() (string, string, bool) { return "demo/box", "token", true }, readiness: func(ctx context.Context) (demobuild.WorkerReady, error) {
+ <-ctx.Done()
+ return demobuild.WorkerReady{}, ctx.Err()
+ }}
+ ctx, cancel := context.WithTimeout(t.Context(), 3*time.Second)
+ defer cancel()
+ _ = w.Connect(ctx)
+ select {
+ case got := <-first:
+ if got.Valid() {
+ t.Error("stale readiness advertised before probe")
+ }
+ default:
+ t.Fatal("no heartbeat")
+ }
+ if w.buildReady().Valid() {
+ t.Error("readiness retained after disconnect")
+ }
+ w.ready = ready
+ w.credentials = func() (string, string, bool) { return "", "", false }
+ _ = w.Connect(ctx)
+ if w.buildReady().Valid() {
+ t.Error("failed dial retained readiness")
+ }
+}
diff --git a/internal/instancectl/client.go b/internal/instancectl/client.go
index 190a3d7f9..362496257 100644
--- a/internal/instancectl/client.go
+++ b/internal/instancectl/client.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "github.com/carlosframework/platform/internal/demo"
"io"
"net"
"net/http"
@@ -405,14 +406,17 @@ func (c *Client) Sweep(ctx context.Context) (SweepResponse, error) {
// *NotReadyError on 503, and a *StaleBuildError on a 204 whose BuildHeader
// is missing or names another build (#256). The verdict is asked first:
// a service that is both stale and not ready says why it is not ready.
-func (c *Client) Ready(ctx context.Context) error { return c.ready(ctx, "/ready") }
+func (c *Client) Ready(ctx context.Context) error { return c.ready(ctx, "/ready", false) }
// ReadyRootfs is Ready for the rootfs verdict (GET /ready/rootfs): both
// probes passed on this boot, or a *NotReadyError carrying the rootfs
// report (rootfs apps plan 2).
-func (c *Client) ReadyRootfs(ctx context.Context) error { return c.ready(ctx, RootfsReadyPath) }
+func (c *Client) ReadyRootfs(ctx context.Context) error { return c.ready(ctx, RootfsReadyPath, false) }
-func (c *Client) ready(ctx context.Context, path string) error {
+// ReadyDemo requires the current root service to enforce demo box isolation.
+func (c *Client) ReadyDemo(ctx context.Context) error { return c.ready(ctx, "/ready", true) }
+
+func (c *Client) ready(ctx context.Context, path string, requireDemo bool) error {
_, hdr, err := c.do(ctx, DeadlineReady, http.MethodGet, path, nil, nil)
if err != nil {
return err
@@ -420,6 +424,9 @@ func (c *Client) ready(ctx context.Context, path string) error {
if got := hdr.Get(BuildHeader); c.Build != "" && got != c.Build {
return &StaleBuildError{Running: got, Want: c.Build}
}
+ if requireDemo && hdr.Get("Carlos-Demo-Box") != "1" {
+ return demo.ErrPolicy
+ }
return nil
}
diff --git a/internal/instancectl/client_test.go b/internal/instancectl/client_test.go
index db11a7bd1..dafbc6399 100644
--- a/internal/instancectl/client_test.go
+++ b/internal/instancectl/client_test.go
@@ -261,3 +261,37 @@ func TestClientSizeMapsRefusalsToErrSizeRefused(t *testing.T) {
}
}
}
+
+func TestClientDemoReadyRequiresCurrentRootMode(t *testing.T) {
+ s, c := newClient(t, &fakeCtl{})
+ s.mu.Lock()
+ s.probed = true
+ s.report = ProbeReport{Ready: true}
+ s.mu.Unlock()
+ s.Build = "this-build"
+ c.Build = "this-build"
+ if err := c.ReadyDemo(t.Context()); err == nil {
+ t.Fatal("ordinary root accepted")
+ }
+ s.DemoBox = true
+ if err := c.ReadyDemo(t.Context()); err != nil {
+ t.Fatal(err)
+ }
+ s.DemoBox = false
+ if err := c.ReadyDemo(t.Context()); err == nil {
+ t.Fatal("root mode change was cached")
+ }
+ s.DemoBox = true
+ s.Build = "old-build"
+ var stale *StaleBuildError
+ if err := c.ReadyDemo(t.Context()); !errors.As(err, &stale) {
+ t.Fatalf("stale demo root: %v", err)
+ }
+ s.Build = "this-build"
+ s.mu.Lock()
+ s.report = ProbeReport{}
+ s.mu.Unlock()
+ if err := c.ReadyDemo(t.Context()); err == nil {
+ t.Fatal("unready demo root accepted")
+ }
+}
diff --git a/internal/instancectl/demo_policy.go b/internal/instancectl/demo_policy.go
index 5fbc2c225..3946b4051 100644
--- a/internal/instancectl/demo_policy.go
+++ b/internal/instancectl/demo_policy.go
@@ -18,20 +18,19 @@ import (
// demoHandler refuses unsupported launch and mutation doors before dispatch.
// DemoBox comes only from this root service's environment, never a request.
func (s *Server) demoHandler(next http.Handler) http.Handler {
- if !s.DemoBox {
- return next
- }
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if strings.HasPrefix(r.URL.Path, "/claim/") || r.Method == "POST" && (r.URL.Path == "/cmd" || r.URL.Path == "/tty" || r.URL.Path == "/seed") {
+ if s.DemoBox && (strings.HasPrefix(r.URL.Path, "/claim/") || r.Method == "POST" && (r.URL.Path == "/cmd" || r.URL.Path == "/tty" || r.URL.Path == "/seed")) {
http.Error(w, demo.ErrPolicy.Error(), http.StatusForbidden)
return
}
if r.Method == "POST" && r.URL.Path == "/start" && provision.ValidHostShape(r.URL.Query().Get("host")) {
host := r.URL.Query().Get("host")
- defer s.lockDemo(host)()
+ if s.DemoBox {
+ defer s.lockDemo(host)()
+ }
if s.HostDemo != nil {
rt, err := s.HostDemo(host)
- if err != nil || rt == nil || !rt.IsDemo() || registry.IsHold(rt.Status) {
+ if err != nil || (s.DemoBox && (rt == nil || !rt.IsDemo() || registry.IsHold(rt.Status))) || (!s.DemoBox && rt != nil && rt.IsDemo()) {
http.Error(w, "DEMO-POLICY", 409)
return
}
diff --git a/internal/instancectl/demo_policy_test.go b/internal/instancectl/demo_policy_test.go
index 5766dcdb0..f683ffe65 100644
--- a/internal/instancectl/demo_policy_test.go
+++ b/internal/instancectl/demo_policy_test.go
@@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
+ "github.com/carlosframework/platform/internal/registry"
+ "net/http"
"net/http/httptest"
"os"
"path/filepath"
@@ -182,3 +184,28 @@ func TestDemoPolicyNamespaceReadback(t *testing.T) {
})
}
}
+
+func TestDemoOrdinaryRootRefusesMarkedStart(t *testing.T) {
+ for _, gen := range []string{"", "&gen=7"} {
+ for _, marker := range []registry.Route{{DemoID: "id"}, {DemoHost: "shop.example.com"}, {DemoLifetime: "life"}, {DemoExpiresAt: 1}} {
+ s := &Server{HostDemo: func(string) (*registry.Route, error) { return &marker, nil }}
+ reached := false
+ handler := s.demoHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { reached = true; w.WriteHeader(204) }))
+ w := httptest.NewRecorder()
+ handler.ServeHTTP(w, httptest.NewRequest("POST", "/start?host=shop.example.com&role=run"+gen, nil))
+ if w.Code != 409 || reached {
+ t.Fatalf("ordinary root accepted demo: status=%d reached=%v", w.Code, reached)
+ }
+ }
+ }
+}
+func TestDemoReadyReportsRootMode(t *testing.T) {
+ for _, mode := range []bool{false, true} {
+ s := &Server{DemoBox: mode, probed: true, report: ProbeReport{Ready: true}}
+ w := httptest.NewRecorder()
+ s.handleReady(w, httptest.NewRequest("GET", "/ready", nil))
+ if w.Code != 204 || (w.Header().Get("Carlos-Demo-Box") == "1") != mode {
+ t.Fatalf("mode=%v status=%d headers=%v", mode, w.Code, w.Header())
+ }
+ }
+}
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go
index e8892217a..f454d0237 100644
--- a/internal/instancectl/server.go
+++ b/internal/instancectl/server.go
@@ -1226,6 +1226,9 @@ func (s *Server) waitInactiveOrFailed(ctx context.Context, unit string, every ti
}
func (s *Server) handleReady(w http.ResponseWriter, r *http.Request) {
+ if s.DemoBox {
+ w.Header().Set("Carlos-Demo-Box", "1")
+ }
if s.Build != "" {
w.Header().Set(BuildHeader, s.Build)
}
diff --git a/internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv b/internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv
index 48a0f8b91..f0d27c4b5 100644
--- a/internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv
+++ b/internal/provision/testdata/plan14-root-reads-agent-start-demo-1.tsv
@@ -51,7 +51,7 @@
@legacy dc744eceb60de7d56641b7931fab6acd3f92b2c523b89411fe3e3eadf2bacc0c internal/host/demo_cleanup.go demoWorker.retireDemo legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Agent reads signed receipt, matching tombstone and registry binding; holds route, invokes root, acknowledges and removes only its remote initialization marker. registry:Account@1038,registry:App@1065,registry:Assigned@1084,registry:DemoHost@1008,registry:DemoID@944,registry:DemoLifetime@970,registry:HoldOp@1224,registry:Host@1198,registry:Host@1527,registry:Region@1108,whole:Route@1470,whole:Route@927 5a7f4289921de219c89a3f46a08a002ae5f23fd784e080656799c1e359766b4d
@legacy ae50722669640415ca70a1d726dba8e9dd96f94d91dc581c0a593399b66f69b1 internal/host/demo_jobs.go demoWorker.pickupHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads a bounded console pickup response; no bucket write or caller-selected execution input. file:ReadAll@615 fc59a4d264445d58fd6ee0060639b64e3773279b516ebe6b3bf3582767ec5c6e
@legacy eead48846bef49f537acd93efce7488c038093de1cd4ab5e6158eca7c94dbeb8 internal/host/demo_policy.go demoDisabledFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads startup box configuration and the activator-held Route.IsDemo marker in memory, then the existing disabled-route predicate. Refuses a marked ordinary-box route without querying the registry. whole:Route@263 0738a87ea56e5b0457dd80f63474cdf819a83fc1dae50ff9741182f1b4afd38b
-@legacy 5a6113d4e2c7b9a4bae5fcbc98aafe148fa31f0a432b2213b6c030e08c8510fc internal/host/demo_policy.go demoPolicyHook legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Returns the original hook unchanged outside explicit demo mode, including nil: no registry read or new spawn refusal. In demo mode reads the route by host and the existing verified policy cache before the original hook. whole:Route@483,whole:Route@582 d62699e7c901025b075d9d6d5f023408a34e635790f934c87c49a23c1c6fc7cd
+@legacy b5572721bf9122b259c6d2e5de4075f80c63449c667335e4add79618b20e6c83 internal/host/demo_policy.go demoPolicyHook legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Returns the original hook unchanged outside explicit demo mode. In demo mode reads the existing route and requires a fresh ReadyDemo verdict from the existing root control socket before checking the verified policy cache and calling the original hook. Missing capability, ordinary root mode, failed probe and stale build refuse the spawn. whole:Route@496,whole:Route@769 a13f61458da24c67c3c5903bf71c60130fa811bdf9c0482e7050f993493df1ec
@legacy 40c1b437514de723ac7f33025384c8980efd175b194dd0f2785371320909dcc6 internal/host/demo_policy.go demoRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads startup box/claims configuration and the caller-held route plus existing verified policy cache. Covers backend acquisition/probe preparation through ConfigGate without a new registry or bucket read. whole:Route@370,whole:Route@465 c42a8a4e0be94749d75f429e2d204d693d55c96da58229c680fd38b76207b5ff
@legacy 10061ec23b9b9523d21d626f74800812495eaeac8863aaea490a5f61c1265dd7 internal/host/demo_policy.go installDemoUnitsIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads the same fixed drop-in files in demo mode. Outside demo mode removes the same two fixed managed filenames; ENOENT is silent, other removal errors are logged and retried next pass without aborting ordinary installation or skipping the second file. Successful removal still signals daemon-reload. Enabled-demo read/write failures still refuse. file:ReadFile@866 70d45eb14cd41baa8b55239a7491ec4cf9a9902c39712655add955b5376d5c72
@legacy 50f81ac80dfb74c7639ef92176738bd35fe5fde3cf00584243bbf0aaa780c1d9 internal/host/demo_units/demo.conf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Retains read-only /run and /var tmpfs overlays and all network/size restrictions. Resets InaccessiblePaths and restates /etc/carlos -/run/carlos-control so the hidden control directory need not exist during namespace setup; /etc/carlos remains required. No new source or bind. file:external@0 578cf8a0f5842e043ff26f1c1b2f62be0baab81e66f322773c3981b494c3da6c
@@ -60,7 +60,7 @@
@legacy 55a2544feb1eabb563f276b13b3d999620adc9648638b70fa5d8ab847bf81428 internal/instancectl/demo_build.go Client.DemoBuildReadiness legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads bounded root readiness and verifies capability, slots, digest and service build identity. file:ReadAll@709 abbb7980212aff48b695260c0f140d63327517e493d00a76f41fb2fe86597507
@legacy 8920df20f3899d376436182a97352567f5bf7c512c872919850e958052ea27f4 internal/instancectl/demo_cleanup.go Server.purgeDemoWithJobs legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Checks root config and current registry identity/hold; reads derived unit/cgroup/exe/drop-in state, stops and proves emptiness before no-follow removal. Fix round 1: passes the descriptor host to the root build-scratch cleaner; same registry, cgroup and derived path reads. file:Lstat@1638,file:ReadDir@2477,registry:Account@833,registry:App@871,registry:DemoExpiresAt@798,registry:DemoHost@676,registry:DemoID@655,registry:DemoLifetime@701,registry:HoldOp@762,registry:Status@734,whole:Route@1374,whole:Route@625 bbed24fd2c6a68a1a0038ef7b13817bb87b97564c15582401a4b61b4ea1fd316
@legacy bc75f2049bd5711df22315f192ca14e9e820605a946b09da6fd323aabb00fcb7 internal/instancectl/demo_policy.go Server.demoCgroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads memory.max, cpu.weight, cpu.max and io.weight beneath root cgroupfs using platform-generated slice/unit names; checks both slice and unit before reporting started. file:ReadFile@395 734de40e9daa0756d5f1b9586aaa7c5810591e5525595e9bd888e7681dd2ca2b
-@legacy 56e04f2c31c95c6706fa2234da5d8f1df637caa5b3e72389871bd89e0f932854 internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Serializes demo starts with purge and refuses missing/non-demo/held current routes. file:Query@469,file:Query@509,registry:Status@687,whole:Route@642 48928e72ca97b7a18acea2e7f38a7c67516a2a8c4b7e6dc27fa07bd064e7df6f
+@legacy bbfe666a7b0b7e14d9f367911b9e414fb2ea599addeff2ee94074c55f51f5f0c internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Serializes demo-mode starts with demo purge; ordinary starts retain their existing unit locking. Uses the existing HostDemo callback to read the fixed service registry for a valid requested host in ordinary mode too; read errors and any demo-marked row refuse that start. Demo mode retains missing/non-demo/held-row refusals. No caller-named filesystem path is opened. file:Query@450,file:Query@490,registry:Status@707,whole:Route@662,whole:Route@738 201bc63347bee7b1bc354e11820e12e427b1573aa6fdf551ca43b6a66965e418
@legacy 4534a0ff26a3ed84cd3647fde754f25924730a0c269709bd36a90a21fcd22730 internal/instancectl/demo_versions.go Server.purgeDemoVersions legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Derives account/app from root config and host; reads registry/live/generation pins and staged entries; deletes only unreferenced demo app files. Fix round 1: logs and skips ENOENT resolving another live link; other errors still refuse, same pin and symlink reads. file:EvalSymlinks@1980,file:ReadDir@1387,file:ReadDir@1850,registry:Account@2336,registry:App@2361,registry:Host@885,whole:Route@1221,whole:Route@2321,whole:Route@842,whole:Route@871,whole:Route@908,whole:Route@924,whole:Route@932 e7d139663a400bb09ef051ff764396000923fe321fb7a4c86bb697bd3f28d9de
@legacy 2b4f69b592efd2d8e01f6f02e7f1d60d1979ea6e654cbefd017e203077589132 internal/provision/demo_policy.go PolicyCache.AssertDemoRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads route identity/runtime/placement, box configuration and verified cache entry under its mutex; refuses absent/expired/mismatched policy with no store request. registry:Account@656,registry:Account@870,registry:App@668,registry:App@882,registry:DemoExpiresAt@604,registry:DemoHost@553,registry:DemoID@536,registry:DemoLifetime@576,registry:DemoLifetime@685,registry:Host@374,registry:Host@676,registry:Kind@231,registry:Moved@386,registry:Region@462,registry:Replica@273,registry:Replicas@287,registry:Runtime@211,registry:Seed@308,registry:SeedSource@325,registry:Socket@348,registry:Unit@256 b8be2f735322dcd628e52e508d57644107fc3f7cf5c77568dd5252f9cc832dea
@legacy f7e471f6d9b9c791517fa8a1dc4c7e47d81bb0eb466c64775e515afdb6fe19a3 internal/provision/demo_policy.go stampDemoRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Copies public descriptor fields from the already-read record into the route; no new external read. registry:DemoExpiresAt@130,registry:DemoHost@100,registry:DemoID@89,registry:DemoLifetime@113 bdea1bb5b22514d290b278ce4d4fb6025c5145c4c8d02c84da1f7bfb9079ecce
@@ -90,7 +90,7 @@ internal/activator/hafiles.go ExecBackend.openHostFiles legacy accepted-legacy a
internal/activator/size.go SizedLimit legacy accepted-legacy accepted-legacy;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), through the activator's tier and GenTier; and, only with host claims on (shelved, Paul 2026-10-25), instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root) through claimBoundSnapshot in the bound-launch snapshot (claimproduction.go, r.Mode != agent);basis=root-route (J1, as ExecBackend.tier): new (#329 plan 3 Task 3): converts a route's size name (rt.Size, the agent-written registry column, which the agent's reconcile fills from the signed app policy) into a platform memory limit: the size table's row of that name, else the caller's fallback tier for an empty or unknown name (an unknown name logs once per host and value, rt.Host and rt.Size keying an in-memory map). No file and no root call of its own. In the agent the limit reaches root only as a start's or /parent's memory_max, which root checks against its own size table (now any of the four rows, 256 MiB to 2 GiB, and /parent any row or the sum of two, up to 4 GiB: the widened validators, spec section 5.3). In the shelved claim mode root itself takes the limit from the agent-written column, within the same table (claimroleassembly, claimlaunch_root);rev3=census-ruling-agent-start-demo-1;basis=Reads Route.IsDemo before ordinary size selection; returns the existing small table row for any demo marker. registry:Host@303,registry:Host@437,registry:Size@160,registry:Size@228,registry:Size@318,registry:Size@446 c4a515016bfd9b6879efbbb751493bd91eb670ca03618a004fc1859b25ce1180
internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop. data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 396bda0907b03093236b6022463bcc80781a689f6fcea28341d2d34c1176ae0d
internal/edge/wildcard.go newWildcardFromEnv legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-agent-start-demo-1;basis=Includes the configured demo domain in the existing wildcard manager's explicit parent input. registry:Host@6490,whole:WildcardDomain@6437,whole:WildcardDomain@6463 3ac9e1f8e14eefa124b8e56b64ffafac34392989e85fab89f9e2397768e70e3e
-internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker; no alternate data store. file:Exec@17790,file:Open@1150,file:Statfs@45979,registry:App@11502,whole:Route@11494,whole:Route@29564 6ead66510aad5025e087a59c67fb94c1619b9b2abf9bcadbeb3a104125ed7975
+internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. file:Exec@17790,file:Open@1150,file:Statfs@45991,registry:App@11502,whole:Route@11494,whole:Route@29576 ffc11cc147b9fb3afb787f02e7aba1e00dbd2e07e1b7d98ed30042fe01e7c964
internal/host/bootstrap.go bootstrapWith authority A,C,G,J4 root-input;kept=A,C,G;scope=protected-decision-only;rev3=census-ruling-region-ha-p1a;basis=root (carlos bootstrap, cloud-init or an operator; also the staging-root and -plan-json path system apply's stagePlan runs): after the units are written, calls retireUnits(root, retiredUnits) (retiredunits.go, a new unit on this card) to disable, stop and remove carlos-system-join.path and .service, which an earlier build installed; an error there fails the bootstrap; enabledUnits (a var, not a census unit) no longer lists carlos-system-join.path; the same two sites, no read added in this body;rev3=census-ruling-fresh-box-446;basis=#446: a live bootstrap runs systemd-tmpfiles --create /etc/tmpfiles.d/carlos.conf (the conf it just wrote, a fixed path) after the credentials repair and before arming units; a failure fails the bootstrap; the staging run prints the same step;rev3=census-ruling-agent-start-demo-1;basis=Uses demo settings from the existing host.env parser; refuses malformed demo config and installs the fixed template drop-ins. file:Command@11482,file:ReadFile@552,file:ReadFile@6958 a55f9f90065579c13a4cb4dfe73b4e4d44b76d69d6e500fc9d024d51f2e469df
internal/host/claimstop_run.go RunInstanceControl authority C,D,G rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control. 75aa3bf336c68d4859f5d0f4c49d44e23d672be99599fec58f7b91c083def5e7
internal/host/claimunit.go readClaimUnitSettings authority C,E3,G,J4 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=retains exact no-census unit settings; a claims-enabled complete census prepares the root-owned retry directory before the hardened controller starts;rev3=census-ruling-agent-start-demo-1;basis=Reads worker/concurrency/toolchain settings from the existing host.env parser; requires box mode and refuses claims coexistence. data-literal@140,data-literal@2064,data-literal@2648 d79f51da7979daeab8202510db8cf032a9b8ca154cf32df8f4e63c32683d6363
@@ -138,7 +138,7 @@ internal/host/claimstop_run.go instanceDemoPurgeGuard legacy accepted-legacy acc
internal/host/demo_cleanup.go demoWorker.retireDemo legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Agent reads signed receipt, matching tombstone and registry binding; holds route, invokes root, acknowledges and removes only its remote initialization marker. registry:Account@1038,registry:App@1065,registry:Assigned@1084,registry:DemoHost@1008,registry:DemoID@944,registry:DemoLifetime@970,registry:HoldOp@1224,registry:Host@1198,registry:Host@1527,registry:Region@1108,whole:Route@1470,whole:Route@927 5a7f4289921de219c89a3f46a08a002ae5f23fd784e080656799c1e359766b4d
internal/host/demo_jobs.go demoWorker.pickupHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads a bounded console pickup response; no bucket write or caller-selected execution input. file:ReadAll@615 fc59a4d264445d58fd6ee0060639b64e3773279b516ebe6b3bf3582767ec5c6e
internal/host/demo_policy.go demoDisabledFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads startup box configuration and the activator-held Route.IsDemo marker in memory, then the existing disabled-route predicate. Refuses a marked ordinary-box route without querying the registry. whole:Route@263 0738a87ea56e5b0457dd80f63474cdf819a83fc1dae50ff9741182f1b4afd38b
-internal/host/demo_policy.go demoPolicyHook legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Returns the original hook unchanged outside explicit demo mode, including nil: no registry read or new spawn refusal. In demo mode reads the route by host and the existing verified policy cache before the original hook. whole:Route@483,whole:Route@582 d62699e7c901025b075d9d6d5f023408a34e635790f934c87c49a23c1c6fc7cd
+internal/host/demo_policy.go demoPolicyHook legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Returns the original hook unchanged outside explicit demo mode. In demo mode reads the existing route and requires a fresh ReadyDemo verdict from the existing root control socket before checking the verified policy cache and calling the original hook. Missing capability, ordinary root mode, failed probe and stale build refuse the spawn. whole:Route@496,whole:Route@769 a13f61458da24c67c3c5903bf71c60130fa811bdf9c0482e7050f993493df1ec
internal/host/demo_policy.go demoRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads startup box/claims configuration and the caller-held route plus existing verified policy cache. Covers backend acquisition/probe preparation through ConfigGate without a new registry or bucket read. whole:Route@370,whole:Route@465 c42a8a4e0be94749d75f429e2d204d693d55c96da58229c680fd38b76207b5ff
internal/host/demo_policy.go installDemoUnitsIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads the same fixed drop-in files in demo mode. Outside demo mode removes the same two fixed managed filenames; ENOENT is silent, other removal errors are logged and retried next pass without aborting ordinary installation or skipping the second file. Successful removal still signals daemon-reload. Enabled-demo read/write failures still refuse. file:ReadFile@866 70d45eb14cd41baa8b55239a7491ec4cf9a9902c39712655add955b5376d5c72
internal/host/demo_units/demo.conf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Retains read-only /run and /var tmpfs overlays and all network/size restrictions. Resets InaccessiblePaths and restates /etc/carlos -/run/carlos-control so the hidden control directory need not exist during namespace setup; /etc/carlos remains required. No new source or bind. file:external@0 578cf8a0f5842e043ff26f1c1b2f62be0baab81e66f322773c3981b494c3da6c
@@ -147,7 +147,7 @@ internal/host/units/carlos-demo-builds.slice external legacy accepted-legacy acc
internal/instancectl/demo_build.go Client.DemoBuildReadiness legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads bounded root readiness and verifies capability, slots, digest and service build identity. file:ReadAll@709 abbb7980212aff48b695260c0f140d63327517e493d00a76f41fb2fe86597507
internal/instancectl/demo_cleanup.go Server.purgeDemoWithJobs legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Checks root config and current registry identity/hold; reads derived unit/cgroup/exe/drop-in state, stops and proves emptiness before no-follow removal. Fix round 1: passes the descriptor host to the root build-scratch cleaner; same registry, cgroup and derived path reads. file:Lstat@1638,file:ReadDir@2477,registry:Account@833,registry:App@871,registry:DemoExpiresAt@798,registry:DemoHost@676,registry:DemoID@655,registry:DemoLifetime@701,registry:HoldOp@762,registry:Status@734,whole:Route@1374,whole:Route@625 bbed24fd2c6a68a1a0038ef7b13817bb87b97564c15582401a4b61b4ea1fd316
internal/instancectl/demo_policy.go Server.demoCgroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads memory.max, cpu.weight, cpu.max and io.weight beneath root cgroupfs using platform-generated slice/unit names; checks both slice and unit before reporting started. file:ReadFile@395 734de40e9daa0756d5f1b9586aaa7c5810591e5525595e9bd888e7681dd2ca2b
-internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Serializes demo starts with purge and refuses missing/non-demo/held current routes. file:Query@469,file:Query@509,registry:Status@687,whole:Route@642 48928e72ca97b7a18acea2e7f38a7c67516a2a8c4b7e6dc27fa07bd064e7df6f
+internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Serializes demo-mode starts with demo purge; ordinary starts retain their existing unit locking. Uses the existing HostDemo callback to read the fixed service registry for a valid requested host in ordinary mode too; read errors and any demo-marked row refuse that start. Demo mode retains missing/non-demo/held-row refusals. No caller-named filesystem path is opened. file:Query@450,file:Query@490,registry:Status@707,whole:Route@662,whole:Route@738 201bc63347bee7b1bc354e11820e12e427b1573aa6fdf551ca43b6a66965e418
internal/instancectl/demo_versions.go Server.purgeDemoVersions legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Derives account/app from root config and host; reads registry/live/generation pins and staged entries; deletes only unreferenced demo app files. Fix round 1: logs and skips ENOENT resolving another live link; other errors still refuse, same pin and symlink reads. file:EvalSymlinks@1980,file:ReadDir@1387,file:ReadDir@1850,registry:Account@2336,registry:App@2361,registry:Host@885,whole:Route@1221,whole:Route@2321,whole:Route@842,whole:Route@871,whole:Route@908,whole:Route@924,whole:Route@932 e7d139663a400bb09ef051ff764396000923fe321fb7a4c86bb697bd3f28d9de
internal/provision/demo_policy.go PolicyCache.AssertDemoRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads route identity/runtime/placement, box configuration and verified cache entry under its mutex; refuses absent/expired/mismatched policy with no store request. registry:Account@656,registry:Account@870,registry:App@668,registry:App@882,registry:DemoExpiresAt@604,registry:DemoHost@553,registry:DemoID@536,registry:DemoLifetime@576,registry:DemoLifetime@685,registry:Host@374,registry:Host@676,registry:Kind@231,registry:Moved@386,registry:Region@462,registry:Replica@273,registry:Replicas@287,registry:Runtime@211,registry:Seed@308,registry:SeedSource@325,registry:Socket@348,registry:Unit@256 b8be2f735322dcd628e52e508d57644107fc3f7cf5c77568dd5252f9cc832dea
internal/provision/demo_policy.go stampDemoRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Copies public descriptor fields from the already-read record into the route; no new external read. registry:DemoExpiresAt@130,registry:DemoHost@100,registry:DemoID@89,registry:DemoLifetime@113 bdea1bb5b22514d290b278ce4d4fb6025c5145c4c8d02c84da1f7bfb9079ecce
@@ -178,10 +178,10 @@ internal/provision/reconcile.go RouteFor authority C,E3 rev3=census-ruling-self-
@coverage internal/demobuild c01e441fb181ec2ed2671874d32d4db0291c5197d366c1744e9f7df02442fbb2
@coverage internal/domains 2e1fcc08678178e4b0fca9a1bf1b8e25cb7d17720f68f596e0af6b8e365fb3c0
@coverage internal/edge f43ea4eef8001f42945c1608d7e33e94fa0af57bae1a9810f99dd6ce7ab5df70
-@coverage internal/host 2f22c79191301ea58f0b2ff96a7bce0f18ef6280ae158c66daeb3762e91add4c
+@coverage internal/host 524a92580e7544b2a2fa685e795b6c7120ba513bedd02803925de838e9d5d22b
@coverage internal/host/demo_units c6c9477377076760c308b460eee45f42f275476a3a919ada7f743fb68aac05c2
@coverage internal/host/units b1160033f0a1511ef378de68191240e89e9f2b54cb9c24e27bb8e675d5762035
-@coverage internal/instancectl fa4d96268b42f98e8d78ba3ac88da41aab3b7297eb42ea585a146dc71829bcb0
+@coverage internal/instancectl b0e7221db94b3768bc0baf4f38af30cfde9d1883c3fb5768ec304799f05565bf
@coverage internal/provision aac23b6b9652d341c8098ff642aad56e085ce1ed00ca76c88b474caf0fd56b44
@coverage internal/registry b771760cec4f5814a844c447a453da6ed3bbcd3dd64cc9ab75feee72de4beaab
@coverage internal/release 9ba0535f01abd88e60c598593362d92e6c9fe33a675bfa1d939ca9b9db2ba511
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index b1aac45e5..c2603d5a7 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -60,4 +60,4 @@ plan14-root-reads-region-ha-p1b3a.tsv 5d20b3777026e43906bfba301186bce0ae58daa9d8
plan14-root-reads-stateless-replicas-1.tsv df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771
plan14-root-reads-domain-registration-1.tsv 8e7126042fef8cc99899a29e9e06c22763a24b6677110144035ec57fcc2de23e
plan14-root-reads-edge-held-streams.tsv c61b055182bf84e822fab92199432bd2d462c268c03ead17c3cfa18f09bd82cd
-plan14-root-reads-agent-start-demo-1.tsv f3328a22e4d406134595d9c4ae8b28f7af17568f6a6092949386227b8b857e5c
+plan14-root-reads-agent-start-demo-1.tsv 39197c39b76e49a8e06c46a8b42c091d842710ffed16fa67cdd283fd93da5033