agent-start-demo-3
Prompts
<task-notification> <task-id>bgk5at03r</task-id> <tool-use-id>toolu_01AhzcPf5NwLpPFcoRWMwLr8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bgk5at03r.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/refresh.done ]; do sleep 30; done; tail -3 $S/refresh.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bzxaabb6o</task-id> <tool-use-id>toolu_01QkDWSVAR9vQpNYMqtiGUsg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bzxaabb6o.output</output-file> <status>completed</status> <summary>Background command "amadan task set 564 -status Started >/dev/null; echo "Task 1: dispatched BASE 00785917 (codex t1)" >> .superpowers/sdd/2026-11-04-agent-start-demo-3-claim/progress.md S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t1.done ]; do sleep 30; done; tail -2 $S/t1.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a6cf2a4b8b37a6fe0</task-id> <tool-use-id>toolu_01KL48CG2bvWpwKwJUCGxHkS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a6cf2a4b8b37a6fe0.output</output-file> <status>completed</status> <summary>Agent "Review Task 1 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>1) **Spec compliance: ✅** - **Endpoints and gate.** All four agent routes are registered (apidemo.go:272-275). GET `/demo/claim` is unchanged. Every handler goes through `demoClaimGate` (demo_claim_auth.go:39). That gate sets no-store, refuses when the R5 switch `demoClaimEnabled()` is off (demo_claim_auth.go:17), then applies the origin check. - **Start order matches `handleContinue`.** The order is: submit cap, Keymail discovery, `mailReady`, then `signinSend` / `HoldEmailChallenge` (demo_claim_auth.go:136-184, compared against server.go:3813-3866). So the no-mailer 503 comes before any send-limit decision, and the public-lookup failure falls back to email through the shared `keymailAddress`. - **Shared limits.** Claims use the same `s.limits` methods as ordinary sign-in: `submit`, `signinSend`, `reserveGuess` and `newPerson`. The 5-wrong-codes-per-challenge burn comes from `TakeEmailCode`. - **Flow token storage and lifetime.** The flow token is a canonical 32-byte base64url value, and only `hashToken` of it is stored (demo_claim_store.go:31-35). Lifetime is `min(now+15m, life.ExpiresAt)` (demo_claim_store.go:93-97). A resend only reads the existing row, and its rebind check is in demo_claim_auth.go:126-129 and :172-174. - **Purpose binding.** `challengeBinding` adds `ChallengeDemoClaim` → `flow_hash` (emailsignin_store.go:103). `deleteBound`, `LiveEmailChallenge` and `HoldEmailChallenge` all filter on `purpose = ?`, and the code MAC binds to the row's link hash. A sign-in, step-up, other-flow or superseded code therefore cannot match. Ordinary `handleEmailCode` only reads `ChallengeSignIn`, so claim codes cannot reach `finishSignin`. - **Atomic consume.** `TakeEmailCode` / `TakeEmailLink` consume atomically. `proveDemoClaim` then does a conditional `UPDATE ... WHERE person=''`, rechecking generation, lifetime and expiry in SQL, under the flow lock and the demo lock (demo_claim_auth.go:240-298). Exactly one proof results. - **Email link.** GET only peeks and renders a page (demo_claim_auth.go:346). POST passes the existing nonce/cookie/sameOrigin check, then the claim's own scheme+host check, then dispatches by purpose before the `finishSignin` branch (emailsignin.go dispatch hunk). - **No credentials issued.** No session cookie, CLI token or grant is created. `apps.expires_at` is never written. The migration is additive (`CREATE TABLE/INDEX IF NOT EXISTS`). The new table is classified in `claimSQLTables` and in the mutation inventory. - **Strict JSON.** Body capped at 4 KiB, string-only exact keys, duplicates refused (including escaped spellings, since keys are decoded), trailing tokens refused. No cookies are read on agent endpoints, and no CORS headers are set. - **Extra files are justified.** store_gate.go, claim_invariant_test.go (required by the census classification) and demo_claim_copy.go (Ruling R8). - ⚠️ I did not run the tests. The report's RED/GREEN evidence is unverified by me; the reported test bodies match the assertions in the brief. 2) **Findings** No P1. No P2. **P3-1. Mail error logging lost for all email sign-in and step-up sends.** Fault family: operability, a shared-path side effect. - Evidence: emailsignin.go `sendChallengeAsync` changed `%v` to `(%T)`. - Failure scenario: every real SMTP or provider failure on ordinary sign-in and step-up now logs only a Go type. The trigger was a hypothetical mailer that echoes the message body. - Fix: keep the error text but redact. For example, have `sendChallengeAsync` take the code and link and `strings.ReplaceAll` them out of `err.Error()`. **P3-2. Users created by claim proof get no first-sign-in record.** Fault family: audit completeness. - Evidence: demo_claim_auth.go:266 discards `created` from `ResolveSignIn`, and calls neither `auditSignInRow` nor anything equivalent. A later ordinary sign-in sees `created=false` (signinmethods_store.go:104), so the first-sign-in audit and the welcome cookie (emailsignin.go:291) never happen for that person. - Fix: audit person creation at proof, or have Task 2 do it when it mints the account. **P3-3. New-person cap refusal tells the user to request another email.** Fault family: refusal accuracy. - Evidence: demo_claim_auth.go:263-265 → verify answers 401 `demoClaimBadProof` ("Request another email") after the code was already consumed. - Failure scenario: retrying hits the same cap. Ordinary sign-in answers 429 "signup busy" here instead. - Fix: a distinct 429 with its own copy constant. **P3-4. `demoClaimAccountChoice` branches on `r.URL.Path == "/api/demo/claims/select"`.** Fault family: fragile seam. - Evidence: demo_claim_auth.go:303. - Fix: Task 2 replaces this with an explicit parameter. **P3-5. `proveDemoClaim`'s UPDATE uses `time.Now()` twice instead of the `now` it was given.** Fault family: consistency. - Evidence: demo_claim_auth.go:279. - Not exploitable, since wall clock only moves forward. **P3-6. The `otherDemo` and `otherFlow` cases test against a held, unsent challenge.** Fault family: test strength. - Evidence: in the test, the second `claimStart` for the same address falls inside the 60 s gap, so the target challenge is held rather than sent. - The binding mechanism (link-hash MAC plus purpose/flow filter) is still what refuses the code. But a sent rival challenge is never exercised. - Fix: advance `s.limits.now` past the gap before the second start. **P3-7. Nothing deletes `demo_claim_flows` rows yet.** Fault family: retention. - The report says Task 5 owns this. Make sure it is on Task 5's checklist, because flows accumulate at up to 30 per IP per hour per demo until then. 3) **Strengths** - Both the store and the proof write recheck generation, lifetime, state, purge and the token hash inside SQL, not only under the lock. - The over-submit-cap path writes nothing and returns a decoy with an identical response shape. - `HoldEmailChallenge` reuse keeps a sent code valid after a throttled resend, and the tests cover this. - The link GET is cross-site tolerant and never spends. Link POST dispatches by purpose before anything sign-in related can run. - The tests include real store reopen, plaintext-in-SQL scans, the SQL gate refusal and a stale-binding matrix. 4) **Verdict: READY**</result> <usage><subagent_tokens>121496</subagent_tokens><tool_uses>17</tool_uses><duration_ms>244941</duration_ms></usage> </task-notification>
<task-notification> <task-id>b7qrpxab4</task-id> <tool-use-id>toolu_01WMXMPmC9e7BiFDTQBzL5iZ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b7qrpxab4.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t2.done ]; do sleep 30; done; tail -1 $S/t2.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a64f11241eab083f6</task-id> <tool-use-id>toolu_019nUDkhTrQKsrsbRKA9Uohe</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a64f11241eab083f6.output</output-file> <status>completed</status> <summary>Agent "Review Task 2 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>1) **Spec compliance: ✅**, with one test regression listed under P2. - **Interfaces.** `chooseDemoClaimAccount`, `reserveDemoClaim`, `claimTarget`/`claimOp` and `demoClaimMutationRefusal` match the brief. `claimOp` also carries `SourceExpiresAt`, which is harmless. - **Rulings.** R1 is honoured: `demo_claim_auth.go:303-344` wires verify and select. R2 is honoured: the `demoClaimCapabilitiesReady` seam is at `demo_claim_target.go:73`. - **Task 1 follow-ups.** All three are folded in: the explicit `explicit` parameter, the first-sign-in audit with no session, and the 429 `errDemoClaimSignupBusy`. - **No source effects.** Reservation does not freeze, call a box or publish. - **Status after reservation.** It returns 202 `claiming`/`reserved`. - **Files outside the Modify list.** `apicli.go:228` and `apiinstances.go:1806` were not edited. They are covered through the shared gates instead. I checked that `handleAPIShip`, `handleAPIPromote`, `handleAPITrashApp`, `handleAPIRunCreate` and `handleAPIPipelinePut` all go through `apiAccountApp`. `handleAPIInstanceCreate` goes through `instanceGate`, which calls `apiAccountAppSaying` (`apicli.go:94`). Browser writes go through `accountApp` (`server.go:4318`). - **Placement check.** `region != s.cfg.Region` (`demo_claim_target.go:134`) is correct. Both values use the record vocabulary, where "" is the home region (`server.go:661-665`). The same comparison is used at `apiinstanceimport.go:133`. - ⚠️ **Cannot verify from the diff:** - Whether the over-cap grace pass or account deletion would hit a pending target through a door that skips the shared gates. - That Task 4/5 will create the destination record with exactly `op.Target.Host`. The counting key `app+"/"+host` depends on it. 2) **Findings** **P2-1. A Task 1 proof-binding test now passes no matter what the code does.** - **Where:** `internal/console/demo_claim_store_test.go:208` (`TestDemoClaimProofIdentity/staleLifetimeAndGeneration`). - **Problem:** The test asserts `claimVerify(...).Code == 200 → Fatal`. After this task, a successful verify returns 202 (claiming) or 200 only for `account_required`. The test has no `claimNoProof` backstop, unlike lines 77 and 139 and `auth_test:340`. - **Failure scenario:** `proveDemoClaim` stops rechecking lifetime or generation. Verify then answers 202, or 503 when the reservation's own recheck refuses. The test still passes, so the stale-binding witness for Review Focus 1 is gone. - **Fix:** Assert `w.Code == 401` and call `claimNoProof(t, s, flow)` inside the loop. - **Fault family:** proof binding (a code for another lifetime or generation grants nothing). **P3 (follow-ups)** 1. **A failed pipeline write fails the request even though the reservation stands.** - **Where:** `finishDemoClaimReservation` (`demo_claim_target.go:224-232`). - **Problem:** A pipeline write failure becomes a 503 "Try again". The reservation is already durable, and status already reports `claiming/reserved`. - **Why it matters:** On the verify path the code is already used up, so a retry gets 401. A freshly minted personal account's sqid was never sent to the client, so it cannot retry through select either. - **Fix:** The ordinary create (`server.go` after `ensureAccountManifest`) treats `SetPipeline` failure as log-only. Do the same here: log it, return 202, and let Task 5 recovery re-ensure the pipeline. - **Fault family:** retry semantics. 2. **Misleading 503s for permanent conditions.** - **Where:** `demoClaimAccountError` maps `ErrDemoToken` (expired or retired demo, stale flow) to 503 `demoClaimReserveFailed`. Separately, `claimReserved`/`claimInvalid` outcomes return 503 instead of a clear refusal (`demo_claim_target.go:~176`). - **Why it matters:** These invite pointless retry loops. - **Fix:** Use `demoError(w, ErrDemoToken)` for the first case. 3. **Materialisation logs a failure for every pending claim.** - **Where:** The `settleApp` guard (`settle.go:78`) returns an error for a pending target. - **Why it matters:** `materializeAppsJudged` (`lifetimes_purge.go:323`) then logs and calls `jobFailed` for each pending claim. For a live, unmarked row, settle would do nothing anyway. - **Fix:** Return nil for pending targets, like the existing `DemoID` early return. 4. **The guard hides a programming-error signal in claims mode.** - **Where:** The `withAutoAppSQL` guard (`claim_sql_auto.go:15`) runs before the `outerInsideView` check. - **Why it matters:** An outer-store call made inside a view now reports "unavailable" instead of `errOuterStoreInView`. Demo claims refuse claims mode anyway. - **Fix:** Move the guard after that check. 5. **The record-lock guard can never pass the operation's own context.** - **Where:** `withRecordLock` checks the guard with `context.Background()`. - **Why it matters:** Task 4/5's operation-owned destination record write must use a create path that passes its context (`createRecordMarked`/the lifetime create). This should be recorded in the Task 5 brief. 6. **The isolation test checks labels, not doors.** - **Where:** `TestDemoClaimTargetIsolation`'s action loop only calls `appMutation` with label strings. - **Mitigation:** The real door coverage is the shared `apiAccountApp` HTTP witness plus the service-mint witness. That is acceptable, but the loop proves less than its names suggest. 7. **Bucket reads under the source demo app lock.** - **Problem:** The source demo app lock is held across up to 17 rounds of name checks (`apexHolder`, prefix list, policy read) plus a channel and manifest read. - **Why it matters:** The demo's own lifecycle paths wait meanwhile. It's not a protocol breach, since this is bucket I/O and not a transfer wait. 3) **Strengths** - **Atomic reservation.** One SQLite transaction (`reserveDemoClaimRows`) under the demo writer lock writes the app row, the `demo_claim_op` marker and the op row. It rechecks membership/role, account liveness, flow expiry, lifetime, generation, token, serving switch and active job, with partial unique indexes as backstops. - **Counting.** It reuses the ordinary `runningThings` and subtracts only the app/record already counted. Trashed or missing destinations keep both slots. Retry reuses the op without rechecking caps. - **Account choice.** It is exact-sqid only, ignores MRU, and returns an identical `http.NotFound` (with no-store from the gate) for foreign, deleted, name, missing and empty IDs. The person lock is held for minting with `checkNewFreeAccount`. - **Ordinary create unchanged.** Extracting `validateClaimAppName` is behaviour-preserving for ordinary creates. The claim passes `ownerClaim=false`, uses no client destination, and skips names with a stale policy rather than clearing it. - **Lock order.** It follows the protocol: person lock for mint only, then the account, then sorted app locks, then hostname, then the SQLite writer. 4) **Verdict: READY AFTER FIXES** (P2-1).</result> <usage><subagent_tokens>171356</subagent_tokens><tool_uses>47</tool_uses><duration_ms>495548</duration_ms></usage> </task-notification>
<task-notification> <task-id>bjyoml2oj</task-id> <tool-use-id>toolu_019MC7qBTvVeu8uNzEN4bTp5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bjyoml2oj.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t2fix.done ]; do sleep 30; done; tail -1 $S/t2fix.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b03ne3980</task-id> <tool-use-id>toolu_01APFMSBiK1CN3bCGVBqvx7h</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b03ne3980.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3.done ]; do sleep 30; done; tail -1 $S/t3.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bwksb3zug</task-id> <tool-use-id>toolu_01M23QHYTxpmGYEPVmC3wmJy</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bwksb3zug.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3b.done ]; do sleep 30; done; tail -1 $S/t3b.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bp2psr0a8</task-id> <tool-use-id>toolu_01J1vkw8J4m6vdDFroDP6AvZ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bp2psr0a8.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3c.done ]; do sleep 30; done; tail -1 $S/t3c.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b2dg2o101</task-id> <tool-use-id>toolu_01KtD4FzmaEhAm7FBHrpY6V8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b2dg2o101.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3d.done ]; do sleep 30; done; tail -1 $S/t3d.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>ae3358749d8f7d5c5</task-id> <tool-use-id>toolu_01Kk96kXsQcaqErQpRm5u32f</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/ae3358749d8f7d5c5.output</output-file> <status>completed</status> <summary>Agent "Review Task 3 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Task 3 review, round 1 of 3: NOT READY.** Two P1 defects block merge: a deadlock between root's snapshot and purge doors, and a snapshot startup failure that kills root control on the whole demo box. ## 1) Spec compliance: ❌ (because of the P1s; the interface surface is complete) - **Interfaces all present.** `Work`/`SignWork`/`VerifyWork`, `claimDemo`, `FreezeDemo` on `POST /demo-freeze`, `ExportSQLite`/`Snapshot`, `SnapshotDemo` on `POST /demo-snapshot`, `RunSnapshotWorker` with private `__demo-snapshot` dispatch (`main.go:38`), `Record.DemoClaim`, `StreamMessage.Claim` and `WorkerReady.ClaimCapability`. `EmptyBuild` ignores the claim capability. - **Files the brief listed but the diff does not touch, all justified:** - `internal/console/apidemobox.go`: moved to Task 5 by R3. - `internal/host/bootstrap.go`: the existing `units/*.service` embed glob already installs the new unit. - `internal/instancectl/demo_policy.go`: its existing `/start` gate already refuses held demo rows. - **Not verifiable from the diff (⚠️):** - How `FenceAndStopAs` returning `ErrStopUnproven` interacts with the real activator's `Quiesced` after an agent restart (`demo_claim_executor.go:157,166`). Only fakes cover it. - Whether systemd's mount of the snapshot disk propagates into instance-control's own mount namespace (that service runs with `ProtectSystem=strict` and `StateDirectory`). - What writing up to 256 MiB through instance-control does to its page cache under `MemoryMax=64M`. - **Requirements resting ONLY on the gated tests** (`CARLOS_DEMO_CLAIM_DEV_WITNESS=1`: `TestDemoClaimFreezeDevWitness`, `TestDemoClaimSnapshotUnitDevWitness`, `TestDemoClaimSnapshotRuntimeDevWitness`): - real cgroup stop proof for freeze, and zero data reads after an unproven stop on a real box; - helper memory ≤256 MiB and OOM kill, `RuntimeMaxSec` ≤120 s, and descendants killed; - the 768 MiB scratch reservation actually enforced (fallocate, mkfs.ext4, loop mount, ENOSPC); - credentials and sibling data unreachable; network and control sockets denied; - "cancel leaves no helper or scratch" against real systemd; - the effective-unit property readback matching systemd 257's exact `show` formatting. ## 2) Findings ### P1-1. ABBA deadlock between the snapshot door and demo purge (lock ordering, root availability) **Evidence:** - The snapshot handler takes `buildPurge` exclusively through `AcquireSnapshot` (`internal/instancectl/demo_snapshot.go:148`, `internal/demobuild/snapshot_slot.go:8`). - While holding it, the handler calls `snapshotHeld` again at `demo_snapshot.go:217` and `:236`. `snapshotHeld` enters `s.DemoPurgeGuard` (`:70`). - In production that guard is `instanceDemoPurgeGuard` (`internal/host/claimstop_run.go:276`). It takes `lockAdoptPass`, which is a blocking `syscall.Flock(LOCK_EX)` (`internal/host/flock_unix.go:13`) and ignores the context. - Purge locks in the opposite order: `handleDemoPurge` → `DemoPurgeGuard` (adopt flock) → `lockDemo` (`demo_cleanup.go:85`) → `PurgeDemo` (`:102`) → `buildPurge.Lock()` (`internal/demobuild/purge.go:21`). **Failure scenario:** 1. An export is running. That is up to 120 s, and includes the case where the source demo expires mid-export, which the plan explicitly expects ("source expiry still wins"). 2. A retirement purge with jobs arrives for any demo on the box. 3. Purge takes the adopt flock and blocks on `buildPurge`. 4. The snapshot handler reaches its recheck and blocks on the flock. 5. Both goroutines hang forever. The 120 s socket deadlines cannot interrupt either a flock or a `sync.RWMutex`. **Impact:** the adopt-pass lock stays held until instance-control restarts. Every adopt, stage, restart and config-sync pass on the box hangs, along with builds, purges and readiness (`recoverPurge` also takes `buildPurge.Lock`). **Fix:** never take `DemoPurgeGuard` while holding `buildPurge`. Either: - recheck under `lockDemo` plus `HostDemo` only, after the slot is held; or - acquire the snapshot slot inside one `DemoPurgeGuard` scope held for the whole export. Add a test that runs a purge with jobs concurrently with an export, using the production guard's lock order. ### P1-2. Any snapshot-recovery or template-check failure kills root control on the box (blast radius, "capability only when fully wired") **Evidence:** - `Serve` returns the error from `s.snapshots.initialize(ctx)` (`internal/instancectl/server.go:378`). `runWithClaim` then calls `log.Fatalf` (`:366`). - `initialize` (`demo_snapshot.go:449-510`) fails on many things: a missing or non-0700 `/var/lib/carlos-demo-snapshots`, any unexpected entry or unit name, any cleanup failure such as a busy unmount, or any `checkUnit` property mismatch. **Failure scenario:** a demo box gets the new binary before its `carlos-instance-control.service` gains `StateDirectory`. Note `ensureSystemUnits` only installs missing units. Or the snapshot template is absent, or real systemd formats one of the ~45 asserted properties differently, or a leftover mount won't unmount. Then instance-control crash-loops: no `/start`, `/stop`, purge or builds for every Plan 1/2 demo on the box. This happens even though `CARLOS_DEMO_CLAIM` is off, because the root side runs whenever `DemoBox` is set. **Fix:** log the failure, leave `ready` false (so no claim capability is advertised), and keep serving. Retry recovery from the readiness path if desired. ### P2-1. WAL check refuses legitimate WALs that contain stale frames (snapshot correctness) **Evidence:** `checkWALBounds` (`internal/democlaim/snapshot.go:186-208`) requires every frame in the file to match the header salt and continue the checksum chain, and requires the file size to be a whole number of frames (`:173`). **Why that is wrong:** SQLite reuses a WAL from the start after a checkpoint, with new salts, and does not truncate it unless `journal_size_limit` is set. Frames past the last valid commit therefore normally carry the old salt. A process killed between SQLite's frame-header write and page write also leaves a torn tail. **Failure scenario:** a demo app that has passed one auto-checkpoint and is stopped without a clean close always fails export with `DEMO-CLAIM-SNAPSHOT`. It fails closed, but claims will not work for a common class of apps. **Fix:** follow SQLite's recovery rule. Validate the prefix up to the first frame with a salt or checksum mismatch, or a partial frame, and apply the page-number bound only within that prefix. Frames past that point are not committed data by SQLite's own definition. Add a test with a reused WAL and a torn tail. ### P3 (follow-up list) - **P3-1. A failed snapshot cleanup does not block builds for long** (one-export-per-box budget). `release(false)` poisons the builder, but `recoverPurge` clears the poison by running the build cleanup, not the snapshot reap (`snapshot_slot.go:99-107`, `purge.go:66-89`). Builds can resume while the helper's stop is unproven. Exports stay off because `p.ready` is false. Keep builds poisoned until the snapshot unit is proven stopped. - **P3-2. The close door can fill the session table** (control-socket DoS). It registers placeholder sessions for unknown transfer IDs (`demo_snapshot.go:295-300`). Any vetted peer can fill all 64 slots and refuse exports for about 150 s. - **P3-3. A failed hold restore still advertises claim capability** (capability gating). `Connect` closes serving when `restoreDemoClaimHolds` fails (`demo_jobs.go:425-434`), but `demoClaimCapability` stays advertised. Clear it on recovery failure. - **P3-4. The agent's digest check runs after the console has accepted the upload** (verification order). `uploadDemoClaimHTTP` wraps the body in `LimitReader(size)` (`internal/host/demo_claim.go:85`), so the body's hash check only runs at `Close`, after the console's 204. It is safe only because the contract says the console verifies the digest itself; Task 5 must actually do that. ### Root census: new root reads and actions (for the R9 overlay) - **`/demo-freeze`:** reads the route via `HostDemo` (written by the agent, as for purge), stats the cgroup parent, and runs `systemctl list-units`/`show`. It reads the `ExeRoot` and `DropInDir` directories (shared `stopDemoUnits`) and checks `cgroup.events`. It reads no data files. - **`/demo-snapshot`:** - reads `HostDemo` three times and runs `Statfs` on the snapshot root; - writes `/run/systemd/system/<escaped>.mount`, whose content uses only paths built from a validated job ID; - runs `/usr/sbin/mkfs.ext4` on an image root itself created; - reads `/proc/self/mountinfo` and `system.slice/carlos-demo-snapshot@<id>.service/cgroup.events`; - **after reaping the helper, reads files the helper wrote:** `work/result.json` (≤1 KiB, strict JSON, `openat2` without following symlinks, regular file only, `O_NONBLOCK`, so a FIFO is safe) and `work/snapshot.db` (`OpenSource`: link count 1, unchanged check, re-hashed). - **Restart recovery:** `ReadDir` of the snapshot root, `list-units` with a pattern, and `os.Root.RemoveAll` of validated IDs. **Assessment:** root never runs SQLite, never opens a path an agent or tenant supplies, and never follows a symlink. The helper-written reads are what the brief requires ("result.json validated independently and re-hashed") and are adequately constrained. I am not raising them as P1. No existing root check is weakened: the `stopDemoUnits` extraction keeps purge's checks and their order. ## 3) Strengths - Work is tightly bound to box, fleet, lifetime, generation and action, with strict JSON and domain-separated Ed25519 signatures. Freeze and export deadlines are capped at demo expiry, and abort gets a fresh 30-second window. - Pickup is authenticated and re-checked before the hold, before export and before ack. Abort requires `RollbackProven`, an absent record hold, an unexpired demo and its own hold. - The persistent hold covers every path: `RouteFor`/`mintHeld`, `holdExisting`, `demoFixed`, `TombstoneBody`, `AssertDemoRoute`, `demoJobAllowed`, `convergeAdopted`, the root `/start` gate and retirement's `HandHold`. - Source files are opened without following symlinks, with link-count and unchanged-file checks. Missing DB, empty DB and over-256 MiB are refused, and there is no empty fallback. - Fixed multipart fields with no filenames, declared-length streaming, the loop-image disk reservation and an exact unit-property readback. ## 4) Verdict: NOT READY The P1s are P1-1 (snapshot/purge deadlock) and P1-2 (fatal snapshot initialization takes down instance-control). P2-1 (WAL stale-frame refusal) should be fixed in the same round. Files: - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/instancectl/demo_snapshot.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/instancectl/server.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/democlaim/snapshot.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/demobuild/snapshot_slot.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/host/claimstop_run.go</result> <usage><subagent_tokens>190930</subagent_tokens><tool_uses>38</tool_uses><duration_ms>486170</duration_ms></usage> </task-notification>
<task-notification> <task-id>brp3ptfmk</task-id> <tool-use-id>toolu_01JzV5vEbPiBKwuYz23LaoaF</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/brp3ptfmk.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3fix.done ]; do sleep 30; done; tail -1 $S/t3fix.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>ad121279a077d2ff2</task-id> <tool-use-id>toolu_01PNEQ48RtaHp3vU2gzYG84x</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/ad121279a077d2ff2.output</output-file> <status>completed</status> <summary>Agent "Re-review Task 3 fix round 1" 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.** All six round-1 findings are fixed. One new P2 needs fixing first: a failed snapshot recovery after an instance-control restart no longer keeps builds closed. I found no P1s. I ran no tests; everything below comes from reading the code. ## Round-1 findings **P1-1, lock order: ADDRESSED.** - `internal/instancectl/demo_snapshot.go:135-148`: `handleDemoSnapshot` takes `DemoPurgeGuard` (the adopt flock) once, before the snapshot slot. It keeps it through streaming, cleanup and slot release. - `demo_snapshot.go:64-80`: `snapshotHeld` no longer takes the guard. It does the same field-for-field hold recheck under `lockDemo`, and runs at the start, after the upload and before streaming. - Every lock order I traced is now acyclic: - Purge: guard → `lockDemo` → `buildPurge.Lock` (`demo_cleanup.go:62-65`, `:85`, `purge.go:21`). - Freeze: guard → `lockDemo` (`demo_claim.go:62`, `:81`). - Snapshot: guard → `lockDemo` (released) → busy → `buildPurge.TryLock` (`snapshot_slot.go:8`) → `lockDemo` again. The only inversion against purge is inside the guard, and the guard is a flock on a fresh descriptor each time, so it shuts out other goroutines in the same process too. - Build: `buildPurge.RLock` only (`worker.go:197`). - Start gate: `lockDemo` only (`demo_policy.go:28`). - `ensureReady`: `initMu.TryLock` → busy CAS → `buildPurge.TryLock`. It never takes `lockDemo` or the flock. - Nothing inside the export calls the guard again, so it cannot deadlock on its own flock. - `demo_snapshot_fix_linux_test.go:58` exercises the production order with a real flock. **P1-2, crash on snapshot init failure: ADDRESSED.** - `server.go:377-379`: `Serve` calls `ensureReady` and ignores the result, so `runWithClaim`'s `log.Fatalf` can no longer fire for this. - `demo_snapshot.go:466-497`: retry happens only on demand, at most once every 5 s. It is serialised by `initMu`, `busy` and the builder slot. - Exports are refused with 503 until recovery succeeds (`:97`). Claim capability is advertised only when `ready` is set (`demo_build.go:96-107`). - `ready` is set only at the end of `initialize` (`:500`, `:558-561`). Each export still does its own `assertUnit`, disk-space check and hold recheck, so a half-initialised provider cannot serve. **P2-1, WAL recovery prefix: ADDRESSED.** - `internal/democlaim/snapshot.go:152-218`: the WAL header is still checked strictly and a bad one is refused. - Scanning stops at the first salt mismatch, bad checksum or partial frame. Checksums chain from the header checksum, and byte order follows the magic's low bit, as SQLite does. - Page limits apply only to frames that pass validation. The copy is truncated after the last valid commit frame, or at 32 bytes if there is none. - This runs only on the helper's private copy and only without root (`finishSnapshot` at `:81-86` refuses euid 0). No shared-memory file exists in that copy, so SQLite rebuilds its index from the truncated WAL. - Stopping at the first invalid frame matches SQLite, so committed frames after it are correctly dropped, and SQLite sees exactly what the scan validated. - One harmless difference: an uncommitted frame with a valid checksum but an out-of-range page number is refused rather than ignored. That fails closed. **P3-1, poison until the unit is proven stopped: ADDRESSED** for a live process. - `purge.go:69-75`: `recoverPurge` refuses while snapshot poison is set and never runs build cleanup for it. - `snapshot_slot.go:24-29`, `:33-46`: only `RecoverSnapshots` clears snapshot poison, and only after `initialize` has stopped the helper. - Every failure path in `p.cleanup` (`demo_snapshot.go:407-428`) clears `ready`, so the next readiness probe retries recovery. - The restart case is not covered; see the new P2 below. **P3-2, unknown close IDs: ADDRESSED.** - `demo_snapshot.go:314-320`: no placeholder session is created, and an unknown ID gets 409. **P3-3, capability after failed hold recovery: ADDRESSED.** - `internal/host/demo_jobs.go:357-360`, `:480-482`: `ClaimCapability` is cleared before readiness is published, and `demoClaimCapability` reads it (`demo_claim_executor.go:37`). ## New findings **P2-A: a restart with a failed snapshot reap admits builds while the helper may still be running.** - `snapshotPoisoned` lives only in memory and starts false (`worker.go:49`). Only `AcquireSnapshot`'s release sets it. - Scenario: instance-control restarts mid-export. The `carlos-demo-snapshot@` unit is its own systemd unit, so it outlives the restart. - `Serve` → `ensureReady` → `RecoverSnapshots` → `initialize` → `cleanup` fails (stop or unmount error). `RecoverSnapshots` returns the error without poisoning anything (`snapshot_slot.go:38-40`). - `Worker.available()` (`worker.go:149`) is then true. `handleDemoBuildReady` ignores what `ensureReady` returns (`demo_build.go:96-99`). Builds are advertised and admitted while the old helper and its scratch may still exist. - This breaks the brief's rule: "serialize it with the builder slot; kill/reap before returning or cleaning scratch, including restart recovery." Before the fix, this case crash-looped, so no build could run; the soft-init change opened it. - `RuntimeMaxSec=120` limits the overlap, but a failed stop is exactly the case where nothing proves that limit held. - Suggested fix: set `snapshotPoisoned = true` in `RecoverSnapshots` when the reap fails, or start a demo-box worker poisoned until the first successful `RecoverSnapshots`. Add a regression test where initial `cleanup` fails and builds stay unavailable until it is repaired. - Fault family: snapshot cleanup work must keep builds closed until the helper is proven stopped. This is the same family as round-1 P3-1, now reached through the P1-2 restart path. **P3-a: the export now holds the adopt flock for up to about 2.5 minutes** (120 s window plus 10 s stop and cleanup). - Adopt passes, stage relays, purge and freeze wait for it. `instanceDemoPurgeGuard` takes the flock without honouring its context (`claimstop_run.go:279`, `adoptlock.go:47`). - So freeze's 30 s budget and the close door's 12 s wait can expire while a request sits on the flock. The handler then gives up cleanly once it gets the lock (`claimstop_run.go:284`). - This is what the chosen outer-guard design costs, not a deadlock. It is worth a comment or a bounded wait. **P3-b: recovery can run past its timeout.** `p.cleanup` creates its own `context.Background()` timeout of `stopWindow` (`demo_snapshot.go:407-409`), so the timeout `ensureReady` sets does not bound a cleanup already in progress. - One recovery can take about 2× `stopWindow` (roughly 20 s). That holds up `Serve` startup and a `/demo-build/ready` request, while the agent's readiness probe gives up at 10 s (`demo_jobs.go:474`). - Effect: one lost readiness tick during recovery. ## Other checks - Root never reads from a path the agent or tenant can write: `checkWALBounds` and its truncation run in the unprivileged helper, and `initialize` reads only the root-owned 0700 snapshot root. - Lock ordering of the new `ensureReady` and `RecoverSnapshots` path against purge, adopt, build and freeze is covered under P1-1 above. ## Out of scope - Because unknown close IDs now get 409, a close that arrives before its POST registers no longer cancels that POST. The agent must cancel its own request context too. That was the requested change; I did not check the client side. - The real-systemd and cgroup witnesses are still gated and were not run. ## Verdict **READY AFTER FIXES** - P2-A: restart recovery failure must keep builds closed. Same family as round-1 P3-1. Files: `internal/demobuild/snapshot_slot.go`, `internal/demobuild/worker.go`, `internal/instancectl/demo_snapshot.go`, `internal/instancectl/demo_build.go`, `internal/instancectl/server.go`, all under `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/`.</result> <usage><subagent_tokens>104275</subagent_tokens><tool_uses>16</tool_uses><duration_ms>219212</duration_ms></usage> </task-notification>
<task-notification> <task-id>bvsqz7z4o</task-id> <tool-use-id>toolu_01SoNuLpzB1E21WCNcELxob8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bvsqz7z4o.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3fix2.done ]; do sleep 30; done; tail -1 $S/t3fix2.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bkvv53jg3</task-id> <tool-use-id>toolu_01TuN7Qw5wpTRDWJaSYAeKbL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bkvv53jg3.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3fix3.done ]; do sleep 30; done; tail -1 $S/t3fix3.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b8q5sajtf</task-id> <tool-use-id>toolu_01KcyrASCNPJZfYqawfSNyji</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b8q5sajtf.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t4.done ]; do sleep 30; done; tail -1 $S/t4.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a5391946210ed7e06</task-id> <tool-use-id>toolu_017U7ZLWvgnYNaPybgBcCUJL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a5391946210ed7e06.output</output-file> <status>completed</status> <summary>Agent "Review Task 4 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**1) Spec compliance: ✅**, with three items I could not verify from the diff: - ⚠️ Rollback binaries are excluded only if the deployment's seeds floor publication actually carries `min: 2`. Root boxes verify a signed publication (`internal/host/rootseedsfloor_publication.go:19`), and nothing in the tree writes one. The console door now writes `Min: seeds.ProtocolVersion` (`internal/console/seedfloor.go:192`), but only unsigned. `demoClaimSeedReady` and `seedRegionReady` both read the same key, so they agree. Task 8's activation run should confirm the signed floor is `{min:2}`. - ⚠️ `TestDemoClaimSeedCommit` has no explicit `ordinaryReplicaAndImport => unchanged` subcase. The report relies on the existing Seed/Import suites for this. - ⚠️ The coordinator side belongs to Task 5. Commit and abort must both run under the app lock, the phase must be set to aborting before finish, and a rotated key must lead to abort, not a new hash. The helpers enforce what they can; the rest is in the report's contracts. **2) Findings** No P1. No P2. **P3-1. Leftover claim data when a box misses the abort.** Fault family: abort cleanup completeness. - `internal/provision/demo_claim_seed.go:1678-1750`: on a box with no row, the abort still fences, finds no matching marker, and moves the record to rolled-back. - Scenario: box A held the row and ran the claim. Box B has no row and rolls back first. A's lease is free (idled out, or A's agent is restarting). The console finishes, deleting the replica and the record (`seedfinish.go:271`). A's next pass then sees no record and removes the row through the ordinary orphan path (`reconcile.go:~2436`), which purges no local data. The claim's database stays at `NestedDBPath(host)`. - Impact: a later instance at the same host (same account, same app name) could open that file as a warm cache, the problem `purgeAbortedFromLocal` guards against for `--from` seeds. Existing `--from` seeds have the same race, so this matches current behaviour. The new rolled-back-with-row case (`seedreconcile.go:2454`) narrows the window. - Fix: before the orphan path deletes a row whose `seed_source` is an uncommitted demo-claim, fence it, check the marker against the row's seed ID and run `RemoveLocal`. The row carries the seed ID, so no record is needed. **P3-2. No byte-level test for unchanged wire format.** Fault family: wire compatibility. - The risk list asked for a fingerprint test. Only the CLI `apiSeed` is checked (`instances_demo_claim_test.go:63`). - It is correct by construction: `omitempty` on `ClaimID` in `provision.SeedSource` (`seed.go:279`) and `seeds.RowSeed` (`row.go:608`). - Fix: add golden tests that `SeedColumn` and `json.Marshal(SeedSource)` produce the old bytes for replica and import seeds without a claim ID. **P3-3. The floor door can no longer publish a protocol-1 floor.** Fault family: ordinary seed compatibility (judgment call 2). - After this change (`seedfloor.go:192`), any republish, even one made only for ordinary seeds, raises the floor to protocol 2. `seedRegionReady` uses `max(RequiredProtocol, floor.Min)`, so ordinary seeds then need every box and every rollback binary at protocol 2. - This only refuses more, so it is safe. It should go in the runbook. **P3-4. Committed claim records keep shape limits forever.** Fault family: "ordinary after commit." - `validateDemoClaimSeed` (`demo_claim_seed.go:1598-1600`) still refuses HA, a runtime, addrs and a non-instance kind once committed. - None of these can change after create today. If a later feature lets them change, a claimed app would be the odd one out. **P3-5. Census false positives.** - `validateDemoClaimSeed`'s "+file:Open" is `RunState.Open()`, a method that touches no file. - `CompareSeedGate`/`DeleteSeedRoute`'s "+file:Exec" is a SQL `Exec`. **Root review (ahead of the census)** - Every new read runs in the agent (user `carlos`) or the console: - the `claimSeedWakeHook` record read - `abortDemoClaimSeed`'s registry and record reads, and its marker read through instancefs - the edge's `SeedSource` parse - the console's edges, status and floor reads - The removal path comes from `NestedDBPath(cfg.DataDir, rec.Host)` and runs only after a fence, proven stop and a marker match. No tenant-named path reaches root. - The only root-side change is indirect. `rootgeneration_requirements.go:59` and `wakeidentity.go:252` call `ValidateShape`, which now refuses more and never less. - Nothing weakens a check root relies on. **3) Strengths** - The route and its gate are created in one insert (`CreateSeedRoute`, guard `AND 0`). `upsertRoute` never updates `import_gate`, so ordinary convergence cannot open the gate. Gate changes are compare-and-swap writes bound to seed, owner and lifetime. - The claim kind never reaches swap or journal code, and it is explicitly kept out of `journalPass`. - The durable record is re-read after the lease and before any restore or exec. Together with the console refusing to finish while the lease is held, this stops a stale wake from restarting an aborted destination. - A missing or unready snapshot always fails the wake instead of booting empty. - The verify token is HMAC-SHA256 of `"carlos demo claim verify v1\n"` plus the operation ID under `cfg.Key.Seed()`. Only its hash is stored, and it is re-derived after transfer, so a rotated key is refused. - Uploads are create-only and the stored bytes are re-verified. No lock is held during transfer. - Edge: exact host and GET only, header stripped, cache bypassed, and alias and path routes are tested. - No new reads on unchanged watch ticks (tested). **4) Verdict: READY** The P3s can go on the follow-up list. P3-1 is worth carrying into Task 5 or Task 8.</result> <usage><subagent_tokens>210339</subagent_tokens><tool_uses>45</tool_uses><duration_ms>527534</duration_ms></usage> </task-notification>
<task-notification> <task-id>bi7470bu0</task-id> <tool-use-id>toolu_01Dv8ihjaZJaMni8QwS3guvb</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bi7470bu0.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t5.done ]; do sleep 30; done; tail -1 $S/t5.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a60ecd904ffa8316f</task-id> <tool-use-id>toolu_01TxAQsVEHzXxeBbUBNBCEMj</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a60ecd904ffa8316f.output</output-file> <status>completed</status> <summary>Agent "Review Task 5 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>1) **Spec compliance: ❌** Most of the brief is in place. The phase table, ordered-lock commit and abort ordering match it. So do the claimed-retirement extension and the operation guard. The guard sits on enqueue (`demo_jobs.go` `insertDemoJob`), update spending (`demo_store.go` `SpendDemoUpdate`) and every `withDemoLocked` publication and result boundary. Leaving `demo_publish.go` and `cmd/console/main.go` unmodified is justified: they reach the guard through `withDemoLocked` and the existing `ReconcileDemoJobs`. Two items fail the new ruling R5a: the box handlers and the status read are gated, and freeze dispatch is not (findings 1 and 2). The idle and waiting request-cost requirement is only partly met (finding 3). ⚠️ Not verifiable from this diff: - Whether the box accepts an early `claimed` receipt only while it holds the claim (that is Task 3 host code). - Whether the box dedupes `export` work, which the console resends on every wake while copying (`apidemobox.go` `pendingDemoClaims`; every ready message calls `wakeDemoBox`). - Real systemd/cgroup stop behaviour. 2) **Findings** **P1:** none. I found no path that leaves two writable apps or strands a committed claim: - Abort is refused once committed (`beginDemoClaimAbort`). - Commit requires `phase='verifying'`, so an aborting operation can never commit. - Abort pickup requires `cleanup=1`. - The hold is cleared only while aborting with cleanup proven. - The post-commit steps (open, moved, retire) do not depend on the gated box handlers. **P2-1. All box claim handlers refuse while the switch is off. This violates R5a.** - Evidence: `internal/console/apidemobox.go:404`. `authenticatedDemoClaim` returns 503 unless `demoClaimEnabled()`, and pickup, snapshot and ack all go through it. `TestDemoClaimTransferBoxGate` (`demo_claim_transfer_test.go:260`) asserts this behaviour. - Failure: the switch goes off while an operation is freezing, copying or aborting. The console still advances it to `aborting`, clears the record hold and signs abort work, and `pendingDemoClaims` still streams that work. The box's abort pickup gets 503, so `abort_ack` never arrives. The anonymous source stays frozen until its original expiry, up to 24 h, and is then retired as expired. That is a user-visible outage of every in-flight demo, though never two writers. - Fix: drop the `demoClaimEnabled` check from `authenticatedDemoClaim`. Keep `HostClaim`/`claimGated` and the existing auth, box, phase, generation and lifetime binding. If you want snapshot and export refused when switched off, gate only those actions for operations not yet frozen. Invert the box-gate test. - Family: termination/liveness (admission switch vs recovery). **P2-2. Freeze dispatch is not gated, and the status read is gated. Both are the wrong way round under R5a.** - Evidence (freeze): `demo_claim_transfer.go:67` checks only `HostClaim`/`claimGated`. The `case "reserved"` branch at `:100` pins the source, writes the hold and dispatches freeze. `demoClaimSeedReady` also lost its `demoClaimEnabled` check (`demo_claim_seed.go`). - Failure (freeze): a reserved operation is still frozen while the switch is off, after a restart or after a flip just past reservation. Combined with P2-1, that freeze can never be acknowledged or undone until expiry. - Evidence (status): `handleDemoClaimStatus` (`demo_claim_auth.go:365`, Task 2 code) starts with `demoClaimGate`. - Failure (status): when the switch is off, a committed or aborting claim cannot report its result through the flow token. - Fix: in `advanceDemoClaim`'s `reserved` branch, if `!s.demoClaimEnabled()` then `beginDemoClaimAbort(ctx, op, "disabled")`. The source is never frozen, because `Action==""` releases without needing a box ack. For status, skip the enabled check but keep the origin, `claimGated` and token checks. - Family: admission switch scope (R5a). **P2-3. An abort waiting for the box's acknowledgement polls the object store and forces a full box reconcile about every 2 s.** - Evidence: `ReconcileDemoClaims` selects `aborting` rows whenever `retry_at<=now` and resets `retry_at` to now+2 s after every pass (`demo_claim_transfer.go:887`). `RunDemoJobs` wakes on that clock: its `claimNext` query uses the ELSE branch for aborting rows (`demo_jobs.go`). Each pass, `continueDemoClaimAbort` calls `ensureDemoClaimHold(ctx, op, true)` (`:811`). That runs `SetDemoClaimHold` → `GetRecordRaw`, one store GET even when the hold is already cleared, and then `NotifyDemoBox` (`:303`). On the box, `NotifyDemoBox` sets `p.reconcile` → `msg.Reconcile` → `notify()` → `backstopFullDue.Store(true)` (`internal/host/demo_jobs.go:551`, `:108`). That is a full backstop pass. - Failure: a slow or offline box, or P2-1 with the switch off, means a store GET plus a full box reconcile every ~2 s for up to 24 h per operation. The same unbounded 2 s loop exists after commit when the `open` step's verify keeps failing (`:693`): a record GET plus an HTTPS GET with no backoff. This breaks the "unchanged tick → zero additional store requests" invariant. `TestDemoClaimRequestCost` covers only the freezing wait. - Fix: - Persist "hold cleared" (e.g. a `hold_cleared` column) so the clear runs once. - Exclude `aborting` rows waiting on `abort_ack` (`cleanup=1`, work present, `phase_until` in the future) from the select, as freezing already is. Wake them by ack or `phase_until`. - Notify the box only when the record actually changes. - Give `committed` retries exponential backoff. - Extend the request-cost test to aborting and committed waits. - Family: request cost (S3 polling). **P3 (follow-ups)** - `acceptDemoClaimSnapshot` holds the per-operation lock for the whole upload, up to `SnapshotWindow`. A due retry or expiry abort on that operation blocks the serial `RunDemoJobs`/`expireDemos` pass meanwhile. Either use a try-lock in the reconcile pass, or skip operations with an upload in flight. - `beginDemoClaimAbort` overwrites a stored reason (`deadline`/`capability`) with `expired` when the expiry pass re-enters. That is diagnostic loss only. - `demo_moved_notices` rows are never pruned. Task 6 should own this; note it in Task 6's brief. - Provision orphan path (risk 9): `removeDemoClaimOrphan` passes `row.DBPath` from the agent-written registry row to `LocalSeedID`/`RemoveLocal`. It is confined by `NestedPaths(cfg.DataDir, row)`, and `seedrollback.go:162` already passes a registry row the same way. It runs on the agent's reconcile path. I found no new path a tenant or agent could name, but the census overlay under R9 should still classify it. 3) **Strengths** - The commit is a single SQL transaction that rechecks identity, membership, the target reservation (`a.expires_at=0`), the hold acknowledgement, source lifetime, generation, deadline and `phase_until` under the account → apps → hostname lock order. It records the decision, nulls the token hash, deletes flows, stores the moved notice and enqueues the outbox together. `checkRunningThings(acct, 0)` is used correctly. - Status keeps working after flows are deleted because it is keyed off `demo_claim_ops.flow_hash`. - The snapshot path is careful: - It reserves scratch before reading any bytes. - It hashes while streaming, then runs an integrity check. - It pins the digest before the PUT and reads before any retry PUT. - It refuses changed bytes. - Verify uses the exact apex host, refuses redirects, requires 2xx plus a matching `X-Carlos-Version`, and checks `placed` after the wake. - On expiry, `retireDemoLocked` refuses while an uncommitted operation has cleanup pending, and the expiry pass aborts the destination first. Operator intent survives retries. - `SetDemoClaimHold` uses a permit that is exact on the decoded record and keeps `WriteRecord`'s sequencing and CAS. - Recovery coverage is broad: SQL and object boundaries, lost replies, and a trigger-forced commit rollback. 4) **Verdict: READY AFTER FIXES.** No P1; fix P2-1, P2-2 and P2-3.</result> <usage><subagent_tokens>172868</subagent_tokens><tool_uses>35</tool_uses><duration_ms>402535</duration_ms></usage> </task-notification>
<task-notification> <task-id>brx7o8irs</task-id> <tool-use-id>toolu_01NxQdkiLaPNacDzVaearvDu</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/brx7o8irs.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t5fix.done ]; do sleep 30; done; tail -1 $S/t5fix.log" completed (exit code 0)</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="b0d6031b-7f12-405e-8af5-0928fe479324" source-agent-title="agent /start demo program controller"> From program controller 39e7acfa (Paul 17:45Z on #527: "keep going until it's done"). Keep going as briefed. Two additions: (1) when Plan 3 merges, send me the merge sha (paseo send 39e7acfa ...); Plan 4's controller 9bc26afc binds its claim contract to it. (2) For the dev witness: dev runs v0.34.7 on canary (sophie, demo box-1) and the dev console; if claiming needs a newer release, tell me rather than asking Paul; I arrange dev-only releases with the agent manager 8a3d302. Questions for Paul still go on #527. </paseo-system>
<task-notification> <task-id>byt6k52uq</task-id> <tool-use-id>toolu_01CFH2QT3zeXRsAVdmQch6qM</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/byt6k52uq.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t6.done ]; do sleep 30; done; tail -1 $S/t6.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a85016b7f9dc86db4</task-id> <tool-use-id>toolu_01NVk48FUnUPNzLLfkuFxgXU</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a85016b7f9dc86db4.output</output-file> <status>completed</status> <summary>Agent "Review Task 6 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>1) **Spec compliance: ✅**, with two delivery-robustness gaps (P2s below). - **Risk 1, ordering (✅).** `ServeHTTP` calls `handleDemoRequest` first (internal/edge/edge.go:1903). The moved check is the first statement there (internal/edge/demo.go:104-107), ahead of route lookup, refusal, cache (edge.go:2623), caps, upgrade and activation. The merged `demoMovedPage` hook now calls `serveDemoMoved` instead of a second hook. Plain HTTP also checks it before redirecting. The old-cache, no-route and pending-route tests drive the real `ServeHTTP`. - **Risk 2, target and response (✅).** - The source must be exactly one label under `Demo.Domain` (`demoHost` plus `MovedDomains`). The target must be exactly app.account under `AppsDomain`. - The console rechecks `TargetHost == apexHost(target_sqid, app)` at commit and again when signing. The edge rechecks the domains on load. - The link is `https://` plus the host, through `html/template`. - GET returns 200 with HTML, HEAD returns headers only, and every other method gets 410 with no forwarding. Headers are no-store, no-referrer, nosniff, and a CSP of `default-src 'none'` with `form-action 'none'` and sandbox. - The page sets no redirect, cookie or token and wakes nothing. - **Risk 3, expiry (✅).** Each request checks `now >= ExpiresAt`. Pruning deletes only `demo_moved_notices` rows past expiry, and the host tombstone is untouched. The snapshot query reads notices, ops and commits but never `apps` or the source's serving state. - **Risk 4, delivery (✅ on the happy path).** - The notice key has one change scope (internal/release/changeindex.go:56). It is read at startup and when its generation changes, inside the existing `fastTick`, with no new ticker. - The registry stores the snapshot as a separate CAS row, and the edge re-verifies those bytes on every Reload. - Demo-fleet boxes get the snapshot over the existing stream. - **Risk 5, capacity (✅).** Capacity is reserved in the reservation writer transaction and rechecked inside the commit transaction, counting envelope and base64 size. A live notice may not change or disappear (`MovedMonotonic`). The signing separator is exactly `carlos demo moved v1\n`. - **Risk 6, Task 5 follow-ups (✅).** `hold_ready` is now written before `NotifyDemoBox` (demo_claim_transfer.go:313-320). The retry backoff resets when a pass shrinks the outbox, and a retirement ack sets `retry_at=0` and signals the job loop. Lock order stays op lock then app lock, matching every other acquisition I found. Nothing new polls. - **Root census (no findings).** I found no new root reads. Root opens the registry through the remote child, which only gains an additive `CREATE TABLE` and a fingerprint term. The registry's `DemoMoved` and `CompareDemoMoved` refuse remote use. The new `release.BumpChangeIndex` writes only `control/changes.json`. - **⚠️ Not verified from the diff.** - That every production edge sets `staticPub` (it comes from `CARLOS_RELEASE_PUBKEY` plus the bucket, edge.go:4815-4836) in the same configurations where the agent advertises `demo-moved-v1`. - The full body of internal/host/demo_moved_test.go. - I ran no tests. 2) **Findings** **P2-1. A moved-snapshot fault tears down the whole demo stream.** Fault family: failure isolation. An advisory notice is gating the serving, retirement and claim channel. - **Box side.** internal/host/demo_jobs.go (diff ~1793-1797): `if err := installDemoMoved(...); err != nil { return err }` ends `Connect`. - **Console side.** internal/console/apidemobox.go:218-226: `sendDemoPending` returns the `demoMovedSnapshot` error before `sendDemoServing` and the retirement replay. Any snapshot error therefore closes every capable peer's stream. - **Triggers:** - The console DB is restored to an earlier point, losing a committed live notice. Every box's `MovedMonotonic` check then fails until that notice's original expiry, up to 24 h. - The console clock runs ahead of a box at a notice's expiry boundary. - The persisted snapshot was signed by a previous key. - A CAS race with the same box's fast-tick reader. - An `AppsDomain` or `Demo.Domain` config change makes one row fail `apexHost`/`MovedDomains`, which fails the whole snapshot. - **Failure scenario.** The console replays the snapshot first on every connect and on every 10 s heartbeat wake, so the stream reconnects in a loop. Serving control lapses and demo traffic on that box fails closed. Retirement receipts and claim work stop for up to 24 h, or indefinitely after a key rotation. - **Fix:** - On the box, log the install error, keep the prior verified mapping and continue reading the stream. - On the console, log and skip the moved frame when building the snapshot fails, and let the outbox `moved` step carry the retry. **P2-2. A permanent install failure turns the normal-edge reader into a 2-second bucket poll.** Fault family: request cost ("no new per-box polling"). - **Evidence.** In `demoMovedReader.pass` (internal/host/demo_moved.go), the generation is consumed only on success. Any install error leaves it pending, so every `fastTick` (`fastTickEvery = 2s`, agent.go:2579) issues another `Get` of control/demo-moved.json. - **Failure scenario.** Use the P2-1 triggers. A console restore makes every box GET every 2 s, about 43k GETs per box per day, until the lost notice expires. A key rotation or corrupt persisted bytes make it last forever. - **Fix.** Consume the generation on a verify, monotonic or CAS failure, keeping the prior mapping and logging once. Retry only transport errors, with backoff or at the existing backstop. **P3s** - **P3-1. The full snapshot is re-signed and re-sent on every heartbeat.** apidemobox.go:181 wakes the peer on each 10 s heartbeat, and :196 then sets `replayRetirements=true`. Each wake re-queries up to 10,000 rows, signs up to 1 MiB with Ed25519, sends about 1.4 MiB per peer, and the 2 GB box re-verifies it. Fix: cache the signed bytes until notices change, and send on connect or change only. Family: CPU and bandwidth cost, not object-store cost. - **P3-2. The target-domain check happens only at commit, after the copy.** The `apexHost`/`MovedDomains` check sits at demo_claim_transfer.go:~656. `reserveDemoClaimRows` only runs `MovedFits` (DNS shape), so a mismatched target freezes and copies the source, then aborts. Fix: also check at reservation, before freeze. - **P3-3. The box-status half of the capability gate checks only freshness.** status/snapshot.go:1177 always advertises `demo-moved-v1`, so that half of `demoClaimMovedReady` only proves the status is fresh; the edges-file capability is the real gate. That capability also ignores the edge's own `staticPub`, `Demo.Domain` and `AppsDomain`. An edge missing these advertises the capability and then drops every snapshot. Fix: also require them when advertising. - **P3-4. The registry fingerprint hashes the whole snapshot.** It hex-hashes up to 1 MiB of snapshot bytes on every fingerprint pass (registry.go:~4233, ~4526). Fix: hash a stored digest instead. 3) **Strengths** - The notice table is independent of `apps` and source purge, and only open destinations are published. - Capacity reservation sits inside the same writer transaction as the app reservation, with a recheck at commit. - `MovedMonotonic` is enforced in both host and edge, and the edge re-verifies on restart. - The tests are strong: a real primed cache, activator-silence checks, escaping, a wrong signing context, and a stream frame larger than the old limit. - The Task 5 follow-ups are minimal and keep the lock order. 4) **Verdict: READY AFTER FIXES** (P2-1, P2-2). Inputs read: - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/.superpowers/sdd/2026-11-04-agent-start-demo-3-claim/task-6-brief.md - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/.superpowers/sdd/2026-11-04-agent-start-demo-3-claim/task-6-report.md - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/.superpowers/sdd/2026-11-04-agent-start-demo-3-claim/review-8f2b67d5..3f29819e.diff</result> <usage><subagent_tokens>136554</subagent_tokens><tool_uses>29</tool_uses><duration_ms>334730</duration_ms></usage> </task-notification>
<task-notification> <task-id>brtwgzgca</task-id> <tool-use-id>toolu_01GMQfYNARD3HiZaxcaYFzUS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/brtwgzgca.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t6fix.done ]; do sleep 30; done; tail -1 $S/t6fix.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a46fea76c2c0d19a5</task-id> <tool-use-id>toolu_01C1DeR1Up7jGpDzM8HjneoE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a46fea76c2c0d19a5.output</output-file> <status>completed</status> <summary>Agent "Re-review Task 6 fix round 1" 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>I'd call this **READY**. All five round-1 findings are fixed, and the fix diff adds no P1 or P2. It does add three P3 edge cases, listed below. I checked the code against the full diff (3f29819e..ee418de0). The targeted `TestDemoMoved|TestDemoOfflineRetirementHTTP` run passed for `internal/edge` and `internal/status`. It did not run for `internal/host` and `internal/console`: setup failed because the sandbox has a read-only entry in `~/.cache/go-build`, and I left `GOCACHE` alone as the house rules require. For those two packages I relied on the GREEN evidence in the report. All paths below are under `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/`. ## Round-1 findings - **P2-1, failure isolation: ADDRESSED.** - Box: `internal/host/demo_jobs.go:535-543` logs the error once (repeats are suppressed until a success) and keeps reading. `installDemoMoved` only writes after it has verified the snapshot and checked it is monotonic, so the prior mapping is untouched. - Console: `internal/console/apidemobox.go:223-245` logs and skips the moved frame. Serving, retirement and claim replay carry on. - Outbox retry is kept: `publishDemoMoved` still returns snapshot-build errors (`internal/console/demo_claim_moved.go:144-147`). - A bad row is skipped instead of failing the whole build (`demo_claim_moved.go:111-117`). - **P2-2, request cost: ADDRESSED.** `internal/host/demo_moved.go:42-58`. After any completed GET the generation is consumed before verify and install. Only a failed GET sets `retryAt = now + ChangeIndexBackstop` (30 min). A later, new generation is still picked up because `d.generation != gen` and a successful GET clears `retryAt`. A new generation that arrives during the 30-minute window waits for it, but the stream push still delivers it. - **P3-1, heartbeat re-sign: ADDRESSED.** - The console caches the signed bytes keyed on the eligible notices plus a SHA-256 of the signing key (`demo_claim_moved.go:126-135`). - Each connection records the last bytes it sent (`p.movedWire`) and sends only on connect or change (`apidemobox.go:236-244`). - **P3-2, domain check at reservation: ADDRESSED.** `internal/console/demo_claim_target.go:185-187` checks before the op is created. The commit-time check is still there. - **P3-3, honest capability: ADDRESSED.** - The edge reports ready only with a correctly sized static public key and valid `Demo.Domain` and `AppsDomain`, and it handles a nil receiver (`internal/edge/demo_moved.go:16-18`). - The host passes that through the status loop (`internal/host/agent.go:1033`, `:4718`), and `demo-moved-v1` is advertised only when the probe is true (`internal/status/snapshot.go:1177-1180`). - No startup race: `ready(e)` (`internal/edge/edge.go:4566`) runs after `enableStaticFromEnv` (`:4510`). ## Your specific questions - **Can a stale snapshot be sent from the cache?** No. ed25519 signing is deterministic, and the cache key covers the full notice list (which drops expired rows, since the query filters on `expires_at > now`) and the key hash. A notice change, an expiry or a key change always forces a fresh signature. The per-connection record is compared byte for byte, so any change is re-sent. - **Is a new generation picked up after a failed one is consumed?** Yes, as above. - **Any new root read?** No. The diff touches no root-binary code and adds no bucket reads. The new readiness probe is in-memory and the console cache is SQL only. ## New issues from the fix (all P3) 1. **P3: skipping a row can publish a snapshot that breaks monotonicity.** Family: failure isolation versus monotonicity, a new family the P2-1 fix opened (related to round-1 P2-1). - Reservation and commit now gate the domain, so a row only fails the check at publish time after it was valid when committed. That happens only after an operator changes the configured domains (`Demo.Domain` or `AppsDomain`). - When it does, `publishDemoMoved` puts a snapshot without that row. It is not a dead end, but it degrades in two ways: - Boxes holding the old snapshot reject every later one on the monotonic check (`internal/democlaim/moved.go:88`). They log once and keep the old mapping, so the dropped host's notice still serves there. But no newly claimed host's notice installs on those boxes until the dropped row expires. - New boxes never show a notice for the dropped host. Nothing ever re-adds it, because the outbox step succeeds. - Before the fix the build failed for everyone instead, so this is no worse in blocking terms. Two possible fixes: keep a skipped row if it is in the currently published snapshot, or refuse the Put when the new snapshot is not monotonic against `old` (`demo_claim_moved.go:148`) and let the outbox retry. 2. **P3: a transient local error can be treated as permanent.** Family: retry classification, the same family as round-1 P2-2. - In the box's `pass`, a SQLite busy or I/O error from `reg.DemoMoved` or `CompareDemoMoved` consumes the generation (`internal/host/demo_moved.go:56-58`). The console also marks those bytes as sent (`apidemobox.go:241-243`). - A valid snapshot is then ignored until the next change or stream reconnect. - A CAS conflict between the reader and the stream is harmless, because both get their bytes from the same console. Only real local I/O errors hit this. 3. **P3: one combination can still fail the whole build.** Each row passes its own check, but duplicate live hosts or a combined size over the limit make `SignMoved` fail for the whole set (`demo_claim_moved.go:119-121`, `:130`). In practice `reserveDemoMovedCapacity` (`demo_claim_moved.go:58-86`), which checks every live notice plus the candidate, guards against both at reservation and again at commit. Noted only. Minor: on an early error return, the `rejected` map is reset to a partial set (`demo_claim_moved.go:95`). The only effect is an extra log line. **Verdict: READY**</result> <usage><subagent_tokens>71873</subagent_tokens><tool_uses>18</tool_uses><duration_ms>166216</duration_ms></usage> </task-notification>
<task-notification> <task-id>bd3u038ij</task-id> <tool-use-id>toolu_01LSmXwwpzzeyAKpKWME72CS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bd3u038ij.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t7.done ]; do sleep 30; done; tail -1 $S/t7.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a3d41ca7c0c4e0bf7</task-id> <tool-use-id>toolu_01NwjddpmqCTVXo2GSppSWbz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a3d41ca7c0c4e0bf7.output</output-file> <status>completed</status> <summary>Agent "Review Task 7 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**1) Spec compliance: ✅ with one ⚠️** Every item in the Task 7 brief has a matching mechanism in the diff: - **Routes and handlers.** `handleDemoClaimPage` and `handleDemoClaimBrowserProof` exist. The intent, prove and select POSTs are registered at `apidemo.go:278-281`. - **Fragment handling.** The page's only script clears the fragment with `history.replaceState` before its POST. The token goes only in the same-origin POST body. A GET only sets a random cookie that is not stored, and writes no flow, proof or operation (the `TestDemoClaimFragment` scanner GET). - **Page headers.** The page sends `Referrer-Policy: origin`, `no-store` and a CSP of `script-src 'self'`. It loads no third-party assets and uses no browser storage. - **Cookie.** `carlos_demo_claim_flow` is HttpOnly, Secure, SameSite=Lax, Path `/demo/claim`, at most 900 s (`demo_claim_page.go:19-28`). Only its hash, purpose, flow hash and expiry are stored (`demo_claim_browser_store.go:21`). The raw flow token is generated and thrown away, so a browser cookie cannot reach the agent doors (tested). - **Request checks.** Every browser POST checks the switch, the origin, a nonce tied to both the cookie and the session, and the session CSRF token. - **Select ordering.** The order is: switch, session, CSRF/nonce, flow owner, membership (an identical `http.NotFound`), then `requireFreshAuth`, then proof from the session's own sign-in method subject (`demo_claim_page.go:297-343`, `:372-398`). - **No automatic claim.** Neither the OAuth return nor an existing session claims anything. The page shows the signed-in person, and claiming needs an explicit POST. Several accounts force a picker with an empty disabled default and an exact sqid. A zero-account claim mints through Task 2's person lock and `checkNewFreeAccount`, and `createOnly` stops a membership that appears in between from being picked silently. - **Keymail.** It uses the ordinary `/auth/signin?next=/demo/claim` state/PKCE path. `safeNext` drops external values. The Keymail fresh-auth test confirms no fallback to email. - **Landing.** `completeSigninSession` was extracted, and only the exact `/demo/claim` return skips MRU landing. - **R5a.** Status still renders with the switch off. The emailed-link GET does not consume the link. A committed token fails at lookup. - **Result page.** It lists account, app, URL and `carlos login`. No deploy credential is issued. ⚠️ I could only verify the fragment exchange in Chromium. See P2-1. **2) Findings** **P2-1: The script's fetch forces `referrerPolicy: "no-referrer"`, so spec-following browsers send `Origin: null` and the token exchange is refused.** - Fault family: same-origin gate vs referrer policy (browser transport compatibility). - Evidence: `internal/console/static/demo_claim.js:17`. The Fetch standard's rule for adding the `Origin` header sets it to `null` for a non-CORS POST whose referrer policy is `no-referrer`. Firefox does this (`ReferrerInfo::ShouldSetNullOriginHeader`). `sameOrigin` then refuses it because the parsed host is empty (`internal/console/emailsignin.go:71-75`, reached through `demoClaimOrigin`). - The implementer hit this exact failure with native forms under a `no-referrer` page policy and fixed the page to `origin`. The fetch kept its own override. The headless test passed only because this Chromium sent a real origin for fetch. - Failure scenario: a Firefox user (possibly Safari too) opens the claim link. The fragment is cleared, then the intent POST gets 403 and "could not be opened" is shown. The token is gone from the URL, so the Keymail browser fallback cannot be used at all in that browser. - Fix: remove the `referrerPolicy` option, or set it to `"same-origin"`. The page policy is already `origin`, and the URL is `/demo/claim` by then, so nothing token-bearing can leak. **P3 (follow-up list)** 1. **Status lifetime vs operation lifetime** (recovery). - The browser row and cookie expire with the flow, at most 15 minutes after intent (`demo_claim_page.go:49`, `demo_claim_browser_store.go:21`). The operation may run up to 5 minutes after reservation. - If someone reserves at minute 14, the page drops to "Open the claim link…" before `done`. Reopening the link after commit fails token lookup, so the browser user never sees the result. - Possible fix: render the result or status directly on the select redirect, or let the status-only row outlive the proof cookie without widening its authority. 2. **Raw JSON shown to people** (browser UX). Form POST failures (wrong code, rate limit, 403) return `jsonError` bodies to a human (`demo_claim_page.go:203-222`, `:282`). There is no return link. 3. **Typed email is locked to the flow on first send** (`demo_claim_page.go:258`). A typo gets 401 until the intent expires, and the fragment is already gone. 4. **Picker lists accounts that would be refused** (`demo_claim_page.go:111` vs `:319`). The picker shows every membership, including roles that are not owner or member. A person whose only memberships are such roles can neither pick nor create, and gets 404 either way. 5. **Claim wording in ordinary sign-in.** `continueKeymailSignin` (`server.go:3847`) answers an empty flow with the claim-specific `demoClaimUnavailable` JSON, even though the helper is shared with ordinary sign-in. It is unreachable from `handleContinue` today, but the shared helper should not carry claim wording. **3) Strengths** - The browser credential is separate from the agent flow token. The flow's raw token is discarded, so the two kinds of authority cannot mix. - Membership is checked before fresh auth, and proof comes from the session's own method subject rather than the typed address. Linked identities are tested. - Step-up resumes to the page instead of replaying the select POST, so confirmation needs a new nonce. - The `createOnly` race guard and identical 404s. - The real Keymail state/PKCE callback test, and a loopback headless check of keyboard use and fragment removal. **4) Verdict: READY AFTER FIXES** (P2-1)</result> <usage><subagent_tokens>127216</subagent_tokens><tool_uses>18</tool_uses><duration_ms>312299</duration_ms></usage> </task-notification>
<task-notification> <task-id>bp4tbmdd1</task-id> <tool-use-id>toolu_01AYDfmM3MSq1rDy3oorAmmg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bp4tbmdd1.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t7fix.done ]; do sleep 30; done; tail -1 $S/t7fix.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>btq1iewqs</task-id> <tool-use-id>toolu_01Hefy6ZGk6fgzK1AMYAxSRA</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/btq1iewqs.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/luna.done ]; do sleep 20; done; tail -1 $S/luna.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a64056782803ab85e</task-id> <tool-use-id>toolu_01U3bLQrE9K3je1YfuaLYmBm</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a64056782803ab85e.output</output-file> <status>completed</status> <summary>Agent "Re-review Task 7 fix round 1" 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>The fix round resolves all six findings, but it adds one functional regression of its own (a P2). I found no new security breakage. HEAD is now 77df0163; the only commit after bcec1b4d is a copy brief, so the line numbers below hold for both. ## Findings | # | Verdict | Where | |---|---|---| | P2-1 | ADDRESSED | `internal/console/static/demo_claim.js:12-17`: the `referrerPolicy` override is gone. The strict `demoClaimOrigin` check is unchanged, now called through `demoClaimBrowserAdmission` (`demo_claim_page.go` around line 184). The fragment is cleared by `replaceState` at js:4, before the request. | | P3-1 | ADDRESSED | `demo_claim_store.go:211-213` changes live browser rows to the `demo-claim-status` purpose when the reservation is made. `demo_claim_browser_store.go:42-50` only accepts a status row while that flow's operation exists and the demo's expiry plus 24 hours has not passed. The cookie is set at `demo_claim_page.go:432` and `:100`. | | P3-2 | ADDRESSED | `demo_claim_page.go:33` (`demoClaimBrowserError`) keeps the status codes; the template shows the message at `templates/demo_claim.html:12`. The membership 404 and the JSON `demoError` on the fetch-driven intent call are left as they were, as intended. | | P3-3 | ADDRESSED | `demo_claim_page.go:305-320` and `demo_claim_browser_store.go:65-105`. | | P3-4 | ADDRESSED | `demo_claim_page.go:134-142` (render filter, plus the `no_accounts` state, which shows no form), `:471` (`demoClaimCanCreate`), and the same predicate in select. The `len(accounts)==0` check still uses the unfiltered list, so a member with only non-creating roles who posts `create=1` gets a 404. | | P3-5 | ADDRESSED | `server.go:3845-3848` uses the neutral sign-in error at 500. The claim wrapper is `continueDemoClaimKeymail` at `demo_claim_page.go:498`, which keeps the claim error at 503. | ## New finding **P2: the long-lived status cookie blocks claiming any other demo in the same browser.** This is the same family as P3-1 (browser credential lifecycle), and it is new in this fix. - `demoClaimBrowserGate` (`demo_claim_page.go:172-181`) refuses every browser POST with 401 once the cookie's flow has an operation. That includes `/demo/claim/intent`. - Before this fix, intent ignored the old cookie and issued a fresh one ("Rotate instead of rebinding", around line 222). Now the refusal holds until demo A's expiry plus 24 hours. - What the user sees: they claim demo A, then open demo B's claim link. The page shows A's "now a permanent app" result, and the background exchange fails with the generic error. The only way out is clearing cookies or using a private window. - `TestDemoClaimBrowserResultLifetime` (`demo_claim_review_test.go:92-97`) asserts that intent returns 401, but only with the same demo's token. The case of a different demo is not tested. - There is no security reason for the intent refusal. Intent takes its authority from the posted claim token and swaps in a fresh cookie, so it never uses the old flow. Prove and select should keep the refusal. - Fix: exempt intent from the reserved-cookie refusal, or move that check into prove and select only. Add a test that claims demo A and then exchanges a token for demo B in the same browser. ## Security checks (no new breakage) **What the status row or cookie can do.** Only three call sites read the browser cookie (`demo_claim_page.go:97`, `:173`, `:198`). - Prove, select and intent are refused by the gate. - Prove would also fail on its own: after a reservation the flow already has a person, and `proveDemoClaim` checks for that (`demo_claim_auth.go:258`). - Page render takes the operation branch, which shows that operation's result and never lists accounts. - Agent endpoints never read `demo_claim_browsers`. The test confirms 401 at `/api/demo/claims/select`. - Counting status rows as "came from a browser" in `isDemoClaimBrowser` grants nothing new. Both of its callers run only after a proof that requires `person=''`. **Lifetime and erasure.** - Server side, a status row is bounded by the demo's expiry plus 24 hours and by the operation existing. - Every non-status cookie still gets at most 15 minutes, because flows are capped at 15 minutes (`demo_claim_store.go:126`) and render uses now + 15 minutes. That still holds even though the 900-second cookie cap was removed. - Expired rows are only deleted when the next browser attaches. They are inert in the meantime, and the implementer already listed this as a known limit. **Restarting email proof on the same intent.** - The new flow copies `demo_id`, lifetime, generation and `expires_at` from the old one, so the intent cannot move to another demo and its life cannot be extended. - The replacement is refused if the flow has a person or an operation, or if no live browser row points at it. A reserved operation therefore cannot be replaced. - The old challenge and the old flow are deleted in the same transaction, so old codes and links fail. - The send, submission and guess limits stay keyed by address and IP, so a correction does not reset them. - Locks are always taken flow first, then demo, which matches `proveDemoClaim`. A proof already running against the old flow fails when it re-reads the flow. **Removing `no-referrer`.** The token is cleared from the URL before the fetch, travels only in the POST body, and the page referrer policy is origin-only. Nothing leaks. **Error page escaping.** The page uses `html/template` (`demo_claim_page.go:8`), and messages are constants or `ref.Msg`, all escaped as text. The page shows no identity or account data. Verdict: READY AFTER FIXES</result> <usage><subagent_tokens>84363</subagent_tokens><tool_uses>13</tool_uses><duration_ms>150570</duration_ms></usage> </task-notification>
<task-notification> <task-id>bc56mm91k</task-id> <tool-use-id>toolu_01ABff85tUN3tZJoUhxQYaUU</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bc56mm91k.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t8.done ]; do sleep 30; done; tail -1 $S/t8.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b2005042h</task-id> <tool-use-id>toolu_01G21VBHSQhhgwaz983L1NXo</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b2005042h.output</output-file> <status>completed</status> <summary>Background command "until amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -qv 'running'; do sleep 60; done; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -5" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>afb2c3ded52d1583d</task-id> <tool-use-id>toolu_01Swt8Jrp3uHdW67VibdVs9b</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/afb2c3ded52d1583d.output</output-file> <status>completed</status> <summary>Agent "Census review agent-start-demo-3" 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>## Census verdict: agent-start-demo-3 at tip 1b764ad6 **Overall: APPROVED.** I found nothing to reject: no P1 and no P2. Four P3s go on the branch's follow-up list and do not start a round. The focused census test passes with the overlay: `nice go test ./internal/provision -run 'TestPlan14RootReadCensus|TestCensus' -count=1` gave `ok … 14.3s`. The first run inside the sandbox failed only because it could not write the default Go cache. I reran it outside the sandbox with the same cache. The worktree is still clean. **Who runs what.** Only `carlos-instance-control.service` (instancectl, and the demobuild worker inside it) runs as root. The agent, edge, activator, provision and registry code runs as user `carlos`. The one production `provision.Reconcile` call is `internal/host/agent.go:2087`. Registry reads by root go through the existing `HostDemo` wiring, which this branch does not change. ### Units with a recorded disposition (body / sites) | unit | verdict | evidence | |---|---|---| | activator/seedplace.go `ExecBackend.SeedPlaced` | APPROVE | Agent side. A demo-claim seed at `placed` re-runs the replica sync; this only tightens. | | demobuild/worker.go `NewWorker` | APPROVE | `snapshotPoisoned: true` at construction and `available()` now also requires `!snapshotPoisoned`. Fails closed. No new read. | | edge/demo.go `handleDemoRequest`, `redirectDemoRequest` | APPROVE | Edge (carlos). Serves a notice only from `VerifyMoved`-verified rows, checked against `MovedDomains`, before route lookup (`edge/demo_moved.go:20-46`). | | edge/edge.go `Edge.Reload` | APPROVE | Adds `loadDemoMoved()`: a signed, verified blob read from the edge's own registry. | | host/agent.go `fastConvergeLoop`, `fastTick`, `runAgent`, `statusLoop` | APPROVE | Agent only. Adds the moved reader on the existing watch, wires the claim client and a capability flag. `convergeAdopted` tightens: held rows are skipped. | | host/demo_serving.go `demoHeartbeat`, `demoServingAllowed` | APPROVE | Capability strings, and a `claimHeld` refusal added (tightening). | | host/seedwiring.go `wireSeedPlacement` | APPROVE | Adds `OnDemoClaimSeedWake`, a record recheck (`seedwiring.go:264-279`). | | units/carlos-instance-control.service `external` | APPROVE | Only adds `StateDirectory=carlos-demo-snapshots` with mode 0700, which is root-only. See P3-1. | | instancectl/server.go `runWithClaim`, `type Server` | APPROVE | Supervisor built only when `DemoBox`. Three POST routes added. No path field anywhere in the requests. | | provision/seed.go `SeedAbortBecause` | APPROVE | Applies the import's run and interactive refusals to demo-claim seeds (tightening). | | provision/seedreconcile.go `journalPass` | APPROVE | Skips any journal whose record is a demo claim (`seedreconcile.go:420-424`). | | status/snapshot.go `CollectBox` | APPROVE | Capability list only. | | activator/seedplace.go `seededRestore` (+Route) | APPROVE | A claim seed that is not ready fails, and an uncommitted one needs `OnDemoClaimSeedWake` (`seedplace.go:110-123`). | | host/demo_cleanup.go `retireDemo` (+HoldOp, Host) | APPROVE | `HandHold` only from a `demo-claim/` hold, after the signed retirement and tombstone checks. The root purge preconditions (`instancectl/demo_cleanup.go:78-92`) are unchanged and never checked expiry. | | instancectl/demo_cleanup.go `purgeDemoWithJobs` (−ReadDir) | APPROVE | Pure extraction into `stopDemoUnits` (`demo_cleanup.go:165-240`). Same derived unit set, stop calls and cgroup-empty proofs, and the same removals afterwards. | | provision/seedreconcile.go `seedAction` (+ImportGate, Route) | APPROVE | Agent. Only adds skip and abort paths (`seedreconcile.go:102-126`). | | registry/registry.go `Registry.migrate` (+Exec, sql) | APPROVE | Fixed DDL for a one-row table. Runs as carlos or the registry child. See P3-2 on the claim wording. | ### New and reads-changed dispositions (all accepted-legacy unless noted) | unit | verdict | evidence | |---|---|---| | democlaim/snapshot.go `checkWALBounds`, `contextReader.Read`, `copySnapshotFile`, `finishSnapshot` | APPROVE | Helper only: `finishSnapshot` refuses euid 0 (`snapshot.go:82`). Its only production caller is `RunSnapshotWorkerIn`. | | democlaim/source_linux.go `Source.open`, `VerifyUnchanged` | APPROVE | openat2 with `RESOLVE_BENEATH\|NO_SYMLINKS\|NO_MAGICLINKS` and `O_NONBLOCK`; the file must be regular with nlink==1 and size ≤ 256 MiB (`source_linux.go:64-79`). Callers: root reading `/work` after the reap, and the agent reading the `NestedDBPath`-pinned DB (`host/demo_claim_snapshot.go:26-29`). | | democlaim/worker.go `RunSnapshotWorkerIn` | APPROVE | Refuses euid 0. Fixed `/work` path. `main.go` refuses any arguments. | | host/demo_claim.go `pickupDemoClaimHTTP` | APPROVE | Agent. Bounded `ReadAll`, strict decode, signature check. | | host/demo_claim_executor.go `abortDemoClaim`, `checkDemoClaimHeld`, `claimDemo`, `claimRoute`, `holdDemoClaim`, `restoreDemoClaimHolds` | APPROVE | Agent-side registry reads and hold changes. Holds are restored only for valid job IDs on this box's fleet (`:320-329`). | | host/demo_claim_snapshot.go `wireDemoClaimSnapshot` | APPROVE | Reads `rt.DBPath` only to compare it with `NestedDBPath`; the derived path is what gets opened (`:26-30`). | | host/demo_serving.go `demoJobAllowed` | APPROVE | Adds a held-row refusal. | | host/seedwiring.go `claimSeedWakeHook` | APPROVE | Equality checks against the judged record. | | units/carlos-demo-snapshot@.service `external` | APPROVE | DynamicUser, no capabilities, `NoNewPrivileges`, private network/PIDs/IPC/devices, `TemporaryFileSystem` read-only over /data, /run, /var, /opt, /etc, /tmp. Only `/work` (the per-operation mount) is writable. Runs the fixed binary read-only. Memory, time and file-size limits. `checkUnit` checks the effective properties before every start (`demo_snapshot_disk.go:121-186`). Bootstrap installs every embedded unit (`bootstrap.go:551-559`, `703`). | | instancectl/demo_claim.go `handleDemoFreeze`, `freezeDemoLocal` | APPROVE | Request ≤ 16 KiB, strict, carrying only a descriptor and a `ValidJobID`. Host passes `ValidHostShape` and `ValidateBinding`. Registry values are equality checks only, under `lockDemo`. The paths are the cgroup parent plus `InstanceID(host)`. Root opens no DB and removes nothing, so this is strictly less than the existing purge. | | instancectl/demo_cleanup.go `stopDemoUnits` | APPROVE | `ReadDir` of ExeRoot and DropInDir (root-owned) moved out of purge, keeping only canonical keys of this host. | | instancectl/demo_snapshot.go `handleDemoSnapshot`, `exportDemoSnapshot`, `handleDemoSnapshotClose`, `snapshotHeld` | APPROVE | Multipart must be exactly metadata, db, wal, each with a single header (`:83-93`). Metadata ≤ 4 KiB; IDs pass `ValidJobID`; sizes ≤ 256 MiB; `io.CopyN` plus an EOF check (`:206-232`). `Statfs` is on the fixed `demoSnapshotRoot`. Output files are fixed names created `O_EXCL` beneath the work dir. The hold is checked three times (`:154`, `:237`, `:256`). | | instancectl/demo_snapshot.go `result` | APPROVE | Runs only after `stop()` has proved the unit inactive and its cgroup empty (`:246`). `result.json` is opened through `OpenBeneath` (regular file, no symlinks, `O_NONBLOCK`) and read ≤ 1025 bytes. `snapshot.db` goes through `OpenSource` (nlink==1, regular), hashed ≤ 256 MiB + 1, then `VerifyUnchanged` (`:433-466`). The helper can plant no FIFO, symlink or device (`nodev` mount, no `CAP_MKNOD`). A hard link can only point inside the fresh image, and nlink==1 blocks it for the DB. Nothing is left running to block on. | | instancectl/demo_snapshot.go `reap`, `checkReadiness` | APPROVE | Unit names and directory entries must be `ValidJobID`, or it fails closed. The root dir is 0700 and root-owned (checked at `:569`). `RemoveAll` goes through `os.Root`, only after the stop, the unmount and a `mountinfo` absence proof (`:407-432`). | | instancectl/demo_snapshot_client.go `demoSnapshotBody.Read` | APPROVE | Agent-side client stream. | | instancectl/demo_snapshot_disk.go `checkUnit` | APPROVE | Data literal and exact comparisons. | | instancectl/demo_snapshot_linux.go `emptyCgroup`, `snapshotDiskUnmounted`, `verifySnapshotDisk` | APPROVE | Paths derived from the cgroup root plus a validated unit name. Reads the process's own `/proc/self/mountinfo`. `verifySnapshotDisk` requires a different device, ext4, bounded size, and nodev, nosuid, noexec. | | (prepareDisk, mount unit, reached from exportDemoSnapshot) | APPROVE | Pinned to `demoSnapshotRoot` and `/run/systemd/system`. `What`/`Where` come only from the validated ID; unit names use systemd escaping (`-` becomes `\x2d`). mkfs gets fixed arguments on a root-created, fallocated image. The unit file is created `O_EXCL` (`demo_snapshot_disk.go:28-91`). | | provision/demo_claim_seed.go `validateDemoClaimSeed`, `demoClaimSeedRow`, `abortDemoClaimSeed` | APPROVE | Agent. Abort removes only at the derived `NestedDBPath` (`:150-157`). | | provision/demo_claim_seed.go `removeDemoClaimOrphan` | APPROVE | Agent (carlos) only; root never runs `Reconcile`. A demo-claim row's `DBPath` is always derived: the seed requires `DerivesPaths` (`:30`) and `RouteFor` sets `DefaultDBPath`. No tenant or app input reaches it. Only the agent can write such a row, and the agent is the actor. See P3-3. | | registry/demo_claim_seed.go `CompareSeedGate`, `CreateSeedRoute`, `DeleteSeedRoute` | APPROVE | Compare-and-swap SQL on the full identity. | | registry/registry.go `DemoMoved`, `CompareDemoMoved`, `Fingerprint`, `SnapshotFingerprint` | APPROVE | One-row blob, ≤ 1 MiB on write, verified by every reader. See P3-2. | | reads: activator `doWakeOnce`, edge `importGateAdmit`, host `convergeAdopted`, provision `AssertDemoRoute`, `Reconcile`, `RouteFor` (authority C,E3) | APPROVE | All refusal-adding or agent-side. `RouteFor` derives `HoldOp` and `Status` from the console-owned `DemoClaim`. `demoFixedForWrite` stops ordinary writers changing it, and `ValidJobID` is enforced. Root uses those fields only as equality gates for actions the agent can already request. | ### Envelopes `.`, `internal/activator`, `internal/demo`, `internal/demobuild`, `internal/democlaim`, `internal/edge`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/provision`, `internal/registry`, `internal/release`, `internal/seeds`, `internal/status`: **APPROVE**, all 14. I read every changed non-test production file the card names. The notable points: - `main.go` adds the `__demo-snapshot` entry point, which accepts no arguments. - `demo.Config` gains a `CARLOS_DEMO_CLAIM` flag. - The demobuild retirement now accepts reason `claimed`. It is signed, and root purge never checked expiry. - `release` adds the `control/demo-moved.json` scope. - `seeds` raises the protocol to 2 and parses the claim ID strictly. No change lets root open, follow, run or query anything new from a path or input a tenant, app or agent can name. No check root relies on is weakened. ### Findings (P3 only; follow-up list, no round) 1. **Stale comment.** `internal/host/units/carlos-instance-control.service:33-34` says nothing but the per-generation drop-in is written to `/run/systemd/system`. Root now also writes `<escaped>.mount` units there (`demo_snapshot_disk.go:58-59`). Fix: update the comment. Invariant: the root write set of `/run/systemd/system`. 2. **Claim text is wrong.** The claims for `Registry.migrate`, `CompareDemoMoved`, `Fingerprint` and `SnapshotFingerprint` describe a "monotonic generation" or "increment a local generation". The code has no generation column: the table is `(id, wire)` and the fingerprints hash the wire bytes. Fix: correct those claim lines on the next `census-propose` rerun. Invariant: census basis accuracy. 3. **Weaker path check than the existing pattern.** `removeDemoClaimOrphan` (`demo_claim_seed.go:201`, `245-250`) checks `row.DBPath` only with `NestedPaths`. That check is an OR over DBPath and Socket prefixes. The existing import rollback pins `rt.DBPath == NestedDBPath(cfg.DataDir, j.Host)` (`seedrollback.go:79-80`). This is agent-only, and the row is derived by the agent, so it is not a root finding. Fix: add `row.DBPath == NestedDBPath(cfg.DataDir, row.Host)` to the guard at `:201` for parity. Invariant: seed removal touches only the derived nested DB. 4. **Dead code.** `democlaim.ExportSQLite` (`snapshot.go:37-78`) has no production caller. It refuses root, so it is harmless. Remove it or mark it test-only. One deployment note, not a census issue: `ensureSystemUnits`' list (`systemunits.go:36`) does not include `carlos-demo-snapshot@.service`. Only bootstrap's sweep of all embedded units installs it, plus whatever the private roll script copies, which I could not check. On a box without the template, `checkReadiness` fails, so claims are refused rather than run unconfined. Confirm the roll script installs it before claims are switched on. **Verdict: APPROVED** (reviewer: Opus, other family than Astra; tip 1b764ad6).</result> <usage><subagent_tokens>201774</subagent_tokens><tool_uses>49</tool_uses><duration_ms>389400</duration_ms></usage> </task-notification>
<task-notification> <task-id>a95b29099847e37ad</task-id> <tool-use-id>toolu_01Wm7do2d3nh2m8pz4pbseqB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a95b29099847e37ad.output</output-file> <status>completed</status> <summary>Agent "Whole-branch review (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Verdict: READY AFTER FIXES.** There are no P1s and two P2s. Both P2s come from Task 8's new wiring and both are cheap to fix. I confirmed each one by running a throwaway test through `go test -overlay` from `$TMPDIR`. Nothing in the worktree was edited, and the tree is clean. ## Tests run (focused, `nice`, default Go cache) - **All pass:** `TestDemoClaimEmailToPermanent`, `FailureKeepsDemo`, `OffCompatibility`, `Readiness`, `ReadinessCache`, `ReadinessDeadline`, `RecoveryRoutes`, `Config`, `AvailabilityResponse`, `CommitRecovery`, `AccountRace`, `ProofBinding`, `BrowserIdentity`, `Transfer`, `ExpiryRace`, `Retirement`, `RequestCost*`, `SnapshotWAL` (democlaim), `FreezeRecovery` (instancectl) and `TestDemoMovedPrecedesCache` (edge). - **One caveat:** `TestDemoClaimEmailToPermanent` fails inside the bubblewrap sandbox because creating the Unix socket is blocked ("operation not permitted"). It passes outside the sandbox. CI should not hit this. - **Review Focus 1-5:** every item has its owning test, and all of them pass. ## P1 None. ## P2 **P2-1. With admission off, the job loop now wakes every second and logs each time for any `ready` demo job.** - **Fault family:** admission switch vs recovery-loop scheduling (cost/noise). - **Cause:** Task 8 lets `RunDemoJobs` run when only the demo account/fleet/domain settings are present (`internal/console/demo_jobs.go:459`, `cmd/console/main.go:715`). The loop still calls `publishReadyDemos` (`demo_jobs.go:472`) and schedules `ready` jobs at now+1s (`:485`). `publishDemo` and `finishDemoPublish` both return `errDemoJob` when admission is off (`demo_publish.go:48`, `:333`), so the job never leaves `ready`. - **Failure scenario:** a worker result lands after the console restarts with `CARLOS_DEMO_APPS` unset (the README's documented post-smoke state). The overlay witness logged 5 "demo publication" lines in 3.5 s. That continues until the demo expires, up to about 86k lines a day per job. Before Task 8 this loop did not run with admission off. - **Fix:** in `RunDemoJobs`, only call `publishReadyDemos` and the `demo_jobs` deadline query when `s.cfg.Demo.Enabled`. Keep `ReconcileDemoClaims` and the claim timer running. Add a `ready`-job case to `TestDemoClaimOffCompatibility/admissionOffIdle`. **P2-2. An aborting claim waiting for the destination to stop reads the store every 2 s with no backoff, for as long as it waits.** - **Fault family:** request cost. The plan says idle claims cause zero extra store requests. This is the same family as Task 5's P2-3, whose fix covered committed waits and the cleanup=1 abort wait but missed this sub-state. - **Cause:** `ReconcileDemoClaims` picks up aborting ops with `p.cleanup=0` (`demo_claim_transfer.go:892`). `continueDemoClaimAbort`, via `abortDemoClaimSeed`/`requestDemoClaimSeedAbort` (`:806`), reads the destination record. The retry update (`:937`) only applies doubling backoff to `committed`; everything else retries at 2 s. - **Failure scenario:** the destination box is offline when the claim aborts. The overlay witness showed 1 GET per tick after the abort, with cleanup=false. That is about 43k GETs a day per stuck op. Because cleanup stays 0, `retireDemoLocked` keeps returning `ErrDemoBusy`, so the wait does not end at source expiry either. - **Fix:** - Apply the committed backoff (2 s doubling, capped at 5 min) to `phase='aborting' AND cleanup=0`. - Reset `retry_delay`/`retry_at` when the seed state changes, or on the target app's change scope. - Extend `TestDemoClaimRequestCostAbortWait` with a seed that has not yet been rolled back. ## P3 (follow-ups) 1. **Mislabelled readiness case.** `TestDemoClaimReadiness` "placement" sets `HostClaim=true` (`demo_claim_ready_test.go:59-60`), which stops at `demo_claim_ready.go:17`. It never reaches the linux-arm64 placement check in `demoClaimSeedReady`. Add a case for a non-arm64 box in the home region. (Test coverage.) 2. **Readiness blocks and flaps.** `demoClaimReady` holds its cache mutex for the whole 10 s check, so concurrent create responses and claim handlers wait behind it. A single transient failure is cached for 45 s, and during that time every `reserved` op aborts with "disabled" (`demo_claim_transfer.go:102`). That is safe, because it refuses before freeze, but it is noisy. (Availability.) 3. **Missing baseline in the off-compatibility test.** `TestDemoClaimOffCompatibility` does not contain the plan's "ordinary email/seed/import/apps => baseline" leg. Task 8 covered it by running the existing tests separately. 4. **Lock order.** `commitDemoClaim` locks only the target account, not the demo holding account (the plan says sorted account locks). It is safe today because the source app lock is held and the op lock is consistently outermost. I checked the commit, finish, abort, pin, hold, retirement-ack and expiry paths. 5. **Intent exemption is path-based.** The R13 exemption checks `r.URL.Path != "/demo/claim/intent"` (`demo_claim_page.go:175`); the controller already noted this. Also, rotating the cookie for demo B drops that browser's status view of demo A. ## Integration checks that hold - **Identities agree across tasks:** the op ID serves as work ID, hold ID, seed `ClaimID` and verify-token HMAC input. The moved row carries the source host, `apexHost` target and `SourceExpiresAt`. - **Commit:** a single transaction rechecks membership, caps (`checkRunningThings(...,0)`), hold ack, snapshot, lifetime and generation. It clears the token hash, deletes the flows and enqueues open/moved/retire. - **No source resume after commit:** clearing the hold requires `aborting` with cleanup=1. - **Expiry vs uncommitted claims:** expiry cannot retire an uncommitted source until destination cleanup (`retireDemoLocked` pending check). - **Expiry and the moved page:** the original expiry is never extended, and the moved notice expires at it. - **Invalid moved rows are skipped,** so publication still completes and nothing strands a committed claim. - **R5a holds:** only start/verify/select, browser proof/select/link, and the not-yet-frozen reserved/freezing phases check `demoClaimEnabled`. Status, box pickup/snapshot/ack, abort, committed recovery, retirement-ack and moved notices do not, and their routes register under the account/fleet/domain settings alone. - **Switch parsing and availability:** `CARLOS_DEMO_CLAIM` accepts only unset or "1". `claimAvailable` comes from `demoClaimEnabled()`. - **Dev witnesses:** both `DevAcceptance` entry points skip without `CARLOS_DEMO_CLAIM_DEV_WITNESS=1` (R6). - **The e2e test drives the real coordinator:** real handlers, `advanceDemoClaim`, the real exporter on an actual WAL, and an HTTP snapshot. Only root stop and seed placement/first replica are faked. - **README:** the operator and API notes match the code. ## Triage of deferred minors and P3s **Must fix before merge:** none. **Already fixed on the branch:** - T1 P3-2 (audit via `auditSignInRow`). - T1 P3-3 (429 `errDemoClaimSignupBusy`). - T1 P3-4 (explicit choice parameter). - T1 P3-7 / T5 moved-notice pruning (`pruneDemoClaims`). - T3 carried P3-4 (console checks digest, size and integrity in `acceptDemoClaimSnapshotLocked`). - T4 seeds floor minimum 2 (README activation step). - T5 overwrite of the stored abort reason (now uses CASE to keep it). - T5 notify ordering (the box is notified after `hold_ready` is written). - T5 committed backoff reset (on outbox progress and retirement ack). **Can stay as follow-ups:** - T1 P3-1, P3-5, P3-6. - T2 P3-4, P3-5, P3-6, P3-7. - T3 P3-a, P3-b, R11, and agent cancels its own POST. - T4 P3-1 orphan purge, P3-2, P3-4, P3-5. - T6 non-monotonic snapshot after a domain change, SQLite busy using up a generation, `SignMoved` failing on duplicates or overflow (guarded at reservation), and P3-4 fingerprint cost. - T7 path-based intent exemption. None of these lets two apps be writable at once or strands a committed claim. The open T3/T4 items are covered by the post-merge dev witness (R6). **Verdict: READY AFTER FIXES** (P2-1, P2-2).</result> <usage><subagent_tokens>193451</subagent_tokens><tool_uses>51</tool_uses><duration_ms>514072</duration_ms></usage> </task-notification>
<task-notification> <task-id>bmt7dr0ge</task-id> <tool-use-id>toolu_01DyvPQGvZBLhk7yFb8Ayhj1</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bmt7dr0ge.output</output-file> <status>killed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/cifix.done ]; do sleep 60; done; tail -1 $S/cifix.log" was stopped after reaching its background time limit</summary> <note>If the work in progress still needs it, start it again with `run_in_background` and a longer `timeout`. If it already had the longest `timeout` allowed, do not restart it. Either way, report that it was stopped.</note> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="09a353a3-2286-4620-b3dc-88e91723d2a4" source-agent-title="agent /start demo program controller"> From 39e7acfa: the CI-fix Codex run has spent almost 4 hours running full package suites locally, one after another (host, then console). Our rule is targeted tests locally and CI as the full gate. Please stop it now: kill that codex run (its edits stay in the worktree), check the diff yourself, commit in small commits (codex author), push, and let amadan CI run on the tip. If CI fails, give Astra only the failing tests to fix, with targeted runs. Then do the final review fix wave the same way. Send me the merge sha when it lands. </paseo-system>
<task-notification> <task-id>btm7dqbml</task-id> <tool-use-id>toolu_01PG9MeDkEntKGJxVoKCYxrm</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/btm7dqbml.output</output-file> <status>killed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/cifix.done ]; do sleep 60; done; tail -1 $S/cifix.log" was stopped after reaching its background time limit</summary> <note>If the work in progress still needs it, start it again with `run_in_background` and a longer `timeout`. If it already had the longest `timeout` allowed, do not restart it. Either way, report that it was stopped.</note> </task-notification>
<task-notification> <task-id>bh9yw9xkm</task-id> <tool-use-id>toolu_01Lb5rUg2oxSNjV2fLBMgbcY</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bh9yw9xkm.output</output-file> <status>completed</status> <summary>Background command "until amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -q '76f358e4.*\(passed\|failed\|succeeded\|green\)'; do sleep 60; done; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -3" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bwr3v02ql</task-id> <tool-use-id>toolu_01Ukue5FwdHstdVYsjeEJwYH</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bwr3v02ql.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/finalfix.done ]; do sleep 60; done; tail -1 $S/finalfix.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a167e5be296dcbcd9</task-id> <tool-use-id>toolu_01UbNuX1Fwbfru6uuhRqipgR</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a167e5be296dcbcd9.output</output-file> <status>completed</status> <summary>Agent "Re-review final fix wave" 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.** All three findings are addressed. The fix diff adds no new P1 or P2, only two P3s, and neither one blocks landing. ## Findings **P2-1, admission switch vs loop scheduling: ADDRESSED.** - `publishReadyDemos` now runs only when admission is on (`internal/console/demo_jobs.go:475-479`). - The `demo_jobs` deadline query only runs with admission on, through `nextDemoJobDeadline` (`demo_jobs.go:489` and `:519-526`). - `ReconcileDemoClaims` and the claim timer still run every pass (`demo_jobs.go:480-488`). - `ObserveDemoJobs` no longer exits early when admission is off, so it can feed target changes to claims. `DispatchDemoChanges` still checks the switch itself (`demo_jobs.go:284`), so build-job dispatch stays off. - The test is `TestDemoClaimOffCompatibility/admissionOffIdle` (`demo_claim_e2e_test.go:447`). **P2-2, one backoff for every idle pass (R14): ADDRESSED.** - A single function, `backoffDemoClaim` (`demo_claim_transfer.go:977-1002`), sets the delay after every due pass, including errors. It starts at 2 s, doubles to a 5 min cap and is stored in SQL. It resets only on progress, which is now judged by a checkpoint of the durable progress fields rather than an outbox count (`:956-975`). - The selection query is now just "`retry_at` has passed" (`:893-895`). A re-check after taking the operation lock stops the job loop and the backstop from spending the same retry twice (`:924-933`). - The freezing wait does no store work once the hold is in place (`:157-159`). - External signals clear the delay and are ignored when repeated: - freeze ack and abort ack: `apidemobox.go:509,515` - snapshot accepted: `demo_claim_transfer.go:512` - operator retire: `demo_expiry.go:141` - retirement ack: `demo_expiry.go:396` - target change: `demo_claim_transfer.go:1008-1040`, with the generation stored (`demo_claim_store.go:55`) - The table-driven test `TestDemoClaimRequestCostEveryWait` (`demo_claim_backoff_test.go:40-45`) walks 13 states, which covers every wait state you listed plus "aborted". Signals are covered by `TestDemoClaimBackoffSignals` (`:221`) and deadlines by `TestDemoClaimBackoffDeadline` (`:321`). **Census P3s: ADDRESSED.** - The service comment now names the escaped `.mount` units (`internal/host/units/carlos-instance-control.service:33-34`). - The four registry claim lines now describe `(id, wire)` and hashing the wire bytes. "monotonic generation" no longer appears in the claims file. The only remaining "monotonic" is an unrelated heartbeat line. - `removeDemoClaimOrphan` now requires the database path to match the one derived from the host (`internal/provision/demo_claim_seed.go:201`). The `siblingDB` and `outsideDB` cases are in `demo_claim_seed_test.go:326-394`. - The service comment has a new external-file claim, and the report says the census rerun passed. ## Checks on the new behaviour - **Deadlines.** The next retry is capped at whichever future time comes first: `phase_until` (the 30 s freeze, 120 s snapshot and 60 s verify windows), the overall deadline for the pre-commit phases, or the source expiry while aborting. `advanceDemoClaimLocked` uses `>=` and `!Before` against those same instants (`:93-95`), so a pass that runs at the capped time aborts. One gap remains (P3-A below). - **Signals.** Freeze ack, abort ack, snapshot accepted and retirement ack all clear `retry_at` and `retry_delay` and call `signalDemoJobs`. A target change, which covers placement and moved/open, is consumed inside the loop itself, and `ReconcileDemoClaims` runs right after it in the same iteration. - **Committed operations never stop retrying.** The delay is capped at 5 min and `retry_at` is always rewritten. If the backoff write fails, the old `retry_at` stays due and the loop's 1 s floor picks it up again. - **No job is stranded by the admission switch.** Admission is set in config and only changes on restart. Before this fix, a ready job with admission off was also left alone: `publishDemo` and `finishDemoPublish` both return `errDemoJob` (`demo_publish.go:48,333`), so the only effect was a log line every second. When admission comes back on after a restart, `recoverDemoSpools` moves half-published stages to `settling:` or fails them (`demo_spool.go:228-247`), and `publishReadyDemos` takes over. While admission is off, those jobs still count as busy for `pinDemoClaim`, which is the same as before. ## New issues **P3-A: an abort can run late if a pass is still running when its deadline passes.** This is a new kind of fault (deadline scheduling), the reverse side of R14. - `backoffDemoClaim` only caps the next retry at deadlines that are still ahead at the end of the pass (`demo_claim_transfer.go:993-996`, using `now.Add(time.Since(started))`). - So a pass that starts before a deadline and finishes after it never sees the deadline and never aborts. The next pass is then scheduled a full backoff delay later. For example, a verify `readRecord` cut off by the `op.Deadline` context would do this. - `TestDemoClaimBackoffDeadline` (`:335-347`) covers an expired deadline after an abort attempt, not this case. - How late it can be: about 64 s in the freeze and verify windows, about 128 s in the copy window, and up to 5 min for source expiry while aborting. - Safety holds, because the next pass still checks the deadline first. The cost is that the source stays frozen longer. - Fix: base the cap on the pass's start time (if the deadline is after `started`, retry at max(deadline, end)). That keeps the rule that an already-handled overdue deadline must not bypass backoff. **P3-B: one busy claim lock stalls change dispatch for every scope after it.** This is a new coupling between claims and build jobs. - `dispatchDemoClaimChanges` returns `ErrDemoBusy` when `tryLock` fails (`:1028-1031`). `ObserveDemoJobs` then returns (`demo_jobs.go:448-450`), which skips that scope's `DispatchDemoChanges` and every scope sorted after it. - The holder can be a snapshot upload, which keeps the lock for up to 120 s (`demo_claim_transfer.go:423`), or a backstop pass. - While the claim operation is due, the 1 s floor limits the delay. If an upload fails, there is no signal, and later scopes wait for the next timer. That timer could be a queued job's deadline, which `reconcileDemoJobState` acts on before the next observation. - It is rare and recovers by itself. Fix: on a busy lock, `continue` past that scope without recording it as observed, instead of returning. I ran no tests; this verdict comes from reading the code. The diff and report are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/.superpowers/sdd/2026-11-04-agent-start-demo-3-claim/`. **READY**</result> <usage><subagent_tokens>93626</subagent_tokens><tool_uses>18</tool_uses><duration_ms>240900</duration_ms></usage> </task-notification>
<task-notification> <task-id>b1ulhf3bz</task-id> <tool-use-id>toolu_01KpcvKs6RFN34N1stqKj3Y5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b1ulhf3bz.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/judged.done ]; do sleep 30; done; tail -1 $S/judged.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bchc3700p</task-id> <tool-use-id>toolu_0117PpmAdNKbRCzVxF2j1cdZ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bchc3700p.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/judged2.done ]; do sleep 30; done; tail -1 $S/judged2.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bx21uql8s</task-id> <tool-use-id>toolu_01E4Vn7STbu1uX7Q5dRNDgY2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bx21uql8s.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/merge.done ]; do sleep 30; done; tail -1 $S/merge.log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a5c0e0f9d8d30910d</task-id> <tool-use-id>toolu_01V2vF8EsdM5mwZ5XvKsy8WP</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a5c0e0f9d8d30910d.output</output-file> <status>completed</status> <summary>Agent "Check merge integration delta" 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. I found no P1 or P2 problems in the merge resolution (8a46f17d), and one P3. I read the remerge diff for `internal/console` and `internal/edge`, and main's alias code in `internal/edge/demo_api.go` and `internal/console/demo_api_origin.go`. I checked how the client IP is chosen, how `sameOrigin` works, and what the four claim handlers read. **(1) Direct requests to the console.** These can't fake their way past the IP limits or the origin rules. - **Untrusted callers:** if the caller is not a trusted proxy, `requireDemoAPIProof` passes the request through, but `clientIP` then ignores `X-Forwarded-For` and keys the send, guess and new-person limits on the caller's own address. - **Trusted callers:** if the caller is a trusted proxy and the site alias is configured, the request needs all of the following, or it gets a 503 before any credential read or budget spend: - the console's Host; - exactly one canonical `X-Forwarded-For` value; - exactly one valid proof (`demo_api_origin.go:34-62`). - **Order:** the proof check now runs first in all four handlers (start, verify, select, status), ahead of `demoClaimGate` and `demoClaimOrigin`. - **Faked site Origin:** this gains nothing. A non-browser client can already send no Origin at all and pass. A browser page on the site that calls the console host directly sends `Sec-Fetch-Site: cross-site` or `same-site`, which is refused (`demo_claim_auth.go:46-50`). The new test checks exactly this case. **(2) CSRF.** None of the agent handlers (`handleDemoClaimStart`, `Verify`, `Select`, `Status`, `demoClaimAccountChoice`, `newAppRegionReq`) reads a cookie or session. They are authorised only by the claim token, the flow token and the emailed code. The only cookie in the file is set by the browser email-link page, which is on `/auth/email/link`, not a claim API path. The site Origin is accepted only when it matches exactly. A third-party page carries its own Origin and is refused, and even if it got through, it would have no ambient credential to use. **(3) What the alias forwards.** Only the four exact routes, each with its one method (`edge/demo_api.go:44-52`). The path must be canonical: - `RequestURI` must equal the path; - no `RawPath`, no query, no `ForceQuery`; - `path.Clean` must not change it; - no upgrade requests. HEAD, PUT and OPTIONS, a trailing slash, `/claims/unknown`, `%63laims` and query strings all get a 404. `/demo/claim*` and `/api/box/demo-claims/*` are outside `/api/demo`, so on the site host they fall through to normal site serving and never reach the console proxy. Box callbacks are unchanged. **(4) Passing `Sec-Fetch-Site` through.** This makes the check stricter, not looser. Browsers set the header and page scripts can't change it. Before this change, the filtered proxy dropped it, so the console saw it as empty, which counts as allowed. A cross-site page on either host now arrives as `cross-site` and is refused. Only a request made by a page on the site itself shows up as `same-origin`. **(5) The Bearer flow token on status.** `Authorization` is on the forwarding allowlist and goes through unchanged. Nothing in the edge or console code logs it; the edge only uses it to decide caching, and responses are forced to `no-store, private`. The token travels in the header, and the edge refuses any status request that has a query string. **Finding** - **P3 (allowlist wider than the routes).** `internal/console/demo_claim_auth.go:30-31` accepts the site Origin for any path starting with `/api/demo/claims/`, not just the three routes under it. It's harmless today: only the four registered claim handlers reach this check through that prefix, and the edge forwards only those four routes. But a future handler under that prefix would accept the site Origin without anyone deciding it should. Matching the exact set of paths would close this. **Tests.** I ran `nice go test`, targeted with `-run`: - `internal/console` (`TestDemoClaimAPIOrigin|TestDemoClaimAliasDispatch|TestDemoAPIProofRequired`) passed. - `internal/edge` (`TestDemoAPI`) passed with the `TestDemoAPIAliasBoundary/local_transports` subtest skipped. The sandbox blocks creating the unix socket that subtest needs ("operation not permitted"), so it still needs a run outside the sandbox. I made no edits and changed no git state. READY</result> <usage><subagent_tokens>73288</subagent_tokens><tool_uses>14</tool_uses><duration_ms>186657</duration_ms></usage> </task-notification>
<task-notification> <task-id>bj7otgig8</task-id> <tool-use-id>toolu_01HFmvkA2inPiz5JrUT21zZZ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bj7otgig8.output</output-file> <status>completed</status> <summary>Background command "sleep 30; until amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -q '8a46f17d.*CI \(passed\|failed\|succeeded\|green\|ok\)'; do sleep 60; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -q '8a46f17d' || true; done; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -3" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a89c61bb1e1ad3834</task-id> <tool-use-id>toolu_014GNTngYt1TxGQT8UFbHRq5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/a89c61bb1e1ad3834.output</output-file> <status>completed</status> <summary>Agent "Census delta recheck" 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>The census delta on agent-start-demo-3 is **APPROVED**, tip reviewed **8a46f17d** (branch side 599ca449, main side 40e1990b). I read the AGENTS.md census section, the branch's in-scope diff `1b764ad6..599ca449`, the merge resolution (`git show --remerge-diff 8a46f17d`), the card, the claims file and the overlay. None of the changes lets root open, run, query or follow anything new from a path or input a tenant, app or box agent can name. No check root relies on is weaker, and every disposition fits its unit's reads. Every change below either keeps or tightens what was approved at 1b764ad6. **Test run.** `nice go test ./internal/provision -run 'TestPlan14RootReadCensus$|TestCensus' -count=1` on the default Go cache: - **Passed:** `TestPlan14RootReadCensus` (overlay leaves the census clean), `TestCensusScopeIsTheRootBinary`, `TestCensusRebaseCarriesDispositions` and the classifier, proposal and claims tests. - **Failed, sandbox only:** 13 fixture tests (`TestCensusRebaseProof*`, `TestCensusScopeGuard`, `TestCensusScopedScan`, `TestCensusRemoval*` and others). They fail with `open /home/paulca/.cache/go-build/...: read-only file system` because the sandbox mounts the cache read-only and these tests build fixture modules into it. They never reached the tree under review. CI or an unsandboxed run should confirm them. **Per unit and envelope:** - **`internal/host/units/carlos-instance-control.service` `external`: approve.** Against main only the `/run/systemd/system` comment changed. Both `StateDirectory=carlos-demo-snapshots` and `StateDirectoryMode=0700` are gone from the shared unit. `ReadWritePaths` and every other directive match main. - **`internal/host/claimunit.go` `claimUnitContent` (body, authority): approve.** The StateDirectory lines are added only when `cfg.demo.BoxMode()` is true, in both the enabled and disabled branches. `cfg.demo` comes from `demo.BoxConfig` over the root-read host unit settings, not from anything a tenant controls. The directory is root-created with mode 0700, and no read is added. On a box without demo config the directory now stays read-only under `ProtectSystem=strict`, which fails closed. - **`internal/host/agent.go` `statusLoop` (legacy): approve.** It adds `DemoClaimSeedReady: os.Getenv("CARLOS_DEMO_CLAIM") == "1"`, an operator environment flag, with no file or registry read. The claim line now matches the code. - **`internal/host/edgesfile.go` `edgesFileCapabilities` (no census unit; host envelope): approve.** - `seeds.DemoClaimCapability` is advertised only when `CARLOS_DEMO_CLAIM=1`. - `democlaim.MovedCapability` additionally needs `demo.ValidDomain(getenv("CARLOS_DEMO_DOMAIN"))`. - Both conditions narrow what is advertised. - **`internal/status/snapshot.go` `CollectBox` (legacy): approve.** The capability list starts empty and gets the claim-seed and moved entries only from their probe flags. That narrows what the heartbeat advertises, with no new read. - **`internal/provision/demo_claim_seed.go` `removeDemoClaimOrphan` (new, accepted-legacy): approve.** It adds `|| row.DBPath != NestedDBPath(cfg.DataDir, row.Host)` to the refusal before any fence, stop or remove. `NestedDBPath` is `filepath.Join(InstanceDir(dataDir, host), host+".db")`. This tightens the earlier prefix check: the later `LocalSeedID(row.DBPath)` and `RemoveLocal(row)` can only reach the path derived from the host. The extra `DBPath ×2` and `Host ×5` reads in the claim match this comparison. - **`internal/registry/demo_claim_seed.go` `CompareSeedGate` and `DeleteSeedRoute` (new): approve.** Both statements keep `kind='instance'` and add `AND kind <> 'forward'`. That is redundant, but it is the explicit fence the registry uses everywhere else. The match only narrows. - **`internal/host/demo_claim_executor.go` `claimRecord`: no net change.** The judged read added in 6ae89653 was reverted in 599ca449, so the code is byte-identical to 1b764ad6, which I approved. It stays on the unjudged `provision.GetRecord`. The permit and its reason are in `internal/console/lifetimes_audit_test.go`, outside census scope. The function only compares the record against signed claim work, and a mismatch refuses. - **`internal/edge/demo_api.go` (merge resolution; edge envelope): approve.** - `demoAPIPath` now also allows POST to `/api/demo/claims`, `/api/demo/claims/verify` and `/api/demo/claims/select`, and GET `/api/demo/claims/status`. These are exact strings, and the canonical-path, no-query and no-upgrade checks still run before them. - The destination is still the operator's `CARLOS_DEMO_API_CONSOLE_ORIGIN`, taken from the upstream snapshot or `ExactHome`. Nothing in the request selects it. - `Sec-Fetch-Site` joins the request-header allowlist. It is a header forwarded to the console, not a root read. - **The merge's other in-scope files are tests only:** `group_names_test.go`, `plan9_b8_census_test.go`, `agent_start_demo_3_census_test.go` and the chain TSV. The record-write inventory now builds on main's `demoAPISiteRouteWriteCensusInventory()`, which is the correct parent. - **Envelopes: approve.** `.`, `internal/activator`, `internal/demo`, `internal/demobuild`, `internal/democlaim`, `internal/edge`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/provision`, `internal/registry`, `internal/release`, `internal/seeds`, `internal/status`. Each one is covered by the changes above or by main's own changes. The remaining in-scope edits since 1b764ad6 are `_test.go` files. All of your known items check out. The full card, claims and overlay are: - `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/docs/superpowers/notes/census-proposal-agent-start-demo-3.md` - `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/docs/superpowers/notes/census-agent-start-demo-3-claims.md` - `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-3/internal/provision/testdata/plan14-root-reads-agent-start-demo-3.tsv` **APPROVED**, tip 8a46f17d.</result> <usage><subagent_tokens>81804</subagent_tokens><tool_uses>20</tool_uses><duration_ms>135229</duration_ms></usage> </task-notification>
<task-notification> <task-id>bg1rgdd10</task-id> <tool-use-id>toolu_01BoJotyKqoRP1Kygkwm4VYZ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bg1rgdd10.output</output-file> <status>completed</status> <summary>Background command "sleep 60; until ! amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -q 'running\|queued\|pending'; do sleep 60; done; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -3" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b2ebxzshu</task-id> <tool-use-id>toolu_012wTYMU1g9nmFwj52sAT5i8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b2ebxzshu.output</output-file> <status>completed</status> <summary>Background command "sleep 90; until ! amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -1 | grep -q 'running\|queued\|pending'; do sleep 60; done; amadan ci status carlos/platform -branch agent-start-demo-3 2>&1 | head -3" completed (exit code 0)</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="da7e3a73-1cad-4c8a-9f90-77bd123a18a7" source-agent-title="agent /start demo program controller"> From 39e7acfa: release plan for your dev witness (8a3d302's ruling): v0.34.9 is being cut and published now by release agent c8c110dd. After the G2 drills (~02:00Z+), on 8a3d302's word, it rolls canary (sophie, demo box-1) and the dev console, with CARLOS_DEMO_CLAIM=1 riding those restarts. Dennis/leo (stable) and the seeds floor wait for the stable promote after G2 cleanup (T10 on #421). If your witness needs the stable boxes or the seeds floor, it waits for that too. Tell me exactly what the witness needs per box, so the release agent's phase 2 does it right. I'll tell you when canary + console are on v0.34.9. </paseo-system>
<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="ea15500c-37c2-4331-a74b-edc91ab84f05" source-agent-title="agent /start demo program controller"> From 39e7acfa: thanks, that's what I needed. One blocker to check in the merged code, please answer with file:line: the dev console has NO mailer, and Paul ruled he does the dev claim himself through his Keymail address in the browser. Does claimAvailable (or demoClaimSeedReady, or the claim start handler) require mail readiness? If it does, claims show unavailable on dev even for the Keymail browser path. In that case, tell me the smallest correct fix: for example, claimAvailable without a mailer when the browser path can complete, with email-code starts refused 503 as Task 1 specifies. Don't build it yet; I'll decide after your answer. Also confirm item 4: with the floor's min_release at v0.34.9, every box needs a second protocol-2 roll (prev binary) before claims turn on. Is setting min_release so a prev of v0.34.7 qualifies ever correct, or is a second release required by design? </paseo-system>