Claims cleanup: inventory, offline-move pause trim, dev trial undo (read-only notes)
Three investigations for the claims cleanup (amadan #404): which claim code runs with claims off, where the offline move's pause goes, and how to undo the dev claim trial. No code changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+1,184
−0
docs/superpowers/notes/claims-inventory.md+324 −0docs/superpowers/notes/dev-claim-trial-undo.md+616 −0docs/superpowers/notes/offline-move-pause-trim.md+244 −0
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/notes/claims-inventory.md b/docs/superpowers/notes/claims-inventory.md| new file mode 100644 |
| index 000000000..7217f26f4 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/claims-inventory.md |
| @@ -0,0 +1,324 @@ |
| +# Claims inventory: what to remove, what stays, and in what order |
| + |
| +Inventory of the shelved host lifecycle claim (amadan #404), taken at `9b81d97b` (origin/main) on 2026-10-25. Nothing was changed, built or run apart from `go list` for the import graph. The census numbers come from replaying the census overlay chain. Paths are repo-relative. |
| + |
| +**Production state assumed:** `CARLOS_HOST_CLAIM` is unset everywhere. No box has a root census (`/var/lib/carlos-claims/authority/exec/census.json`, `rootparticipation.Namespace`, `internal/rootparticipation/ledger.go:15`). `CARLOS_REGION_HA`, `CARLOS_MOVES_PHASE1` and `CONSOLE_APP_REGIONS` are off. `CARLOS_DB_FORWARD=1` on flagship. |
| + |
| +**Scope (Paul, 2026-10-25):** live moves and HA are parked, so nothing will reuse claim pieces. |
| +- Class C (features merged dormant that waited on claims) is now **delete** as well, and is folded into the removal order. |
| +- db push is kept separate (§6). |
| +- Salvage is cut down to the things that already run with claims off (§3). |
| + |
| +**Classes** |
| +- **A**: runs in production with claims off. If an A piece goes, the claims-off behaviour must stay identical. |
| +- **B**: claims-on only. Behind `CARLOS_HOST_CLAIM`, a root census, a guard-armed box, or an operator-only verb. |
| +- **C**: feeds a dormant claim-gated feature. Now delete. |
| + |
| +## 1. Claim packages and files |
| + |
| +Lines are non-test / test. Importers are production importers outside the package (from `go list`). |
| + |
| +| Package | Lines | Production importers | |
| +|---|---|---| |
| +| internal/hostclaim | 6,857 / 11,716 | activator, console, dbreads, genselect, host, hostactors, hostbox, hostexec, hostfence, hostguard, hostops, hostrelocate, hostresolve, moves, park (262 files) | |
| +| internal/hostops (+ fencerelease, internal/fencerelease) | 14,420 / 13,810 | claimactivation, console, host, hostrelocate, mail (76 files) | |
| +| internal/hostbox | 9,514 / 10,508 | activator, claimactivation, host, hostops, layout (191 files) | |
| +| internal/hostguard | 2,751 / 3,723 | activator, host, hostbox, hostexec, park (121 files) | |
| +| internal/hostexec | 2,779 / 2,993 | host only (22 files) | |
| +| internal/hostactors (+ awsmembership) | 2,952 / 3,675 | root CLI, claimactivation, console, historyreadback, host, hostfence, hostops, hostrelocate, hostresolve | |
| +| internal/park | 2,099 / 3,521 | console, host, hostbox, hostops, hostrelocate (68 files) | |
| +| internal/hostrelocate | 1,777 / 3,295 | host only (8 `relocation*` files) | |
| +| internal/rootstate | 987 / 873 | host, hostbox, hostexec, hostguard, release, rollout, rootparticipation | |
| +| internal/claimactivation | 933 / 1,466 | host only (`activation_artifacts_linux.go`, `activation_command_linux.go`) | |
| +| internal/hostfloor | 927 / 848 | claimactivation, console, host, hostactors, hostexec, hostfence, hostops, hostresolve | |
| +| internal/maintenanceguard | 811 / 619 | hostclaim, provision, release | |
| +| internal/hostresolve | 611 / 860 | root CLI (`hostclaim_cli.go`, `move.go`), console, hostops | |
| +| internal/rootparticipation | 601 / 415 | caps, host, hostexec, hostfloor | |
| +| internal/hostfence | 579 / 720 | root CLI, console, host, hostops, hostrelocate, hostresolve | |
| +| internal/genselect | 565 / 971 | console, host, hostbox, hostrelocate, moves | |
| +| internal/historyreadback | 444 / 987 | root CLI, host | |
| +| internal/boxchoice | 299 / 372 | console, edgesfile, host, hostops | |
| +| internal/termfence | 202 / 209 | host, hostactors, hostclaim, hostfence, hostops, hostrelocate | |
| +| internal/hostquarantine | 116 / 77 | hostactors, hostexec, hostresolve | |
| +| internal/hostwrite | 74 / 50 | activator, appconfig, console, host, hostbox, hostclaim, registry, release, rootparticipation, schedule | |
| +| internal/controlname | 8 / 0 | 17 packages (pure validators) | |
| +| internal/hostevidence | small | host, hostops | |
| +| internal/sim/hostlife | test only | none. A standalone claim lifecycle simulation, cited by `genselect/select_test.go:89` and `moves/budget.go:11` | |
| + |
| +**Claim files inside mixed packages:** |
| +- **internal/host.** 278 non-test files, about 50,600 lines: `claim*`, `root*`, `relocat*`, `guard*`, `join*`, `activation*`, `proofroot`, `proofbinding`, `movesheld*`, `edgesclaims`, `hostfencepass`, `updatesroot`. 468 test files: those prefixes plus `plan14_*`, `plan9*`, `plan11*`, `plan12*`. Also the moves Phase 1 files in §2. |
| +- **internal/activator.** `claim*.go`, `rolelaunch*.go`, the claim halves of `servingretry.go`, `probewake.go`, `recoveryprobe.go` and `swap.go`, and `generations*`/`worker*`, which carry claim rows. |
| +- **internal/console.** About 40 `claim_*.go` files, `apihostclaim.go`, `apidbclaim.go`, `hostclaim{backfill,executor,ops}.go`, `hostwakereset*.go`, `movesrecovery.go`, `enrollpass.go`, `awsmembership.go`, `hostactivation.go`, the `region*` files and `store_gate.go`. |
| +- **internal/instancectl.** `claim*.go` (`ClaimStop` and held-release routes), `legacy_claim_cleanup.go`. |
| +- **internal/registry.** `claimhold.go`, `claimrows.go`, `claimtimers.go`, `claimtransaction.go`, the claim branches in `timers.go`, `recoveryjournal.go` and `importjournal.go`. |
| +- **internal/release.** `roothistory*.go`, `rootgeneration*.go`, `rootrestart_history.go`, `rootbake.go`, `releaseexclusion.go`, `materializeheld.go:606`, `healthy_root.go` (A). |
| +- **internal/rollout.** `rootfailures.go`. |
| +- **internal/lease.** `claimgeneration.go`. Also `versioned.go` and `staging.go`, whose only constructors are on claim and Phase 1 paths (`movespass.go:531-534`, `claimproduction.go:169`, `relocatepass.go:258`, `cmd/console/main.go:373-384`). |
| +- **internal/caps.** `rootauthority.go`. |
| +- **internal/layout.** `census.go`. |
| +- **internal/appconfig.** The `RenderHeldUnder` half of `renderheld.go`. |
| +- **internal/edge.** `homemap.go:172`, `lbhealth.go:22` (region HA). |
| +- **Root CLI.** `hostclaim_cli.go`, `accounts_record_sequence.go:18,39`, `move.go:884-945` (`declareLost`), `proof_cli.go`/`history_cli.go`, and the `system.go:54-110` verbs `claims`, `files`, `guard-arm`, `guard-exec`, `journal-migrate`, `join`, `install-channel`. |
| +- **Units.** |
| + - `internal/host/units/carlos-system-update.service` and `carlos-system-recover.service`: the `guard-exec` branch, plus the `floor-allows-prev` branch (moves and seeds floors). |
| + - `carlos-system-join.{service,path}`. |
| +- **Scripts.** `scripts/activation-tools-root-runner.sh`, `scripts/plan14-console-root-runner.sh`. |
| +- **Census testdata.** `internal/provision/testdata/plan14-root-reads*.tsv` (117 overlays plus the chain manifest, 3.7 MB). Also the `*_census_test.go` files tied to claims: `claim_*_census_test.go`, `activation_tools_census_test.go`, `plan14_*` in `internal/provision` and `internal/host`, `hostbox/empty_census*_test.go`, `hostactors/census_test.go`, `console/claim_*_census_test.go`. |
| + |
| +## 2. Classification |
| + |
| +### 2.1 Packages: one class each |
| + |
| +When a package is A, only the slice named in the table runs. The rest of it is B or C and can go once that slice has moved out. |
| + |
| +| Package | Class | Evidence | |
| +|---|---|---| |
| +| hostwrite | A | **The switch itself.** Read on the wake path (`activator/activator.go:2115` `doWake`; `backend_exec.go:456,1486,3180`; `swapadmit.go:44` → `Config.Select` returns `legacy{}`, `hostwrite/write.go:33-36`), in `registry/timers.go:60,132`, `appconfig/renderheld.go:52,68`, `release/materializeheld.go:606` and `host/systemapply.go:1563`. Agent entry: `agent.go:241` → `claimEntryContext` (`claimassembly.go:51`). Remove last. | |
| +| controlname | A | Pure account, app and host validators. Used by `release.ValidApp` (`release/release.go:320`), `release/qualified.go:54`, `activator/maintenance.go:113`, `activator/seed_exclusion.go:16` and provision. Not claim-specific: **keep.** | |
| +| maintenanceguard | A | `RecordIdentity` (`maintenanceguard/types.go:62`) sits under `hostclaim.Incarnation`. Record decode in `provision/maintenance.go`; `release/workercontrol.go`. Keep (UNSURE whether the release worker-control half is live; not traced). | |
| +| rootstate | A | **Release-dir parent repair:** adopt → `recoverRootRestarts` (`agent.go:4993`) → `rootrollback_resume.go:24` `EnsurePublicDir(release.RootHealthyDir)` (`rootstate/shared_linux.go:10-55`). **D3 health store:** `release/healthy_root.go:27` `rootstate.Open`, through `RecordHealthy` and `readRootHealthy` (below). Keep. | |
| +| rootparticipation | A | **The census probe on every root adopt pass:** `RunAdopt` → `runAdoptWithEnsureSystemUnits` (`agent.go:4874-4886`) → `withClaimRootRelease` (`rootreleaselock.go:13`, which ignores its `bool`) → `withClaimReleaseCensus` → `OpenForUpdate` (`rootparticipation/production.go:70-89`). With no census it returns `required=false` and the effect runs directly. The same probe sits at about 15 effect sites (§2.3). Also `caps/rootauthority.go:12` (an `os.Lstat` on every `caps.Converge`/`Restore`/`Restart`, `host/caps_pass.go:92`, `release/adopt.go:1764,1798,1909`), and root `instance-control` startup (`claimstop_run.go:22`, `registerProductionLaunchVerifier`, which is fatal on error). Its purpose is claims-only, but it runs. | |
| +| hostfloor | A | `carlos system apply` → `beginExecutableChange` (`systemparticipation.go:48`) → `Disk.ParticipationRequired` (`hostfloor/disk.go:215-232`) → `legacy()`. Console system update and rollback doors: `hostfloor.Read` of `control/moves-protocol.json` (`console/hostactivation.go:31,209`; `hostfloor/floor.go:14,72`). When absent, they take the legacy path. | |
| +| hostclaim | A | Live slice: **`Incarnation`** (`hostclaim/claim.go:192`, a pure hash). Called by db forward (`dbreads/agent.go:218`; `console/apidbforward.go:415`, live with `CARLOS_DB_FORWARD=1`, gated `!HostClaim` at `apidbforward.go:66`), by carlos run (`host/runexec.go:103` from `armRunsPass`, `agent.go:627`; `console/apiruns.go:537`), and by `runs/runs.go`. Also **`Read`/`Key`**: the offline-move door's absence check (`console/apiinstancemove_offline.go:441` → `hostclaim/store.go:38`, `control/hosts/<host>.json`; any error gives a 502). Everything else is B or C. | |
| +| hostops | A | Live slice: `AdmissionKey` (`hostops/admission.go:98`), `CheckCreateFreeze` (`create_freeze.go:12`, a GET of `control/hosts-backfill.json`, `backfill.go:22`), both on the offline door (`apiinstancemove_offline.go:455,468`). Also error sentinels compared with `errors.Is` on claims-off console paths (`record.go:20-22`, `executor.go:17,24`; used at `console/domainattach.go:398,414`, `apidomains.go:560,1034`, `apisystem.go:146`, `scandeliver.go:243`). None of its 67 files is a general console operation. The rest is B. | |
| +| park | A | Live slice: `region.go` and `region_names.go`, pure wrappers over `regionname`. `HomePlacementCode` is used on the create door (`console/apiinstances.go:1250,1304` via `homeRegionIn`, `apiinstancemove.go:306,318`), on the regions door (`apiregions.go:49`), in `regionchoices.go:27,32`, `seedfloor.go:36,71`, `instancesplacement.go:204`, `boxselect.go:99,155`, the legacy move door (`apiinstancemove.go:427`) and the offline door (`apiinstancemove_offline.go:514,543`). `PlacementMatches` and `PlacementRegion` are used box-side on the offline path (`host/movesoffline.go:101,105,225,228,253,423,424,501`; `movesoffline_seal.go:217`; `movessources.go:76`). The sweep and the views are B or C. | |
| +| hostbox | A | Trivial slice: `agent.go:347` → `newClaimWiring` (`claimwiring.go:49`) → `hostbox.Startup` (`hostbox/identity.go:134-136`) returns a disabled config. Also the constant `hostbox.RequestLimit` (`agent.go:4936`). Everything else is B. | |
| +| hostactors | A | Live slice: `GroupBoxReference`, a pure hash on `CARLOS_BOX_REFERENCE=group` boxes (`RunAgent` → `agentEntry`, `joining.go:264` → `boxreference.go:86`). The console activation-cancel door is ungated: `authcli.go:1036` → `hostactivation.go:305` reads the roster and answers 404 with no roster. The rest is C (claim activation, region HA) or B. | |
| +| hostguard | B | Agent side: after `claimstop_run.go:35`. Moves land and rollback (`movesland.go:585`, `movesrollback.go`): C, behind `movespass.go:339`. In activator `swap.go:231-237` it is only `errors.Is` sentinels, which never match claims off. | |
| +| hostexec | B | System apply: `controllersRecovered` (`guardtransaction.go:422-438`) is reached only on a guard-armed box. `a.floor` is set only when `/opt/carlos/system/guard` holds non-legacy entries (`guardtransaction.go:535-542`). Otherwise `checkUnarmedParticipationRecovery` returns without a census (`systemparticipation.go:208-211`). The agent-side trace thought this was A; my check says B. UNSURE until it is confirmed that no box was guard-armed (the G10 harness host only?). | |
| +| hostfence | B | `hostfencepass.go:17`; `apihostclaim.go` routes only under `authcli.go:509`; CLI `ops host` under `hostclaim_cli.go:36`. The CLI `declareLost` (`move.go:884`) is C. | |
| +| genselect | B | Claim wake and owners (`claimproduction.go`, `claimwakeassembly.go`, `claimowners.go`). Moves parks and wake source need both switches (`movessources.go:697`, `moveswakesource.go:238`). `apidbclaim.go:220` is behind HostClaim. `moves/startcheck.go:121` is only reached through the wake owners. | |
| +| claimactivation | B | Operator verb only: `system.go:63` `carlos system claims` → `host/activation_command_linux.go:22`. | |
| +| hostquarantine, hostevidence, hostops/fencerelease | B | Only imported by B packages. | |
| +| hostrelocate | C (region HA) | `relocatepass.go:696` (`hostwrite.Enabled`), plus region HA. R-E2a exemptions in J4. | |
| +| termfence | C (region HA) | Only imported by B and C packages. | |
| +| hostactors/awsmembership | C (region HA) | `console/hostclaimops.go:55-62` → `enrollpass.go:89` → `awsmembership.go:15`. | |
| +| hostresolve | C (Phase 1) | Resolve routes are only registered with Phase 1 (`authcli.go:739-741`); `apihostclaim.go` is behind `authcli.go:509` (B). | |
| +| boxchoice | C (Phase 1, region HA) | `selectMoveBoxes` after `if !s.cfg.MovesEnabled` (`apiinstancemove.go:558,686`); `relocatepass.go:306`; `edgesfile/snapshot.go:11` (region HA placement). | |
| +| historyreadback | C (claim activation) | `carlos proof history` (`proof_cli.go:40` → `history_cli.go:28-32`) is ungated but needs an enrolled roster box (`historyreadback/readback.go:73-92`). `host/roothistory_readback.go` is census-gated. | |
| +| sim/hostlife | C | Test only, no importers. | |
| + |
| +**Counts:** A = 11 packages (hostwrite, controlname, maintenanceguard, rootstate, rootparticipation, hostfloor, hostclaim, hostops, park, hostbox, hostactors). B = 8 (hostguard, hostexec, hostfence, genselect, claimactivation, hostquarantine, hostevidence, hostops/fencerelease). C = 7 (hostrelocate, termfence, awsmembership, hostresolve, boxchoice, historyreadback, sim/hostlife). |
| + |
| +Of the 11 A packages, three are **kept whole** because they are not claim code in substance: controlname, rootstate and maintenanceguard. In five, **only a thin slice runs**: Incarnation; Read/Key; AdmissionKey/CheckCreateFreeze; the park region helpers; GroupBoxReference. Three **only probe or no-op**: hostwrite, rootparticipation, hostbox.Startup. |
| + |
| +### 2.2 Notable files in mixed packages |
| + |
| +| Where | Class | Evidence | |
| +|---|---|---| |
| +| release `healthy_root.go`, `proofgate.go:91-93,261-276` | A | **D3 health.** Write: `rootRestartRouteWith` (`agent.go:5045`) → legacy restart → `recordSettled(RootHealthyDir)` (`agent.go:5044`; `proofobserve.go:133-145`) → `recordRootHealthy` (`healthy_root.go:65-82`). Also `recordLive` (`proofroot.go:90-117`, `agent.go:5217`), named-unit routes only. Read: cold wake `materializeHook` (`agent.go:1327`) → `agentProofGate` (`proofask.go:43`) → `NewRootProofGate` → `readRootHealthy` (`healthy_root.go:48`), when the app's proof policy requires a proof. | |
| +| release `versions.go:294-340` (`PointLive`), `sweep.go:200-211` | A | **The previous pointer.** `adoptHost` (`adopt.go:1820`), and a cold wake's materialize (`materialize.go:50`), keep `/opt/carlos/previous/<host>`; the sweep pins its target. This is plain release code that imports no claim package. `runningVersion` comes from `rootrestart.go:138`, which returns `""` with no census. | |
| +| host `rootrestart.go`, `legacyrestart.go`, `rootreleaselock.go`, `rootrollback*.go`, `updatesroot.go`, `rootupdates*.go`, `proofbinding.go`, `proofnamed.go`, `rootroute.go`, `boxjudge.go` | A | Run in every adopt pass (`productionRootRestartChecks`, `agent.go:4982`). Each probes the census and then runs main's effect (§2.3). Proof binding feeds history and diagnostics only (`proofbinding.go:124`: no hostclaim reader; `rootroute.go:79-81`: `claimIdentity` returns `""`). `boxjudge.go:22` wires the lifetime judge (`agent.go:247,4902`; `seedwiring.go:162`), which is live and lives in provision. | |
| +| host `movesfloor.go`, `rootmovesfloor*.go`; units' `floor-allows-prev` branch | A (feature C) | The moves protocol floor is "the one Phase 1 element not behind `CARLOS_MOVES_PHASE1`" (`movesfloor.go:1-8`). `movesFloorLoop` runs on every agent (`edgesfile.go:980`) as an hourly GET of `control/moves-protocol.json`. `systemapply.go:416` `armFloor` runs on every system apply. It is a no-op unless the object was ever published. `floor-allows-prev` also serves the **seeds floor**, which is not claims: keep that verb. | |
| +| host `claim*`, `relocat*`, `guard*`, `root{execution,generation*,inventory*,migration*,floor*,history*,recovery*,record_claim}*`, `rootinstallation.go`, `claimcensus.go:198` | B | `agent.go:332` (claim assembly), `claimwiring.go:88` (regional worker), `claimfiles.go:228`, `agent.go:1108,1122`, `relocatepass.go:696`, `claimstop_run.go:35` (instance-control), and the census gates in §2.3. | |
| +| host `joining.go`, `joinroot.go`, `joinmode.go`, `boxrecord.go:26`, `edgesfile.go:984`, `edgesclaims.go:224` | C (region HA) | `joining.go:188` and `joinroot.go:84` need both switches. **`edgesfile.go:984` reads `hostclaim.Read` with `CARLOS_REGION_HA` alone**, claims off (UNSURE whether region HA is set anywhere). | |
| +| host moves Phase 1: `movesphase1.go`, `movescut.go`, `movesland*.go`, `movesrollback.go`, `movesrecover*.go`, `movesinstall.go` (rounds), `movesprobeowners.go`, `movesrecoveryowners.go`, `movesguard.go`, `moveswakesource.go`, `claimmove*.go`, `movesheld*.go` | C (Phase 1) | `armPhase1` and the Phase 1 rounds behind `movespass.go:326,339,1186,1298`. Offline (`movesoffline*.go`) and legacy (`legacyMoveRound`, `movespass.go:1493`) moves call none of them. | |
| +| moves: `offline.go`, `ids.go`, `switch.go`, `envreport.go`, `timers.go`, `readiness.go`, `check.go`, `archive/` | A | The offline and legacy move paths (`movesoffline.go:573`; door `apiinstancemove_offline.go:704`). None imports a claim package. | |
| +| moves: `build.go`, `parkscope.go`, `source.go`, `startcheck.go`, `seal.go`, `sealedclient.go`, `ltxbuild.go`, `probe.go`, `abort.go`, `returnlane.go`, `transition.go`, `journal.go`, `floor.go`, `lease.go`, `evidence.go`, `log.go`, `budget.go` | C (Phase 1) | Users are in `armPhase1` and its rounds (for example `movespass.go:466,523,605`). `moves` imports hostclaim and genselect only from these files. `floor.go` holds the moves floor key, which stays with the floor (above). | |
| +| activator `claim*.go`, `rolelaunch*.go` | B | `RoleLaunch` is built only by the claim wake assembly (`claimwakeassembly.go:123-146`) and used only from `claimwake.go`. `doClaimWake` is never reached with claims off (`activator.go:2115`). `Start` refuses with a nil `Root` (`rolelaunch_linux.go:24-25`). `ClaimArmed` is false (`seedwiring.go:150` ← `agent.go:616`). | |
| +| console `claim_*.go`, `apihostclaim.go`, `apidbclaim.go`, `hostclaim*.go`, `hostwakereset*.go`, gated `store_gate.go` | B | `cmd/console/main.go:339` `hostClaim := hostClaimEnabled(os.Getenv)` feeds `cfg.HostClaim` (`main.go:436`). Further gates: `main.go:373` (versioned store), `:522`, `:715` (`OpenGated`); `ConfigureClaimRuntime` returns early (`claim_runtime.go:24`). `store_gate.go:1724` (`gate == nil`) is a plain call claims off. **Nothing claim-related is needed at console startup.** | |
| +| console `movesrecovery.go`; the Phase 1 half of `apiinstancemove.go` (from `:558`); `writeMoveDetail` `:1525`; `PublishMovesConsole` `server.go:1752` | C (Phase 1) | `CARLOS_MOVES_PHASE1`: `moves/switch.go:6,14`, applied at `cmd/console/main.go:1671`. | |
| +| console `hostclaimexecutor.go:19`, `nocapacity.go:148,167,249`, `boxselect.go:204`, `regioncapacity.go`, `enrollpass.go`, `apiboxroles.go`, `authcli.go:518` | C (region HA) | `CARLOS_REGION_HA`: `cmd/console/main.go:1789` → `:413`. These also always need HostClaim. | |
| +| console `regionpicker.go:36,83`, `apicli.go:558,577`, `regionclaim.go:106`, `server.go:4543`, `regionconfig.go:11,43` | C (nearest region, Plan 15) | `CONSOLE_APP_REGIONS`: `cmd/console/main.go:417,1494`. Its only claim-package dependency is `park.HomePlacementCode`, which is already A. | |
| +| console `hostreports.go:67` (`StartHostReports`); `hostactivation.go` hostactors halves | C (claim activation) | Only with `CARLOS_CONSOLE_ID` (`main.go:438`), which only the claim activation install writes (`host/activation_console.go:36`), or with a published floor. | |
| +| console `apiinstancemove_offline.go:435-470` (`offlineClaimEvidence`) | A | Absence checks for the claim object, admission and backfill freeze (above). | |
| +| instancectl `claim*.go` (`ClaimStop`, `/claim/*`, held-release, `server.go:308-321`, `:1066`) | B | `claimstop_run.go:35-37` and `:114-118`. **Exception:** `instancectl.ClaimUnitControlGroup` (`claimunit.go:63`) is a pure path join that the **live offline path** uses (`movesoffline.go:406`). Rename it; do not delete it. | |
| +| registry `claim*.go`; the claim halves of `timers.go` | B | `registry/timers.go:60,132` (`!hostwrite.Enabled` takes the legacy timers). The `CREATE TABLE IF NOT EXISTS` claim tables (`claimrows.go:47`, `fencegen.go:25`, `recoveryjournal.go:81`, `importjournal.go:60`) exist in live DBs. Dropping the code is fine. Do not drop tables, and note that `@fields` in the census pins the struct field names. | |
| +| appconfig `RenderHeldUnder` | B | `RenderHeld` and `RenderHeldBefore` refuse when claims are on (`renderheld.go:52,68`); the `!writes.Enabled` branch (`movespass.go:487-490`) is A. | |
| +| rollout `rootfailures.go` | B | Only from `host/rootupdates.go:114,316`, after the census probe (`:85-100`). | |
| +| caps `rootauthority.go` | A | An Lstat of `census.json` on every caps operation (above). | |
| +| layout `census.go` | B | Only from `host/rootinventory_sibling.go:56` (census-gated root inventory). | |
| +| lease `claimgeneration.go` | C/B | `movescut.go:1512,1514` (Phase 1); `claimwakeassembly.go:526` (claims). | |
| +| lease `versioned.go`, `staging.go` | C/B | Constructors only at `movespass.go:531-534` (Phase 1), `movessources.go:703`, `claimproduction.go:169`, `relocatepass.go:258` and `cmd/console/main.go:373-384` (hostClaim). Possibly relevant to db push (§6). | |
| +| lease, everything else | A | Offline moves and hibernation use `Acquire`, `Restore`, mirror and tombstone (`movesoffline*.go`). Keep. | |
| +| dbreads `agent.go:218` | A | `hostclaim.Incarnation` (above). Refuses when claims are on (`host/dbreads.go:49-51`). | |
| +| edge `homemap.go:172,370`, `lbhealth.go:22` | C (region HA) | `privateDial` and LB health are off without `CARLOS_REGION_HA`. Imports no claim package. | |
| +| root CLI `hostclaim_cli.go`, `accounts_record_sequence.go` | B | `hostclaim_cli.go:36`; `accounts_record_sequence.go:18,39`. | |
| +| root CLI `move.go:884-945`, `proof_cli.go`, `history_cli.go` | C | The resolve door needs Phase 1 (`authcli.go:739`). Proof history needs a roster. | |
| +| root CLI `system.go` verbs `claims`, `files`, `guard-arm`, `guard-exec`, `journal-migrate` | B | Operator or claim tooling. In the units, `guard-exec` runs only if `census.json` or `/opt/carlos/system/guard/moves` exists (`carlos-system-update.service:47`, `carlos-system-recover.service:41`). | |
| +| root CLI `system.go` `join`, `install-channel`; `carlos-system-join.{service,path}` | C (region HA) | `joinroot.go:84` prints "off" and exits. The unit is installed and runs as a no-op. | |
| + |
| +### 2.3 Where "no census" chooses main's code |
| + |
| +From the wake-path trace. Each site calls `rootparticipation.OpenForUpdate`, and on absence takes the path shown. |
| +- **Restart:** `rootrestart.go:162,557` → `legacyCheckedUnitRestart` (`legacyrestart.go:48`). |
| +- **Rollback and start:** `rootrestart.go:442,524-525` → `legacyRollbackRestart` (`legacyrestart.go:86`) / `systemctl start`. |
| +- **Reset-failed:** `legacyrestart.go:88` vs `rootrestart.go:319,340`. |
| +- **Running version:** `rootrestart.go:138` returns `""`. |
| +- **Unit-shape check:** `claimunit_policy.go:163-169`; **capabilities:** `claimunit_policy.go:173-187`. |
| +- **Restart-recovery resume:** `rootrollback_resume.go:16-25` (only `EnsurePublicDir`). |
| +- **Root proof and history:** `proofroot.go:348-350`, `rootadoption_options.go:6-8`. |
| +- **Restart requests:** `rootrestart_requests.go:56-64`; **release exclusion:** `rootreleaselock.go:31-40`; **root update inputs:** `rootupdates.go:91-98`. |
| +- **Moves floor:** `movesfloor.go:451-458`, `rootmovesfloor_source.go:18-23`. |
| +- **System-apply participation:** `hostfloor/disk.go:215-232`; **root execution recovery:** `rootexecution_recovery.go:17-25`. |
| + |
| +**This is fail-closed today.** `rootstate.Open` refuses a non-root-owned or group/world-writable ancestor with `ErrPermission`. On the adopt pass that error is fatal (`agent.go:4881-4886`), and `legacyRootRestart` returns it (`legacyrestart.go:21-27`). Removing the probe removes that failure mode, which is a benign but real behaviour change. |
| + |
| +### 2.4 Risky dependencies |
| + |
| +The things live wakes and offline moves rely on. |
| + |
| +1. **Cold wake: `hostwrite` pass-through.** `activator.go:2115`, `backend_exec.go:456,1486,3180`, `swapadmit.go:44`. Removing it means deleting the claim branches without changing the legacy branches. |
| +2. **Cold wake: the D3 proof gate.** It reads `/var/lib/carlos-release/healthy/...` through `rootstate`. A wrong owner or mode reads as empty history and holds apps whose policy needs a proof. That is why `EnsurePublicDir` (rootstate) must stay. |
| +3. **Cold wake: the previous pointer.** If writing it fails inside `PointLive`, the wake fails. |
| +4. **Root `instance-control` startup.** It is fatal on `registerProductionLaunchVerifier` or `claimEntryContext` errors (`claimstop_run.go:22,31`). Nested wakes need this service. |
| +5. **The adopt pass.** It runs every restart, rollback and start behind the census probe, and a probe error is `log.Fatalf`. |
| +6. **Offline moves.** Console: `hostclaim.Read`, `hostops.AdmissionKey`, `hostops.CheckCreateFreeze` and `park.HomePlacementCode` in `offlineBeginChecks` (`apiinstancemove_offline.go:441-514`). Box: `park.PlacementMatches`/`PlacementRegion` and `instancectl.ClaimUnitControlGroup`. **At compile time, all of `moves`, `console`, `host` and `move.go` import hostclaim, hostops, park, hostfence and hostresolve.** No claim package can be deleted before these imports are cut. |
| +7. **db forward and carlos run.** Both use `hostclaim.Incarnation`, which must keep the exact same bytes. The console and the box both compute it, and both must agree. |
| + |
| +## 3. Salvage |
| + |
| +Short list: only the pieces already used with claims off. Keep or move them. |
| + |
| +| Piece | Where | Depends on | |
| +|---|---|---| |
| +| `Incarnation` (legacy hash plus `RecordIdentity`) | `hostclaim/claim.go:192-201`, `maintenanceguard/types.go:62` | controlname. Move it to provision or maintenanceguard. | |
| +| Region helpers | `park/region.go`, `park/region_names.go` | regionname (call it directly) | |
| +| Offline-door absence checks | `hostclaim.Key`/`Read`, `hostops.AdmissionKey`, `hostops.CheckCreateFreeze` + `BackfillKey` | release.Store. Keep them as console-local reads, or drop them once the buckets are shown to hold none of those keys (§4 R1). | |
| +| `rootstate` (`EnsurePublicDir`, root-owned `Open`) | `internal/rootstate` | safefile | |
| +| D3 health history | `release/healthy_root.go`, `proofgate.go`, `host/proofobserve.go`, `proofroot.go` | rootstate | |
| +| Previous pointer, release-dir repair | `release/versions.go:294-340`, `sweep.go:200-211`, `host/rootrollback_resume.go:24` | rootstate (repair only) | |
| +| `ClaimUnitControlGroup` | `instancectl/claimunit.go:63` | none (path join; rename it) | |
| +| `GroupBoxReference` | `hostactors` (`host/boxreference.go:86` caller) | none (pure hash) | |
| +| `controlname`; lease (all except `claimgeneration.go`, `versioned.go`, `staging.go`) | as is | | |
| + |
| +## 4. Removal order |
| + |
| +Every branch: |
| +- removes only code that is B or C, or code made dead by an earlier branch; |
| +- keeps each claims-off path byte-identical; |
| +- runs targeted tests locally and the full gate in CI; |
| +- needs a census overlay. With today's tooling, every deletion is an owner decision on #280 (§5). |
| + |
| +**Before each deletion, move any claims-off witness test out of the files being deleted.** About 80 tests are named `*FlagOff*`, `*ClaimsOff*`, `*NoCensus*` and so on, and 38 of them live in claim-named test files. Examples: `TestClaimSQLFlagOffStoreIsUngated`, `TestClaimRuntimeFlagOffDoesNotNeedProviders`, `TestAgentNoCensusShutdownBudget`, `TestClaimsOffGate*`, the activator's `TestAFlagOff*`. |
| + |
| +| # | Branch | Removes | Callers to edit | Claims-off behaviour that must stay identical | Tests that prove it | Touches | |
| +|---|---|---|---|---|---|---| |
| +| R0 | **census-removal plumbing** (test only) | nothing | `internal/provision`: a retired-envelope directive (`@coverage <dir> -`), and a `removed` change class in `census-propose`. `removed` would be approvable by a reviewer when the scan proves the declaration is absent, since a deletion cannot add a read. Today it is refused (`census_propose_test.go:255-262`). Also a J4 rule for retiring a family together with its witnesses. | The census still fails on every changed or new read. | `TestPlan14RootReadCensus*`, `TestPlan14RemovedH3NeedsCensusRuling`, `TestPlan14J4RemovalRequiresAbsentDeclaration`, census-propose tests; an owner ruling on #280 | — | |
| +| R1 | **move the live slices out** | nothing yet | `hostclaim.Incarnation` → `provision`: edit `dbreads/agent.go:218`, `host/runexec.go:103`, `console/apidbforward.go:415`, `console/apiruns.go:537`, `runs/runs.go`. `park.HomePlacementCode`/`PlacementMatches`/`PlacementRegion`/`SameRegion` → `regionname`: about 20 sites in console and in `host/movesoffline*.go`. The offline door's three absence checks become console-local. The `hostops` error sentinels on console claims-off paths are deleted (they never match). `hostbox.RequestLimit` and `GroupBoxReference` move into host. `ClaimUnitControlGroup` is renamed. | Incarnation bytes, for both the legacy and the created form. Placement codes. The offline door still 502s on any read error and refuses when a claim, admission or backfill object is present. | Golden vectors for `Incarnation`; dbreads and `dbforward_e2e_test.go`; runs/runexec tests; offline door tests and `self_serve_moves1_census_test.go`; console create and regions tests | console (create, regions, offline, db and run doors), box offline round | |
| +| R2 | **leaf: activation tooling and simulation** | `internal/claimactivation`; `host/activation_*.go` and tests; the `carlos system claims` verb (`system.go:54,63`); `internal/sim/hostlife`; `scripts/activation-tools-root-runner.sh`, `scripts/plan14-console-root-runner.sh` | `system.go`, `system_test.go:34`, `docs/site/cli.md` if the verb is listed (docsite gate) | No other `system` verb changes. | `system_test.go`, docsite test | — | |
| +| R3 | **C: region HA 2a/2b** | `hostrelocate`, `termfence`, `hostactors/awsmembership`; `host/relocat*.go`, `joining.go`/`joinroot.go`/`joinmode.go`, `boxrecord.go:26`, the region HA read at `edgesfile.go:984`, `edgesclaims.go`; console `hostclaimexecutor.go`, the region HA branches of `nocapacity.go`/`boxselect.go`, `regioncapacity.go`, `enrollpass.go`, `apiboxroles.go`; `system join` and `install-channel`; `carlos-system-join.{service,path}`; the hostenv `CARLOS_REGION_HA` key | `cmd/console/main.go:413,1789`; `edge/homemap.go:172,370`, `edge/lbhealth.go:22`; `system apply` unit set (it must also remove or disable the installed join units on boxes); infra modules if they reference the join units | Edge dials the EIP (`privateDial` false); LB health returns early; boxes do not join; console placement as today | edge homemap and lbhealth tests with the flag off; console nocapacity and placement tests; `systemunits` tests | **EDGE**, console, root units | |
| +| R4a | **C: moves Phase 1** | moves Phase 1 files (§2.2); host Phase 1 files; console `movesrecovery.go`, the Phase 1 half of `handleAPIInstanceMoveRequest`, the resolve routes (`authcli.go:739`), `PublishMovesConsole`; CLI `declareLost`; `hostresolve`, `boxchoice`; `lease/claimgeneration.go`, `versioned.go`, `staging.go` (unless db push keeps them, §6) | `movespass.go` (`armPhase1` and the round dispatch at `:1154-1195`); `moves.Enabled` collapses to false (`moves/switch.go`), including `offlineCapable` (`movesoffline.go:59-63`) and the offline door's `MovesEnabled` refusal (`apiinstancemove_offline.go:98`) | Offline and legacy moves; the `movesPass` dispatch order (offline first, then legacy) | offline move tests (`movesoffline_*_test.go`, the console offline door tests, `moves_offline*_census_test.go`); legacy move tests (`TestAPIInstanceChannelLegacyMoveLands` …) | box movesPass (shared with the live offline round), console move doors | |
| +| R4b | **C: moves protocol floor** | `host/movesfloor*.go`, `rootmovesfloor*.go`, `armFloor`, `hostfloor`, the moves-floor half of the `floor-allows-prev` unit branch | `edgesfile.go:980`, `systemapply.go:416`, the console update and rollback doors (`hostactivation.go:31,209`), both system units | **Precondition:** confirm `control/moves-protocol.json` was never published and no box has `/data/.moves/floor.*`. Keep the seeds-floor branch. | systemapply tests, seeds floor tests, unit template tests | root units, console update doors | |
| +| R5 | **C: nearest region (Plan 15)** | the `CONSOLE_APP_REGIONS` branches: `regionpicker.go`, `apicli.go:558,577`, `regionclaim.go:106`, `server.go:4543`, `regionconfig.go` | `cmd/console/main.go:417,1494` | Every region door answers as with the switch off. The `homeRegionIn` callers (A) stay. | console region tests with the switch off | console | |
| +| R6 | **B: console claim runtime** | console `claim_*.go`, `apihostclaim.go`, `apidbclaim.go`, `hostclaim*.go`, `hostwakereset*.go`, `OpenGated`; the claim half of `store_gate.go`; `hostreports.go`; the hostactors halves of `hostactivation.go`; `internal/mail` claim_gate; packages `hostops`, `hostfence`, `hostactors`, `historyreadback`, `hostevidence`, `hostquarantine`; CLI `hostclaim_cli.go`, `proof_cli.go`/`history_cli.go`, the branches in `accounts_record_sequence.go` | `cmd/console/main.go:339,373,436,522,715`; `NewServer` branches (`server.go:1391,1394,1526,1698,1707`); `authcli.go:509,1036` | Console startup; every SQL call takes the ungated store; mail writes take the original body; no claim workers run | `TestClaimSQLFlagOffStoreIsUngated`, `TestClaimRuntimeFlagOffDoesNotNeedProviders`, `TestClaimMailGateFlagOffWritesNothing`, `TestClaimLossPagesFlagOff` (moved out first); console e2e | **CONSOLE** (startup, every door through the store) | |
| +| R7a | **B: activator claim wake** | activator `claim*.go`, `rolelaunch*.go`, the claim halves of `servingretry.go`, `probewake.go`, `recoveryprobe.go`, `swap.go:231-237` | `activator.go:2115`, `backend_exec.go:456,1486,3180`, `swapadmit.go:44`, `seedwiring.go:150` | Cold wake, swap and seed fallback exactly as today | the activator's `TestAFlagOff*`, `wakecheck_test.go`, `TestClaimsOffGate*`, `TestClaimSpawnDisabledKeepsLegacyBuild` | **WAKE PATH** | |
| +| R7b | **B: box agent claim wiring** | host `claim*` (except the A slices), `guard*`, `edgesclaims.go`, `hostfencepass.go`; packages `hostbox`, `hostguard`, `genselect`, the rest of `park`, `hostclaim` | `agent.go:241-347,616,805,1108,1122`, `claimwiring.go`, `movespass.go:345-353`, `registry/timers.go`, `appconfig/renderheld.go`, `release/materializeheld.go:606`, `schedule` | Agent startup and passes; timers take the legacy path | `TestAgentNoCensusShutdownBudget`, registry `TestClaimReviewFlagOff*`, seed tests | agent startup (shares the process with the wake path) | |
| +| R7c | **B: root instance-control claim routes** | instancectl `claim*.go` (except the renamed path helper), `ClaimStop`, held-release; `claimstop*.go` in host | `claimstop_run.go:22-37,114-118`; `server.go:308-321,1066` | `RunWithRegistry(nil, nil)`; `registerProductionLaunchVerifier` must still not fail startup (or must go together with R8) | instancectl legacy tests, `legacy_claim_cleanup_rev3_test.go` | root service that nested wakes depend on | |
| +| R7d | **B: guard-exec in the units** | the `guard-exec` branch of `carlos-system-update.service` and `carlos-system-recover.service`; the `files`, `guard-arm`, `guard-exec` and `journal-migrate` verbs; `hostexec` | `system.go`, the unit templates | **Precondition:** confirm no box has `census.json` or `/opt/carlos/system/guard/{carlos,moves}`. Otherwise `system apply` and `carlos.prev` as today. | unit template tests, systemapply tests | root units (self-update) | |
| +| R8 | **B: root census plumbing** | `rootparticipation`; host `root{execution,generation*,inventory*,migration*,floor*,history*,recovery*,record_claim}*`; release `roothistory*`, `rootgeneration*`, `rootrestart_history.go`, `rootbake.go`, `releaseexclusion.go`; rollout `rootfailures.go`; caps `rootauthority.go`; layout `census.go` | the ~15 probe sites in §2.3 collapse to their legacy arm; `agent.go:4874-4886` | Every restart, rollback, start and reset-failed effect is the legacy one. D3 health, the previous pointer and `EnsurePublicDir` stay. **Behaviour change:** a bad-owned `/var/lib/carlos-claims` no longer kills the adopt pass. | `plan14_release_lock_test.go`, `rootadoption_options_test.go`, `proofroot_test.go`, `legacyrestart` tests, caps tests | adopt pass (every restart), cold-wake proof gate (adjacent) | |
| +| R9 | **the switch** | `hostwrite`; the `CARLOS_HOST_CLAIM*` keys in `hostenv/hostenv.go:41-42,82,123-124`; `cmd/console/main.go:1685` | the remaining `hostwrite.Enabled` call sites | Decide and test what a box or console with `CARLOS_HOST_CLAIM` set does: refuse to start, or ignore it. Today it changes behaviour. | hostenv tests, console boot tests | everything, trivially | |
| + |
| +**Census cost per branch.** R1-R9 together retire about 1,517 census rows and 188 frozen declarations (§5). Without R0, each branch needs hand-written `@remove`/`@removed` rows, an owner decision, and a test-code change for every deleted directory. |
| + |
| +## 5. The census gate |
| + |
| +### What `TestPlan14RootReadCensus` scans and fails on |
| + |
| +`internal/provision/plan14_root_reads_test.go:587`. |
| + |
| +**Scope: the whole repository, not just root-run code.** `rootReadProduction` (`:161`) walks every directory except `.`/`_`-prefixed ones and `testdata` (`:185-189`): |
| + |
| +- Every non-test `.go` file is parsed. Each top-level declaration (func, method, type, var/const group) becomes a *unit*. A unit is a census entry if it contains any of: |
| + - a selector or identifier named after an I/O primitive in the `rootReadIO` list (`:37`): `Open`, `ReadFile`, `Stat`, `Query`, `Command`, `Exec` and so on. This matches by name, so any `x.Open` counts. |
| + - a typed use of an `internal/registry` struct field, or of a whole registry struct (`rootReadTyped`, `:43`; typed with `go list -deps -export` for GOOS=linux); |
| + - a string literal containing `/data`, `CARLOS_DATA` or `DATA_DIR` (`:308`). |
| + Each entry records `kinds`, meaning every site with its byte offset, plus the sha256 of the declaration. **Every** declaration's sha256 also goes into `Declarations`. |
| +- Every `.sh`, `.service`, `.path`, `.socket`, `.timer`, `.conf`, `.tf`, `.tftpl`, `.tmpl`, `go.mod` and `go.sum` is one `external` unit holding its whole-file digest (`:191-201`, `:324-333`). |
| +- **Source envelopes** (`@coverage`): one sha256 per directory over every file's name and digest (`:279`, `:336`). Any edit to any file in a covered directory fails, even one that reads nothing. There are 139 envelopes. |
| +- The registry schema: the sorted field names of every struct in `internal/registry` (`@fields`). |
| + |
| +It fails (`compareRootReads`, `:547`; `checkRootReadDeclarations`, `:1651`; `checkRootReadLegacy`, `:533`) on: |
| +- an unclassified unit, or a unit whose kinds or digest changed; |
| +- a stale row, i.e. a classified unit that no longer exists, unless it is non-legacy with no kinds and an unchanged declaration; |
| +- a changed, stale or new envelope; a changed registry schema; |
| +- a frozen (`@legacy`) declaration that is gone or changed without an explicit `@removed` (owner in A..G, or `H3;census-ruling-*`); |
| +- a change to the legacy seal: the sha256 over all `@legacy` fingerprints must equal the seal the chain expects at each step. |
| + |
| +### Overlays, chain and seal |
| + |
| +- **Base:** `testdata/plan14-root-reads.tsv`, 4,244 lines: 1,775 `@legacy`, 120 `@coverage`, 1 `@fields`, and the rest classified rows. Row shape: `file unit class task basis kinds sha256`. Class is one of `authority|hint|diagnostic|legacy`. Task is a family list. |
| +- **Overlays** are deltas applied in a fixed order. The first 77 are hard-coded in `rootReadChainBefore` (`:623-1489`), each followed by an inline `seal = "…"`. The other 40 come from `testdata/plan14-root-reads-chain.tsv`, one `<file>\t<seal>` per line, which `make census-propose` appends to (`rootReadManifest`, `:1782`). That makes 117 overlays, and every `plan14-root-reads-*.tsv` in testdata is loaded. Directives are: a plain row (add or replace), `@remove file unit` (delete a row), `@removed file unit owner basis` (retire a frozen declaration), `@legacy fp row` (freeze a declaration), `@coverage dir hash`, and `@fields`. |
| +- **Seal:** after each overlay, `checkRootReadLegacy` recomputes the sha256 of the sorted set of `@legacy` fingerprints and compares it with the hard-coded or manifest seal. So adding any frozen declaration needs a new seal, and the chain is append-only: an overlay cannot be edited without breaking every seal after it. |
| +- **The effective inventory today** (computed by replaying the chain): 4,092 rows (1,792 authority, 43 hint, 76 diagnostic, 2,181 legacy), 2,242 frozen declarations, 93 `@removed`. |
| +- **The tooling cannot express a deletion.** `make census-propose` refuses `removed`, `new`, `reads` and `other` changes as decisions (`census_propose_test.go:255-262`), so every deleted unit needs hand-written `@remove`/`@removed` rows and an owner ruling on #280. Also, **no directive deletes an envelope.** `@coverage` only sets a value (`:478-484`), and `compareRootReads` reports `stale root source envelope` for any envelope whose directory has gone (`:575-579`). So **deleting a whole package directory cannot pass the census without a change to the test code.** That is why R0 comes first. |
| + |
| +### What J4 (`TestPlan14RootInputInventoryCoverage`) scans and fails on |
| + |
| +`internal/provision/plan14_input_inventory_test.go:448`. |
| + |
| +- **Its inventory differs from the census.** `inputInventory` (`:73`) loads only the 27 overlays named as string literals in `plan14_p3_census_test.go:8`, from the base up to `activation-tools`. Later overlays (`roster-binding`, `claim-*`, `region-ha-2b`, …) are not in J4's view. |
| +- **Call graph:** `inputCallers` (`:132`) loads `./...` with `golang.org/x/tools/go/packages` for linux, darwin and windows, and builds a conservative reference graph: identifier uses, interface dispatch to every implementing method, and `json.Unmarshal` to `UnmarshalJSON`. It then walks that graph from `main.go:main` and `cmd/console/main.go:main` (`:303`). |
| +- **Per row** (`checkInputRow`, `:422`): only `authority` rows that are "activation-enabled" are checked. `inputActivationEnabled` (`:401`) excludes `internal/hostrelocate/`, `internal/hostclaim/relocat*`, `internal/host/relocation*` and `internal/activator/worker*`, and rows whose only tasks are E4/J1-J4. Each checked row fails if |
| + - it has no production caller reachable from either entry point, and no exemption; or |
| + - any witness test named in its family slots (`inputFamilies`, `:28-41`: five test names each for A, B, B2, B3, B4, C, D, E1, E2, E3, F, G) does not exist anywhere in the tree as a `func TestX(t)`. |
| +- **Exemptions** (`inputExemptions`, `:347`): 16 named units. Each fails if its authority row is gone, or if it gains a production caller. |
| +- Everything else is logged and written to a report TSV (`PLAN14_J4_REPORT`), but does not fail (the 2026-10-16 narrowing, `docs/superpowers/plans/2026-10-16-claim-activation-scope.md`, "Census and J4"). |
| +- **What this means for removal:** deleting claim code can **break J4 in two ways that have nothing to do with root reads.** |
| + - (a) A surviving authority row whose only path from `main` ran through deleted claim code loses its caller. |
| + - (b) Deleting a claim test file deletes a family witness, and any surviving row of that family then fails. The witnesses live in: |
| + - `internal/rootstate/state_linux_test.go` (A) |
| + - `internal/release/plan14_healthy_test.go` (B) |
| + - `internal/host/proofbinding_provenance_linux_test.go` (B3) |
| + - `internal/hostguard/plan14_root_fences_test.go` (C) |
| + - `internal/host/rootmigration_rulings_root_linux_test.go` (D) |
| + - `internal/host/plan14_root_history_test.go` (E1) |
| + - `internal/host/plan14_generation_*_test.go` (E2) |
| + - `internal/host/plan14_root_failures_root_linux_test.go` (E3) |
| + - `internal/host/rootmovesfloor_root_linux_test.go` (F) |
| + - `internal/host/rootmigration_historic_linux_test.go` (G) |
| + |
| +### Families, and which rows exist only because of claims |
| + |
| +The families are named by their witness tests (`inputFamilies`). The J1-J4 tags (`root-route`, `root-input`, coverage) are not defined anywhere in this tree. Counts are per task tag over non-legacy and legacy rows, so a row tagged with several families counts in each. |
| + |
| +| Family | What it is | Claim packages | Claim files in `internal/host` | Elsewhere | Exists only because of claims? | |
| +|---|---|---|---|---|---| |
| +| A | root-owned directories (rootstate) | 28 | 3 | 8 | No: D3 and release-dir repair use it | |
| +| B, B2, B4 | healthy-proof admission (D3 health) | 3 | 8 | 24 | No: D3 is live | |
| +| B3 | proof binding provenance (named-unit binding) | 6 | 47 | 63 | Partly: the binding runs claims-off but only feeds history and diagnostics | |
| +| C | root fences and inventory | 202 | 475 | 88 | **Yes**, except the activator rows (`cleanup.go`, `seed_exclusion.go`, `maintenance.go`, tagged `B,C,D,F,J4`) and `system.go`, which are live code | |
| +| D | root execution broker (hostexec, rootparticipation) | 61 | 47 | 26 | **Yes**, except the units and activator rows that are multi-tagged | |
| +| E1 | root history (release, restart, recovery history) | 24 | 69 | 191 | Mostly: `release/roothistory*`, `rootrestart_history.go` and historyreadback are census-gated. The `console/apirestartscope.go` and `rollout/failures.go` rows are live | |
| +| E2 | generations (pins, completeness, launch records) | 49 | 228 | 119 | **Yes** (release `rootgeneration*`, `pins.go`, schedule, instancectl claim files) | |
| +| E3 | swap and rollout failures | 0 | 38 | 103 | Partly: `rollout/rootfailures.go` yes; `rollout/failures.go` and the console rows no | |
| +| E4 | caps route grant | 0 | 0 | 23 | Partly: `caps/rootauthority.go` yes; caps converge no | |
| +| F | floors (moves floor, seeds floor, system units) | 43 | 82 | 74 | Partly: moves floor yes (R4b); seeds floor and the update and recover units no | |
| +| G | root migration | 37 | 188 | 25 | **Yes** | |
| +| H3 | census diagnostic (schema-only, no-effect) | 6 | 7 | 43 | n/a | |
| + |
| +**Totals.** |
| +- The claim packages hold 546 rows (367 authority) and the claim files in `internal/host` hold 971 (924 authority). Together that is **1,517 of the 4,092 rows** and **188 of the 2,242 frozen declarations**. |
| +- Overlays written for claim work alone: 26 named `claim-*`/`claims-on-*`, plus `e` (562 rows), `p3` (499), `seed` (362), `activation-tools` (84), `roster-binding` (77), `region-ha-2a` (22) and `region-ha-2b` (23). They cannot be deleted from the chain without re-sealing everything after them. |
| + |
| +### Narrowing the census to "code root runs automatically" |
| + |
| +**What root runs.** These units run as root (no `User=` line): |
| +- `carlos-adopt` (with `--config-only`, `--stage-only` and `-restart-only` via `config-sync`, `stage` and `restart`); |
| +- `carlos-instance-control`; |
| +- `carlos-system-update` / `recover` (`system apply`, `guard-exec`, `floor-allows-prev`); |
| +- `carlos-system-join`. |
| + |
| +These do not: `carlos agent` (`carlos-edge.service`) runs as `carlos`; `db-worker` and the apps use `DynamicUser`; `instance-exec` runs as `carlos`. UNSURE: the console unit lives in infra, not here, so I could not check its user. |
| + |
| +| Option | What changes | Cost | What is lost | |
| +|---|---|---|---| |
| +| 1. Keep the scanner and add a removal path (R0) | Add an envelope-retire directive. Make `removed` reviewer-approvable when the scan proves the declaration is absent. | Small test change plus one owner ruling. Each branch still writes a large overlay, but the tool can generate it. | Nothing | |
| +| 2. Re-base on a root-reachable call graph | Seed J4's existing reference graph (`inputCallers`) from the root verb functions (`runAdopt`, `RunInstanceControl`, `runSystem` branches) instead of `main.go:main`. Census only the reachable units with I/O sites, envelopes only for directories holding a reachable unit, and externals only for root units, shell and tf. Write a new base TSV with a new seal and archive the 117-overlay chain. | High: rewrite `rootReadProduction` (about 300 lines), re-classify the reachable set once, and get an owner ruling to accept the re-base. The run cost is about J4's (three-platform type-check). | Agent-only and console-only edits leave the census. **That loses review of agent-writable inputs root reads**, unless the graph also seeds from the root readers' input paths. The interface-dispatch graph is conservative, so reach will still be wide. | |
| +| 3. A hand-kept package allowlist | Census only the listed packages (release, host root files, instancectl, caps, layout, units). | Low | Breaks "a rule stated as an absence cannot see a second door" (AGENTS.md). Any new root caller elsewhere is invisible. | |
| +| 4. Retire the census with the claims | It was built for Plan 14 (H3). Delete the test and its testdata after R8. | Lowest | The only check that every change to a root read gets a second reader. That is Paul's call. | |
| + |
| +Under options 1 or 2, all of families C, D, E2 and G, and the claim-only parts of B3, E1, E3, E4 and F, leave with R3-R8. |
| + |
| +## 6. db push (kept separate) |
| + |
| +- **It is not built in this tree.** `carlos db` has only `pull` and `query` (`db.go:63-68`). |
| +- What exists: |
| + - the claim op kind `hostclaim.KindPushing` (`hostclaim/claim.go:32,40`, "later push spec") and its case at `host/movessources.go:470`; |
| + - the move-any-app spec's F7, "`carlos db push` … the claim's `pushing` op" (`docs/superpowers/specs/2026-10-02-move-any-app-design.md:1104,6361`). |
| + So as specified, db push is a claim operation. |
| +- **What it shares with claims today:** |
| + - `hostclaim.Incarnation`, through db forward (R1 moves it, and keeps it); |
| + - `dbreads` refuses when claims are on (`host/dbreads.go:49-51`); |
| + - the exact-version store `lease/versioned.go` (`DeleteVersion`, `CopyVersion`, `PutIfAbsent`) and `staging.go`, whose only users are claims and Phase 1. R4a deletes them unless db push wants them. |
| +- A worktree named `db-push-pull` exists under `.git/worktrees`. I did not inspect it. Check it before R4a removes `versioned.go`/`staging.go` and before R7b removes `KindPushing`. |
diff --git a/docs/superpowers/notes/dev-claim-trial-undo.md b/docs/superpowers/notes/dev-claim-trial-undo.md| new file mode 100644 |
| index 000000000..ed88c5cf8 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/dev-claim-trial-undo.md |
| @@ -0,0 +1,616 @@ |
| +# Undoing the dev claim trial |
| + |
| +Status: inventory and plan only. Nothing here has been run. Every step that |
| +changes a box, the bucket, IAM or tofu needs Paul's go (amadan #404). |
| + |
| +Goal: dev (leo, sophie, dennis, the dev console) behaves like a deployment |
| +that never saw host claims, and like flagship. Flagship was never armed |
| +(section 4). |
| + |
| +Sources, all read-only: |
| + |
| +- the runbook, `origin/claim-dev-cohort1-runbook:docs/superpowers/plans/2026-10-16-claim-activation-dev-cohort1.md` |
| + ("Paused state (2026-10-19)", steps 4 to 7a, section 5, "Pre-roll emptiness check"); |
| +- main at `9b81d97b` (this worktree), code cited as `file:line`; |
| +- platform-infrastructure `origin/main` at `5cf9a0ed`, cited as `pinfra:file:line`; |
| +- the dev roll logs since the pause, latest `own/after236/release-and-dev-roll-v0.28.16.md` |
| + (2026-10-25 17:07Z to 17:41Z), and the flagship roll logs; |
| +- memory notes host-lifecycle-claim, claims-shelved-live-moves, deployment-harness, root-runner. |
| + |
| +## 0. What changed since the pause, and what the brief got wrong |
| + |
| +The trial stopped at the end of step 7 (2026-10-19). Since then dev has been |
| +rolled from v0.28.4 to v0.28.16, always armed. That left more residue than |
| +the pause note lists: |
| + |
| +- **One published identity per release.** Because a floor is published, every |
| + dev roll needed a throwaway signing session to run `publish-identity` |
| + (role `carlos-claim-signer`, made and deleted each time). The bucket now |
| + holds `control/system/router/releases/v0.28.2.json` and `v0.28.4.json` to |
| + `v0.28.16.json` (no v0.28.3). |
| +- **The roster has moved from revision 9 to 53.** Every console promote |
| + reserves in it, and the console's 5-minute report loop re-signs it |
| + (section 1, R3). At 17:38Z on 2026-10-25: rev 53, `activations []`, `holds []`. |
| +- **`carlos.prev` is no longer the 6.1a copy.** Ordinary rolls have refreshed |
| + it. Leo and sophie are at v0.28.16 with `.prev` v0.28.15. |
| +- **The guard has grown.** Leo's guard dir holds `activation.json carlos |
| + completed.json identities policy.json`, and sophie's also has |
| + `console-ready.json`. `identities/` gains a file per release. |
| +- **Sophie's console is upgraded by `install-console --upgrade`**, not by |
| + promote. A `canary/console` promote stages the build and restarts the unit, |
| + but the unit still runs the protected copy until `install-console` |
| + replaces it. `x-carlos-version` shows the promoted version either way, so |
| + the header can't tell you which build is running. |
| +- **The moves protocol floor is armed on all three boxes, dennis included.** |
| + `publish-floor` wrote `control/moves-protocol.json`, which is also the moves |
| + floor. Every agent copies it to `/data/.moves/` within the hour (R2). That |
| + is the widest live constraint, and the pause note doesn't mention it. |
| + |
| +Corrections to the brief, from the infra checkout: |
| + |
| +- **#45 merged** as `a0b3f5a5` (it added `dev/cohort1-fence-kms.tf`). **#48** |
| + (`5cf9a0ed`) removed the file again and its 0/0/3 plan was applied on |
| + 2026-10-19 at 20:26Z. Key `ef26a257` is `PendingDeletion` until |
| + **2026-10-26T20:26:18Z**, and the SSM parameter was deleted after 19 |
| + seconds. So a plan from main no longer deletes a live key. **Targeted plans |
| + are still required**, for a different reason: dev pins the platform modules |
| + at `?ref=main` and has drifted from them. A whole-root plan showed 13 adds |
| + on 2026-10-18. Since then `5698a8f5` added `host_release_key_deny`, which |
| + duplicates dev's own deny, and `606afcb9` changed the bucket module. |
| +- **#44** (`f609434b`) is the release-key read deny |
| + (`pinfra:dev/release-key-deny.tf:2-49`). It isn't claim machinery, so keep it. |
| +- **Leo's object-version grant is not in platform-infrastructure.** It is |
| + `PullDoorObjectVersions` / `DeleteObjectVersion` / `PullDoorVersionList` in |
| + `infra/modules/region-host/main.tf:182-196`, from `e1121997`. It covers the |
| + IE data bucket and serves the db pull door, not claims. Keep it. |
| +- **The traffic barrier on leo was never applied** (runbook line 3: "do NOT |
| + apply the traffic barrier until Paul's go"), and leo has served through |
| + `--resolve` ever since. Step 0 checks that sg-054aa165db842b6ba still has |
| + 80 and 443 open. |
| + |
| +## 1. Residue table |
| + |
| +"Reads on main" means a code path that runs on a claims-off box or console |
| +today. A **LIVE** row changes behaviour now. An *inert* row is read only by |
| +claims-on paths or operator-only claim verbs. |
| + |
| +### S3, `carlos-dev-640012953448` |
| + |
| +| # | Object | Created by | Reads on main with claims off | State | |
| +|---|---|---|---|---| |
| +| R1 | `control/moves-protocol.json` (`{"min":1,"min_release":"v0.28.4"}`, digest `1a6a7e50…4ab3`) and `control/moves-protocol-auth.json` (`3bbd48a8…`) | 7.2 `claims run` phase `publish-floor` (signer); `hostfloor.Publish` `internal/hostfloor/floor.go:121-130` | **Console update doors.** `reserveHostUpdate` treats the deployment as legacy only when both keys are absent (`internal/console/hostactivation.go:33-44`). With them present, every `carlos system update`, promote and rollback must find a published identity by tag (`:84-95`) and a roster bound to this floor (`:107`), must verify every active roster box's report (`:151-161`), and is reserved in the signed roster (`:193`). Rollback does the same (`:211-226`). **Armed boxes.** `guard-exec` compares the policy with the published floor on every edge, apply and recover start (`internal/host/guardexec.go:56-66`, `internal/hostfloor/remote.go:52-80`), and an armed apply needs it (`internal/host/guardtransaction.go:202-205`). **Every box.** The agent copies it to the local moves floor every hour (`internal/host/edgesfile.go:980`, `internal/host/movesfloor.go:496-505`), root's apply does the same first thing (`internal/host/systemapply.go:909-935`), and the moves T1 check reads it (`internal/host/movesreport.go:312-330`). | **LIVE** | |
| +| R2 | `control/host-actors.json`, the signed roster: leo `active` in pool `cohort1`, sophie in pool `console`, console `dev-console`, `home_region ie` (write-once), `floor_sha256` bound, leo's census key bound, `regions.ie.pools` holds `cohort1`. Rev 53 | 5.1 `initialize`, `configure`, `invite-*`, `enroll-*`; 7.2 `publish-floor` and `home`; 7.3 `bind-key` (signer). Since then, every console promote (`hostactivation.go:193`) and the console's report loop (`internal/console/hostreports.go:86-92`) | **Console:** read by every update door while R1 exists (`hostactivation.go:99-109`). The console's 5-minute loop (below, S4) reads it and calls `ReleaseActivation` with the release key on every tick, which re-signs it (`hostreports.go:86-92`). **Armed boxes:** `prepareGuard` needs the box's enrollment and a reservation in it (`guardtransaction.go:547-605`), and `beginGuard` re-reads it (`:206-223`). Other readers: §1a. | **LIVE** while R1 or S4 stand | |
| +| R3 | `control/system/router/releases/v0.28.2.json`, `v0.28.4.json` … `v0.28.16.json` | 6.1 `publish-identity`, then one signing session per dev roll | `reserveHostUpdate` (`hostactivation.go:53-95`, `:172-177`) and armed `prepareGuard` (`guardtransaction.go:585-602`) while R1 exists. `install-channel` and `join` read them only for region HA joins (`internal/host/installchannel.go:457`, `internal/host/joinroot.go:175-176`), which are dormant. | **LIVE** (each release needs one) until R1 goes; inert after | |
| +| R4 | `control/host-actor-invitations/leo-climbing.json`, `sophie-knitting.json`; `control/host-console-invitations/<sophie's instance>.json` | 5.1 `invite-box`, `invite-console` (`internal/claimactivation/runner.go:150-157`) | `guard-arm` for a box not yet in the roster (`internal/host/guardarm.go:102-109`). The console report loop's `InvitedConsole` (`hostreports.go:48-53`), only while S4 is set. | inert after S4 | |
| +| R5 | `status/consoles/dev-console.json` | The dev console, every 5 minutes (`hostreports.go:68-87`) | Claim census and `publish-floor` only (`internal/hostactors/census.go:349`). | inert, but **rewritten** every 5 min until S4 goes | |
| +| R6 | Fields in `status/boxes/{leo-climbing,sophie-knitting}.json`: `enrollment`, `floor_sha256`, `floor_guard_ready`, `activation_id`, `console_processes` | The agent's report (`internal/host/claimreport.go:14-38`), `console-report` | `reserveHostUpdate`'s `VerifyReport` (`hostactivation.go:155-161`) while R1 exists. | Drops out by itself once B1/B2 are gone: `claimReport` returns early (`claimreport.go:15-22`) | |
| +| R7 | `control/boxes/leo-climbing.json`, `sophie-knitting.json` (AWS-signed identity records) | 5.0 `carlos system box publish-record` | Enrollment (claims runner) and region HA (dormant). See §1a. | inert. **Undeletable** while the bucket policy I3 stands | |
| +| R8 | Pointer fields in `control/system/router/{stable,canary}.json`: `release_tag`, `moves_protocol`, `console_artifacts`, `activation_id`, plus history entries carrying them | `PrepareSystemPromotion` / `PublishActivation` under R1 | The guarded apply only (`guardtransaction.go:570-575`). Legacy promote writes the plain shape. | inert; replaced by the next legacy promote | |
| +| R9 | `claim-signer/<run-id>/` | Each signing session's exchange prefix | none | Each session emptied it. "claim-signer/ empty" at 17:12Z on 2026-10-25. Check only | |
| +| R10 | `root-runner/<run>/x.test` and `root-runner/<run>/phaseN/` SSM logs | `own/after236/root-runner.py:16,74,116,145` (Plan 14 and files-seed tests, from 2026-10-14) | none | inert; never cleaned | |
| +| R11 | `releases/bab/pointer-digests` (219 bytes, digests on for `bab` since 2026-10-18T10:11:25Z) | runbook 5.0a item 3 | Pointer-digest checking on every box and the console. This is release integrity, not claims | **keep** (§2) | |
| +| R12 | `control/hosts/*`, `control/hosts-backfill.json`, `apps/*/*/admission.json` | must not exist: step 8 never ran on real dev | the claim door | pre-check only | |
| +| R13 | App `claimtrial` (account `bab`): `instances.json` with `pool: cohort1`, instance record `claimtrial.dev.carlosframework.com` (pool `cohort1`), cert `control/certs/claimtrial.dev.carlosframework.com`, releases `wc4` | step 4 | Ordinary app paths. Leo serves it. The only cohort1-pool record. | live but harmless; it blocks the pool change in B9 (#309) | |
| + |
| +### Leo (`carlos-dev-ie-b`, i-046c7fe43620944bc) |
| + |
| +| # | Path | Created by | Reads on main with claims off | State | |
| +|---|---|---|---|---| |
| +| B1 | `/opt/carlos/system/guard/`: `carlos` (checker copy), `policy.json` (mode `armed`), `identities/v0.28.4.json` … `v0.28.16.json`, `activation.json`, `completed.json` | 6.2 `guard-arm` (`guardarm.go:118-156, 202`); every guarded apply (`prepareGuard` `guardtransaction.go:600-604`, `settleGuard` `:158`) | **Root's apply.** `installFloorHook` (`guardtransaction.go:515-545`) arms the floor path whenever the dir holds more than main's marker. Every apply then needs R1 and a reservation in R2 (`beginGuard` `:174-225`, `guardImage` `:34-84`), and a refused armed roll wedges its channel (runbook G4, harness Run 1). **Every exec** through B2 is verified against `identities/` at or above the floor (`guardexec.go:114`, `internal/hostfloor/report.go:20-80`). **Agent report** (`claimreport.go`). | **LIVE** | |
| +| B2 | `90-host-floor.conf` in `carlos-edge.service.d`, `carlos-system-update.service.d` and `carlos-system-recover.service.d`. The edge's adds `Requires=`/`After=carlos-system-recover.service` | 6.2 `guard-arm` (`guardarm.go:163-193`) | systemd: edge, update and recover all `ExecStart=/opt/carlos/system/guard/carlos system guard-exec …` | **LIVE** | |
| +| B3 | `/etc/carlos/host-actor.json` (enrollment) | `guard-arm` (`guardarm.go:159-161`) | `prepareGuard` (`guardtransaction.go:548`), the agent report (`claimreport.go:19`) | inert without B1 | |
| +| B4 | `/data/.hostexec/` (carlos, 2770) | `guard-arm` (`guardarm.go:111`, `internal/hostfloor/controllers_linux.go:23-60`) | `checkLegacyParticipation`: passes when absent or empty, refuses updates when non-empty (`internal/hostfloor/participation.go:25-50`). While B1 is armed the directory **must exist**: the armed path calls it with `requireDirectory` and defers the update otherwise (`internal/hostfloor/disk.go:242-256`). | inert while empty. Remove it only after step 2 | |
| +| B5 | `/data/.moves/floor.json`, `/data/.moves/floor.min-release` (`v0.28.4`) | The agent's hourly refresh and root's `armFloor`, after R1 appeared (`movesfloor.go:219`, `systemapply.go:909-935`) | **`activationRule`** (`systemapply.go:1123-1150`): no update, rollback or recovery may activate a build below v0.28.4, and while any registry row is held (offline moves hold rows) no downgrade at all. **The prev gate:** the system units let `carlos.prev` run a recovery only when the floor line is absent or matches the verdict (`internal/host/movesfloorgate.go:12-30`). **Edges file:** `moves_floor_min_release` (`movesfloor.go:507-525`). Never deleted by code, and only rises. Lowering it is a manual step on each box (`movesfloor.go:20-37`, `:175-180`). Flagship logs `no moves protocol floor is armed on this box` (flagship-roll-v0.28.9.md:618). | **LIVE** | |
| +| B6 | `/opt/carlos/carlos.prev.allowed` (the verdict) | `judgePrev` while B5 is armed | The prev gate, only while B5 exists | inert after B5 | |
| +| B7 | `/etc/carlos/fence-writer/credentials.json`, `credentials.installation.json` (root 600; access key `…VINM` for `carlos-dev-ie-b-fence-writer-root`) | 7a.2 `claims fence-credentials` | root's fence pass, claims-on (§1a) | inert, but **a live AWS credential** | |
| +| B8 | `/etc/carlos/host-evidence.key` (root 600) | 7.3 `claims evidence-key` | claims census and production only | inert, secret | |
| +| B9 | `CARLOS_POOLS=cohort1` in `/etc/carlos/host.env`, plus `host.env.bak-pool-20261018` | step 4 | provision reconcile: leo mints only cohort1-pool records, so it serves `claimtrial` and nothing pool-less (wakecheck left leo on 2026-10-18) | **LIVE**: leo isn't a normal home box, and it can't take part in an offline move (§1a) | |
| +| B10 | `/opt/carlos/system/router/channel-identity.json` | 6.1a `install-channel --policy --identity` (`installchannel.go:416, 649`) | region HA `join` only (`joinroot.go:175`) | inert | |
| +| B11 | `/root/claim-trial/` (staged policies, identities, `roster.json`, `rev`, `le`, `key-proof.json`, enrollment, `release.pub`, `fence-role-arn`) | 5.1 to 7a | none | inert | |
| +| B12 | `/opt/carlos`, `live`, `versions` and `host.env` owned by root (the session-3 chown fix, Paul's approval) | 2026-10-19 by hand. The infra branch `host-root-owned-opt` (`747f699`) is **not applied** | `OpenProtected` (guarded paths only). The platform intends root ownership (opt-ownership-report §1). | inert once B1 goes; keep (§2) | |
| + |
| +### Sophie (`carlos-dev-ie`, i-05498eada6f0afd23, the console box) |
| + |
| +Everything in B1 to B6, B10, B11 and B12 also applies to sophie: her guard |
| +dir has `console-ready.json` too, and there is no B7, B8 or B9. Sophie's own |
| +rows: |
| + |
| +| # | Path | Created by | Reads on main with claims off | State | |
| +|---|---|---|---|---| |
| +| S1 | `console.service.d/90-host-floor.conf`: `ExecStart=/opt/carlos/system/guard/carlos system guard-exec console /opt/carlos/system/console/console serve` | 6.3 `guard-arm --console` (`guardarm.go:168-184`, `internal/hostfloor/report.go:101-103`) | systemd. The console runs the protected copy (S3), not the live link that a `canary/console` promote moves (roll log 17:08:52Z: staged `v0.28.16` while the running exe was still `1e36de1a`). | **LIVE** | |
| +| S2 | `/opt/carlos/system/guard/console-ready.json` | `guard-arm --console` (`guardarm.go:197-200`) | `Disk.Running("console")` (`report.go:30-42`). `proofnamed.go:126-145` reads it, but only treats the console as guarded when the file names the live link, which it doesn't. | inert without S1 | |
| +| S3 | `/opt/carlos/system/console/console`, `console.prev` (now v0.28.16 `337387dd`, `.prev` `1e36de1a`) | 6.3 `claims install-console`, then `--upgrade` on every roll | only through S1 | inert without S1 | |
| +| S4 | `console.service.d/91-claim-runtime.conf` and `/etc/carlos/claim-console.env` (`CARLOS_CONSOLE_ID=dev-console`, `CONSOLE_HOME_REGION=ie`, `CARLOS_HOST_CLAIM=`) | 6.3 and 7.4 `claims console-config`. On 2026-10-19 at 22:53Z the env file was swapped back to the off form by hand | `cmd/console/main.go:412, 438`. With `CARLOS_CONSOLE_ID` set, `StartHostReports` runs whether claims are on or off (`internal/console/claim_workers.go:30-33`, `hostreports.go:68-92`). Every 5 minutes it writes R5, reads R2, and with the release key re-signs R2 for each activation. `CONSOLE_HOME_REGION` names the home for offline moves and the regions door (`internal/console/apiinstancemove.go:276-281, 303-311`). Flagship's console has `CONSOLE_HOME_REGION=ie` too (roll-v0.28.10.md F1, 2026-10-23), so **the home region must stay**. Only the claim lines go. | **LIVE** | |
| +| S5 | `/root/claim-trial/paused-20261019/` (saved 7.4 files) | the pause | none | inert | |
| + |
| +### Dennis (`carlos-dev-uk`, i-009d593f451cfd562, eu-west-2) |
| + |
| +Never enrolled. There is no guard on dennis (v0.28.16 log, 17:07:10Z), no |
| +`host-actor.json` and no roster row. **B5 and B6 apply** anyway: dennis's |
| +agent armed the moves floor from R1 like everyone else's. This is a |
| +consequence of the code (`movesfloor.go:20-37`); confirm it in step 0. Dennis |
| +also shares `stable` with leo, so while leo is armed a refused stable roll |
| +freezes dennis too (runbook G4). |
| + |
| +### Infra and account |
| + |
| +| # | Resource | Where | Reads | State | |
| +|---|---|---|---|---| |
| +| I1 | `module.fence_writer_ie_b`: role `carlos-dev-ie-b-fence-writer`, user `carlos-dev-ie-b-fence-writer-root` (path `/carlos/fence-writers/`), user policy `assume-own-fence-role`, role policy `create-termination-fences`. Plus **access key `…VINM`, made by hand and not in tofu** | `pinfra:dev/cohort1-fence-writer.tf:14-18` (#46, `beb346b2`). Module `infra/modules/box-fence-writer/main.tf:23-72`, which has no `force_destroy` | B7 | live credential, unused with claims off | |
| +| I2 | `box_fence_writer_role_arns = [module.fence_writer_ie_b.role_arn]` | `pinfra:dev/main.tf:62-64` | Bucket policy statement `OnlyBoxRolesWriteTerminationFences` (`infra/modules/deployment-buckets/main.tf:199-208`) | Drop it, and the module default (a "nobody" ARN, deny everyone) takes over | |
| +| I3 | `module.buckets.aws_s3_bucket_policy.deployment_box_records` (`BoxRecordsAreCreateOnly`, `BoxRecordsAreNeverDeleted`, …) | Unconditional in `infra/modules/deployment-buckets/main.tf:171-226` (since `abcc732d`). First applied on dev 2026-10-18 by the trial's targeted plan | Denies every principal deleting `control/boxes/*` and three sibling prefixes (`:192-196`) | **Keep**: it is the module's standard shape (§2) | |
| +| I4 | KMS key `ef26a257-fc1d-4fe3-ad9e-77a4b7b789f6` | Was `dev/cohort1-fence-kms.tf` (#45), removed by #48 | none | `PendingDeletion` until 2026-10-26T20:26:18Z. **Do nothing**, and don't cancel the deletion | |
| +| I5 | `carlos-claim-signer` role, profile, SG | Made and torn down by hand each session (`signing-host.md:45-76` on the runbook branch) | none | Should be absent (`NoSuchEntity` at 17:12Z on 2026-10-25). After the undo, no more sessions | |
| +| I6 | `carlos-root-runner` role and profile, SG `sg-0c328faf839a02986` | not in tofu | none | Plan 14 test rig. Optional removal once claims are gone from the code | |
| +| I7 | Harness: host i-06a1ec144aa5226fb (self-shutdown, terminate-on-shutdown, last TTL 2026-10-22T12:00Z), SG `sg-0b9cf4c2a508b7cec`, role and profile `carlos-harness`, bucket `carlos-harness-640012953448` | `platform-harness-build:harness/RESOURCES.md:8-14` | **Nothing in dev's bucket**: its role denies `s3:*` on `carlos-dev-*` (`harness/aws/role-policy.json:10-12`) | No teardown is recorded after 2026-10-21T16:23Z. Check, then `harness/TEARDOWN.md` | |
| +| I8 | Branch `host-root-owned-opt` (`747f699`, unmerged) | infra | — | Built on `a0b3f5a`, so it still carries `cohort1-fence-kms.tf`. Don't merge it as it stands | |
| + |
| +### 1a. Other roster and floor readers on main |
| + |
| +These are the remaining readers of R1, R2, B1 to B3 and S4, sorted by |
| +whether they run with claims off. |
| + |
| +**Run claims-off. These are the live constraints, besides those above:** |
| + |
| +- **The reserve check needs fresh reports.** `VerifyReport` refuses a box |
| + report older than 15 minutes, or one without `floor_guard_ready` and the |
| + floor digest (`internal/hostactors/census.go:66-68`). A stalled agent on |
| + leo or sophie therefore blocks **every** dev router promote and rollback, |
| + dennis's included. |
| +- **The console report worker is gated only on `CARLOS_CONSOLE_ID`.** It is |
| + registered without a claims gate (`internal/console/claim_workers.go:30-33`, |
| + `cmd/console/main.go:579`). Every 5 minutes it writes R5. With the release |
| + key loaded, which sophie has through `release-key.conf`, it calls |
| + `ReleaseActivation` for every activation, and that **writes R2** |
| + (`hostreports.go:86-92`, `internal/hostactors/activation_complete.go:56`). |
| + This is how the roster went from rev 49 to 53 during the v0.28.16 roll. |
| +- **Root's generation census accepts the edge's guard-exec `ExecStart`** |
| + only while `guard/carlos` is readable (`internal/host/rootgeneration_services_linux.go:226-231`). |
| + A drop-in left behind with the guard binary gone is refused there as well |
| + as by systemd. |
| +- **Box and group role verbs (`carlos system box role`, `group role`)** read |
| + and **write** R2 (`internal/console/apiboxroles.go:57-60`; `SetBoxRole` |
| + and `SetGroupRole` call `Replace`). They are gated on `CARLOS_REGION_HA`, |
| + not on claims (`apiboxroles.go:89`), and dev runs without it. With R2 |
| + gone they answer 503, as on flagship. |
| +- **`CARLOS_POOLS=cohort1` (B9)** makes leo's edges file say |
| + `serves_shared_pool=false`. That keeps leo out of region candidates |
| + (`internal/console/regioncandidates.go:63-75`) and out of the offline move |
| + door's box choice (`internal/console/apiinstancemove_offline.go:332, 413`). |
| + Today leo can be neither a target nor a source of an offline move. |
| +- **`carlos proof history`** (`history_cli.go:30`) needs R2. It is run by an |
| + operator and never automatically. |
| + |
| +**Gated off claims-off, so nothing changes when the residue goes:** |
| + |
| +- `internal/console/claim_runtime.go:24-60`; |
| +- `hostclaimbackfill.go:25-52`; |
| +- `apihostclaim.go:28-44` and `hostresolve/readmit.go` behind it; |
| +- `claim_sql_instance.go` (opened only with claims on); |
| +- `apiinstancemove.go:777, 1657` (Phase 1 live moves, `CARLOS_MOVES_PHASE1`; `boxselect.go:83` sits behind it); |
| +- `internal/host/hostfencepass.go:17-55` (so B7 is never used); |
| +- `relocatepass.go:678-680`; |
| +- `joinmode.go:300` and `joinroot.go` (region HA joins); |
| +- `claimproduction*.go`, `rootmigration_startup.go`, `claimcensus.go`, `claimparticipation.go` (claim construction only); |
| +- `internal/hostops/evidence.go`, `move_loss_grant.go`, `production_create.go` (built only in `ConfigureClaimRuntime`); |
| +- `roothistory_readback.go:39` (needs a readback request object, and there is none). |
| + |
| +`internal/hostexec/pending_linux.go` is reached without a gate from |
| +`guardtransaction.go:437`, but only when `.hostexec` is non-empty. The live |
| +offline move door (`apiinstancemove_offline.go`) reads none of R1, R2, R3 or |
| +the home binding. The only residue it sees is B9's pool flag. Nothing in |
| +provision or reconcile reads the roster's `regions.*.pools`. |
| + |
| +## 2. Reverses: supported, manual, and what breaks out of order |
| + |
| +**There is no supported reverse for any claim artefact.** The code is |
| +one-way on purpose: |
| + |
| +- `Persist` refuses to move a policy from armed back to unpublished, or to a |
| + different floor (`internal/hostfloor/disk.go:72-80`). |
| +- `install-channel` refuses an armed box (`installchannel.go:301-305`). |
| +- The claims runner's store refuses every delete (`internal/claimactivation/runner.go:349`). |
| +- `console-config` refuses to go from on to off (runbook, "Paused state"). |
| +- The local moves floor only rises (`movesfloor.go:175-180`). |
| +- `cancel-activation` releases only a reservation that was never published |
| + (`hostactivation.go:248-345`). |
| + |
| +What the code does define is the **legacy shape**, and every manual reverse |
| +below aims at it: |
| + |
| +- no guard dir, or one holding only main's marker → unarmed (`guardtransaction.go:515-537`); |
| +- no `.hostexec`, or an empty one → idle (`participation.go:25-40`); |
| +- no `/data/.moves/floor.json` → "no moves protocol floor is armed on this box" (`systemapply.go:1127-1133`); |
| +- both floor keys absent → no reservation (`hostactivation.go:34-44`); |
| +- no `host-actor.json` → no claim fields in the report (`claimreport.go:19-22`); |
| +- no `CARLOS_CONSOLE_ID` → no console report loop (`hostreports.go:70`). |
| + |
| +Hand edits therefore leave root state the code already accepts as "never |
| +armed". **No code change is needed before the undo** (§3, "Code"). |
| + |
| +| Item | Minimal safe manual reverse | Wrong order, and what breaks | |
| +|---|---|---| |
| +| S1 (console guard) | Before anything else on sophie: check that `/opt/carlos/live/platform.dev.carlosframework.com` resolves to a build with the same sha256 as the protected console. Move `90-host-floor.conf` aside, `daemon-reload`, restart `console.service`. It then runs the live link, as flagship's does. | **Remove sophie's guard dir (B1) first:** `ExecStart` points at a missing `/opt/carlos/system/guard/carlos`, and the dev console fails with exit 203 at its next start. **Remove S3 first:** the same failure. **Live link on another build:** the console silently changes build at the restart. | |
| +| S4 (claim runtime) | First add a console-only drop-in with `Environment=CONSOLE_HOME_REGION=ie`. Then move `91-claim-runtime.conf` and `claim-console.env` aside, `daemon-reload`, restart (the same restart as S1). | **Drop the home region:** offline moves and the regions door lose the home name, and the console stops matching flagship. **Remove the env file but not the drop-in:** `EnvironmentFile=` without `-` fails the unit start. | |
| +| B2 (unit drop-ins) | Under the apply lock (`flock -n /opt/carlos/system/router/lock`), with `carlos-system-update.path` stopped: move the three `90-host-floor.conf` aside, `daemon-reload`, check `ExecStart` is the plain unit's. Don't restart: the running edge was exec'd from `/opt/carlos/carlos` and stays the same process. | **Move B1 first:** the next edge, update or recover start exits 203. The edge `Requires=` the recover unit, so a reboot leaves the box dark. | |
| +| B1, B3 (guard, enrollment) | After B2, under the same lock: move `/opt/carlos/system/guard` and `/etc/carlos/host-actor.json` aside to `/root/claim-undo-<date>/` (root 700, **not** under `/opt/carlos/system/`). Preconditions: no `system/router/journal.json`, no `update-begun.json*`, `completed.json` equals `activation.json`'s id, and the roster's `activations` and `holds` are empty. | **With an unsettled transaction:** the box loses its half of a reservation, and the console holds that channel (`activationHeldError`, `hostactivation.go:123-129`) until R1 goes. **While R1 and R2 remain:** the console refuses every router promote and rollback, because the disarmed box's report no longer verifies (`hostactivation.go:155-161`). That fails closed and wedges nothing. Hold the freeze until step 5. | |
| +| R1 (floor) | After **both** boxes are disarmed: delete both keys in one `s3api delete-objects` call. The bucket is versioned, so the old versions stay as the rollback. | **Before disarming:** armed boxes refuse every update (`beginGuard`, `guardtransaction.go:202-205`). Serving is fine, because `guard-exec` accepts "neither key" for an armed policy (`remote.go:57-63`). **One key only:** the console refuses every router update (`hostactivation.go:38-41`), and on any still-armed box `guard-exec` refuses to start edge, apply and recover (`remote.go:57-79`). That is an outage at the next restart. | |
| +| B5 (local moves floor) | After R1 is gone: on each of leo, sophie and dennis, holding `/data/.moves/floor.lock`, move `floor.json` and `floor.min-release` aside. Leave `.moves/` and the lock file. | **Before R1 goes:** the agent's hourly refresh, or the next apply, writes them back (`movesfloor.go:496-505`, `systemapply.go:921`). | |
| +| B6 | Leave it. It is read only beside a floor line. Optionally move it aside after B5. | none | |
| +| R2, R4, R5 (roster, invitations, console report) | After R1 and S4: delete them by exact key. Pre-check: `activations` and `holds` are empty. | **R2 before R1:** every promote is refused (`hostactivation.go:100-103`, `d.Read` returns not-exist). **R5 before S4:** the console rewrites it within 5 minutes. **R2 before S4:** the console logs a report error every 5 minutes. | |
| +| R3 (identities) | Optional, last: delete by exact key. | **Before R1 goes:** promotes of those releases are refused. | |
| +| R7 (box records) | Keep. Deleting them needs I3 changed first, and I3 is the module standard. Nothing claims-off reads them. | — | |
| +| R8 | Nothing to do. The next legacy promote rewrites the pointer. | — | |
| +| R10 (root-runner objects) | Optional: list them, then delete by exact key. | none | |
| +| R11 (pointer digests) | **Keep.** It is release integrity, not a claim. Turning it off is a separate decision, and flagship parity is unknown: run `carlos channels digests --account-id bab` against flagship read-only. | — | |
| +| R13, B9 (claimtrial, leo's pool) | Delete the `claimtrial` instance through the console, and wait for leo's route to retire. Then remove `CARLOS_POOLS=cohort1` from leo's `host.env` and restart the edge. Then trash the app. | **Pool first:** the cohort1 row falls out of leo's scope and is never retired, an orphan route (#309, runbook step 4.3). **Trash first:** the dev trap, where routes survive a trashed app (memory: dev-console-unit). | |
| +| B7, I1 (fence credentials) | `iam delete-access-key` for `…VINM`, then `shred -u` both files on leo, then the targeted tofu destroy of I1 together with I2. | **tofu before the key:** `DeleteConflict` on the user, because the module has no `force_destroy`. **Files before the key:** harmless, but the key stays live. | |
| +| B8, B10, B11, S2, S3, S5, B4 | After the steps above: `shred -u` the evidence key, remove the rest by exact path. `rmdir` `.hostexec` only if it is empty. | **S3 before S1:** console exit 203. | |
| +| B12 (root-owned `/opt/carlos`) | **Keep.** It is the platform's intended layout, and nothing claims-off depends on either owner. Flagship is `carlos:carlos` from infra's `host-init.sh`, so the boxes differ on this one point. Changing it back is Paul's call. Changing flagship's is the unmerged infra branch, which restarts every box. | — | |
| +| I3 | **Keep.** | — | |
| +| I4 | Nothing to do. It finishes deleting on 2026-10-26 at 20:26Z. | Cancelling the deletion brings the trial key back. | |
| + |
| +## 3. The undo, in order |
| + |
| +Rules for every step: |
| + |
| +- One step at a time, each on Paul's go. |
| +- Read-only pre-check, then the action, then the post-check. A failed check is a STOP: change nothing more and report on #404. |
| +- Box commands run as root over SSM from DOCS-T1 (profile `kass`), with the runbook's `ssm.sh`. Dennis is eu-west-2. |
| +- "Aside" means `/root/claim-undo-20261026/<step>/`, root 700, made with `install -d -m 0700`. Every move there is `mv -T` of one exact path. No globs, no `rm -r` on patterns. |
| +- **Freeze, from step 1 until step 8:** no `carlos system update`, `rollback` or `cancel-activation`, no `canary/console` promote, no `install-console`, no other session's dev roll. Tell other sessions on #404. |
| + |
| +Kinds: **[SSM]** touches a box over SSM. **[S3]** writes the bucket. **[IAM]** |
| +is a hand change in IAM. **[INFRA]** is targeted tofu. **[CONSOLE]** is a |
| +console API call. **[READ]** is read-only. |
| + |
| +### Step 0 [READ]: inventory and the claim emptiness check |
| + |
| +Pre-check and action are the same thing here. Reuse the runbook's "Pre-roll |
| +emptiness check" blocks 1 and 2 unchanged. Expected: `leo: all empty` and |
| +`bucket and roster: all empty`. Then add: |
| + |
| +- Bucket: |
| + - `aws s3 ls` on `control/hosts/`, `control/hosts-backfill.json`, `control/host-actor-invitations/`, `control/host-console-invitations/`, `control/system/router/releases/`, `status/consoles/`, `claim-signer/` and `root-runner/`, plus a recursive `admission.json` search under `apps/`; |
| + - `rosterview` (rev, `activations`, `holds`, `regions.ie.pools`); |
| + - the sha256 of both floor keys; |
| + - the version IDs of R1 and R2, recorded for rollback. |
| +- Each box: |
| + - `ls -la /opt/carlos/system/guard /opt/carlos/system/guard/identities`; |
| + - `cat completed.json`, and the `id` from `activation.json`; |
| + - `test ! -e /opt/carlos/system/router/journal.json`; |
| + - no `update-begun.json*`; |
| + - `test ! -e /opt/carlos/system/guard/moves` (no root moves floor); |
| + - `test ! -e /var/lib/carlos-claims`; |
| + - `ls -A /data/.hostexec`; |
| + - `cat /data/.moves/floor.json /data/.moves/floor.min-release`; |
| + - `systemctl cat carlos-edge carlos-system-update carlos-system-recover | grep -E 'ExecStart|Requires'`. |
| +- Sophie also: |
| + - `systemctl cat console.service`, to read the plain `ExecStart` (the opt-ownership report says `/opt/carlos/live/platform.dev.carlosframework.com`); |
| + - the sha256 of `readlink -f` of that link against `/opt/carlos/system/console/console`; |
| + - the environ of the running console. |
| +- IAM: |
| + - `list-access-keys` for `carlos-dev-ie-b-fence-writer-root`; |
| + - `get-role carlos-claim-signer` (expect `NoSuchEntity`). |
| +- SG: sg-054aa165db842b6ba has 80 and 443 from 0.0.0.0/0. |
| + |
| +Post-check: none. Any non-empty claim item (control/hosts, backfill, |
| +admission, /var/lib/carlos-claims, guard/moves, a non-empty .hostexec, roster |
| +activations or holds) is a STOP: real claim state exists, and this plan |
| +doesn't cover it. |
| + |
| +Rollback: none. |
| + |
| +### Step 1 [SSM sophie]: the dev console back to the plain unit |
| + |
| +Pre-check: |
| + |
| +- step 0 is clean; |
| +- the live link's target sha256 equals the protected console's (both `337387dd…` at v0.28.16); |
| +- `console.service` is active; |
| +- no `.next` in `/opt/carlos/system/console`. |
| + |
| +Action: |
| + |
| +1. Write `/etc/systemd/system/console.service.d/home-region.conf` (root 644): `[Service]` then `Environment=CONSOLE_HOME_REGION=ie`. |
| +2. Move `90-host-floor.conf`, `91-claim-runtime.conf` and `/etc/carlos/claim-console.env` aside. |
| +3. `systemctl daemon-reload`, then `systemctl restart console.service`. |
| + |
| +This is a few seconds of dev console downtime, like a roll. |
| + |
| +Post-check: |
| + |
| +- `console.service` is active, and `readlink /proc/$PID/exe` is `/opt/carlos/versions/<v>/console`, not `system/console/console`; |
| +- the exe sha256 is unchanged; |
| +- the environ has `CONSOLE_HOME_REGION=ie` and no `CARLOS_CONSOLE_ID` or `CARLOS_HOST_CLAIM`; |
| +- `/healthz` is 200; |
| +- the runbook's P9 check still passes; |
| +- after 6 minutes, `status/consoles/dev-console.json` has not changed (R5) and the roster revision has not moved; |
| +- `carlos move offline status` still answers for a dev host. |
| + |
| +Rollback: move the three files back, remove `home-region.conf`, |
| +`daemon-reload`, restart. The protected copy is untouched. |
| + |
| +### Step 2 [SSM leo]: disarm leo |
| + |
| +Pre-check, again just before acting: |
| + |
| +- no `journal.json`; |
| +- no `update-begun.json*`; |
| +- `completed.json` equals `activation.json`'s id; |
| +- `.hostexec` is empty; |
| +- `rosterview` shows `activations []` and `holds []`; |
| +- the edge is active, and its PID is noted. |
| + |
| +Action, as one root shell: |
| + |
| +1. `systemctl stop carlos-system-update.path`. |
| +2. `flock -n /opt/carlos/system/router/lock` around steps 3 to 6. |
| +3. Move aside `/etc/systemd/system/{carlos-edge,carlos-system-update,carlos-system-recover}.service.d/90-host-floor.conf`, one exact path each. |
| +4. `systemctl daemon-reload`. |
| +5. Check `systemctl show -p ExecStart` for each of the three units: no `guard-exec`. Check the edge shows no `Requires=carlos-system-recover`. |
| +6. `mv -T /opt/carlos/system/guard <aside>/guard` and `mv -T /etc/carlos/host-actor.json <aside>/host-actor.json`. |
| +7. Release the lock, then `systemctl start carlos-system-update.path`. |
| + |
| +Post-check: |
| + |
| +- the edge has the same PID and is active; |
| +- `test ! -e /opt/carlos/system/guard`; |
| +- the next `status/boxes/leo-climbing.json` (within about 6 minutes) has no `floor_guard_ready` or `enrollment`; |
| +- wakecheck and claimtrial answer 200 through `--resolve` to leo. |
| + |
| +Rollback, in reverse order: |
| + |
| +1. Move the guard dir and `host-actor.json` back first. |
| +2. Then the three drop-ins. |
| +3. `daemon-reload`. |
| + |
| +Never put the drop-ins back before the guard dir. |
| + |
| +### Step 3 [SSM sophie]: disarm sophie |
| + |
| +As step 2, on sophie. Step 1 must have passed: `console.service` no longer |
| +execs through the guard. Add `console-ready.json` to the pre-check listing. |
| +It moves with the guard dir. |
| + |
| +Between steps 2 and 5 the console refuses router promotes and rollbacks |
| +(R1 and R2 are still published and the boxes' reports no longer verify). |
| +That is expected, and the freeze covers it. |
| + |
| +### Step 4 [S3]: remove the floor |
| + |
| +Pre-check: |
| + |
| +- neither leo nor sophie has `/opt/carlos/system/guard`; |
| +- `rosterview` shows `activations []`; |
| +- dennis has no guard; |
| +- both keys are present with the hashes from step 0. |
| + |
| +Action: `aws s3api delete-objects` for exactly `control/moves-protocol.json` |
| +and `control/moves-protocol-auth.json` in one request. |
| + |
| +Post-check: |
| + |
| +- `head-object` returns 404 for both; |
| +- `carlos system status --console https://platform.dev.carlosframework.com` answers; |
| +- the console log has no `hostfloor` refusal. |
| + |
| +Rollback: restore the step-0 version IDs. Copy each prior version over its |
| +key, auth key first, then the floor (the order `Publish` uses). This only |
| +helps if steps 2 and 3 are rolled back too, because otherwise the restored |
| +floor wedges promotes again. |
| + |
| +### Step 5 [SSM leo, sophie, dennis]: remove the local moves floor |
| + |
| +Pre-check: |
| + |
| +- step 4 is done (404 on both keys); |
| +- on each box, `/data/.moves/floor.json` holds `v0.28.4` (or is absent on a box that never armed it); |
| +- no offline move is in flight (`carlos move offline status` for every dev host). |
| + |
| +Action, on each box: |
| + |
| +1. `flock /data/.moves/floor.lock`. |
| +2. Move `floor.json` and `floor.min-release` aside. |
| +3. Optionally move `/opt/carlos/carlos.prev.allowed` aside too. |
| + |
| +Post-check: |
| + |
| +- both files are absent; |
| +- after the agent's next hourly refresh they are still absent, which proves R1 is gone; |
| +- the edges file shows no `moves_floor_min_release`. |
| + |
| +Rollback: move them back. |
| + |
| +### Step 6 [S3]: remove the roster, invitations and console report |
| + |
| +Pre-check: |
| + |
| +- step 1 is done and R5 hasn't changed since; |
| +- step 4 is done; |
| +- `rosterview` shows `activations []` and `holds []`; |
| +- no box has `host-actor.json`. |
| + |
| +Action: delete `control/host-actors.json`, the two |
| +`control/host-actor-invitations/*.json`, the one |
| +`control/host-console-invitations/*.json` and |
| +`status/consoles/dev-console.json`. Each is one exact key, named from step 0. |
| + |
| +Post-check: |
| + |
| +- all of them return 404; |
| +- the console logs nothing about the roster; |
| +- `carlos system status` is fine. |
| + |
| +Rollback: restore the prior versions. |
| + |
| +### Step 7 [CONSOLE, then SSM leo]: claimtrial and leo's pool |
| + |
| +Pre-check: claimtrial is the only record with pool `cohort1` |
| +(`aws s3 ls` on the instance records, read the pool). |
| + |
| +Action: |
| + |
| +1. `carlos instances delete` the host through the dev console. |
| +2. Wait for leo's route to retire: `registry.db` has no `claimtrial` row. |
| +3. On leo, copy `host.env` to `host.env.bak-undo-<date>`. |
| +4. Remove the `CARLOS_POOLS=cohort1` line by exact match. |
| +5. `systemctl restart carlos-edge.service`. This is also the first start through the plain unit. |
| +6. `carlos apps trash claimtrial`. |
| +7. Optionally move `host.env.bak-pool-20261018` aside. |
| + |
| +Post-check: |
| + |
| +- the edge is active, and the log line reads `instances loop armed … pools []`; |
| +- within 5 minutes leo mints the pool-less records again (wakecheck); |
| +- wakecheck answers 200 on both boxes. |
| + |
| +The #286 two-home-box hazard is back. That is the state before the trial. |
| + |
| +Rollback: restore `host.env` and restart the edge. A deleted instance |
| +isn't restored; it was disposable. |
| + |
| +### Step 8 [READ, then normal operation]: prove dev updates like flagship |
| + |
| +This step ends the freeze. Use the next real release, or the current one if |
| +none is due. |
| + |
| +1. `carlos system update --channel canary` (sophie), then `--channel stable` (leo, dennis). There is no signing session and no `publish-identity`. |
| +2. `carlos system rollback --channel canary`, then forward again. |
| +3. Ship and promote the console with `ship-app.sh` to `canary/console`, as on flagship. |
| + |
| +Pass: |
| + |
| +- every promote and rollback succeeds with no `activation … is held` and no `hostfloor` error; |
| +- `control/host-actors.json` stays absent, and no `releases/<tag>.json` appears; |
| +- each box's journal logs `no moves protocol floor is armed on this box` (as flagship-roll-v0.28.9.md:618); |
| +- the console's `/proc` exe changes to the promoted build with no `install-console`; |
| +- every box `current`, 0 `REFUSING`, wakecheck 200. |
| + |
| +Rollback: `carlos system rollback` works now. That is the point of the step. |
| + |
| +### Step 9 [IAM, SSM leo]: the fence-writer credential |
| + |
| +Pre-check: |
| + |
| +- the key `…VINM` is listed and `Active`; |
| +- leo's file fingerprint is `3fe9f5d9`; |
| +- `CARLOS_HOST_CLAIM` is still unset on leo. |
| + |
| +Action: |
| + |
| +1. `aws iam update-access-key --status Inactive`, then `delete-access-key` for `…VINM`. |
| +2. On leo, `shred -u /etc/carlos/fence-writer/credentials.json /etc/carlos/fence-writer/credentials.installation.json /etc/carlos/host-evidence.key`. |
| +3. `rmdir /etc/carlos/fence-writer`. |
| + |
| +Post-check: |
| + |
| +- `list-access-keys` is empty; |
| +- the three files are gone; |
| +- CloudTrail shows no `AssumeRole` on the fence-writer role since 2026-10-19. |
| + |
| +Rollback: none for the key, which is the point. A new one can be made if |
| +claims ever return. |
| + |
| +### Step 10 [INFRA, targeted]: remove the fence writer |
| + |
| +Pre-check: |
| + |
| +- step 9 is done (the user has no access keys); |
| +- on a branch from infra `origin/main` (`5cf9a0ed`), remove `dev/cohort1-fence-writer.tf` and the `box_fence_writer_role_arns` line plus its comment (`dev/main.tf:62-64`). |
| + |
| +Action: |
| + |
| +``` |
| +tofu plan -target=module.fence_writer_ie_b -target=module.buckets.aws_s3_bucket_policy.deployment_box_records -out=undo-fence.plan |
| +``` |
| + |
| +Read the whole plan. Expect 0 to add, 1 to change (the bucket policy's |
| +`OnlyBoxRolesWriteTerminationFences` ARN list becomes the module's "nobody" |
| +ARN) and 4 to destroy (the user, its policy, the role and its policy). |
| +Anything else, and any `user_data` change, is a STOP. Then apply the saved |
| +plan, and merge the PR. |
| + |
| +Post-check: |
| + |
| +- `get-role carlos-dev-ie-b-fence-writer` and `get-user …-root` return `NoSuchEntity`; |
| +- the bucket policy has four statements, and no ARN of ours in the fence statement. |
| + |
| +Rollback: revert the branch and run a targeted apply. That makes a new role |
| +and user, but no key. |
| + |
| +### Step 11 [SSM leo, sophie; S3]: inert leftovers |
| + |
| +After step 8 passes. Pre-check: steps 1 to 8 passed and a week has gone by |
| +without a problem. |
| + |
| +Action: |
| + |
| +- **On both boxes:** remove `/root/claim-trial` by exact path (and sophie's `paused-20261019` inside it). |
| +- **On sophie:** remove `/opt/carlos/system/console` (S3). Step 1 must have passed and the console must run from `versions/`. |
| +- **On both boxes:** |
| + - remove `/opt/carlos/system/router/channel-identity.json`; |
| + - `rmdir /data/.hostexec` if it is empty; |
| + - remove the aside dirs from steps 1 to 5. |
| +- **In S3:** delete the identities `control/system/router/releases/*.json` (R3) one exact key at a time, from the step-0 list. Optionally do the same for `root-runner/` (R10). |
| + |
| +Post-check: each path is absent, and `carlos system status` is fine. |
| + |
| +Rollback: none needed. Everything here is inert, and the bucket keeps |
| +versions. |
| + |
| +### Step 12 [IAM, by hand; optional, separate go]: account leftovers |
| + |
| +- **Root runner:** first check no instance is tagged `purpose=plan14-root-runner`. Then delete role and profile `carlos-root-runner` and SG `sg-0c328faf839a02986`. |
| +- **Harness:** check i-06a1ec144aa5226fb is `terminated`, then follow `harness/TEARDOWN.md` (role, profile, SG, bucket). |
| +- **Claim signer:** check `carlos-claim-signer` is absent. |
| + |
| +### Step count by kind |
| + |
| +| Kind | Steps | |
| +|---|---| |
| +| READ only | 0 (inventory); 8 is the verification | |
| +| SSM on boxes | 1 (sophie), 2 (leo), 3 (sophie), 5 (all three), 7 (leo, after a console call), 9 (leo, with IAM), 11 | |
| +| S3 writes | 4, 6, 11 (identities, optional root-runner) | |
| +| IAM by hand | 9 (access key), 12 (optional) | |
| +| Targeted tofu | 10 | |
| +| Console API | 7 (instance delete, app trash) | |
| +| Platform code change first | none | |
| + |
| +Thirteen steps (0 to 12): |
| + |
| +- seven touch boxes over SSM; |
| +- three write S3; |
| +- two change IAM by hand; |
| +- one runs targeted tofu; |
| +- one uses the console API; |
| +- one is read-only; |
| +- one is the end-to-end proof. |
| + |
| +Steps 1 to 6 are the core undo. They must run in that order, under one |
| +freeze, ideally in one sitting. |
| + |
| +**Code.** No platform change is needed first. The hand edits produce the |
| +legacy shape that main already handles as "never armed" (§2). A |
| +`guard-disarm` verb would only package steps 2 and 3, and it would be new |
| +claims code written just to be deleted with the rest. Write one only if Paul |
| +wants the order and checks enforced by the binary rather than the runbook. |
| +If he does, it needs: the apply flock, `guardArmIdle`, a settled |
| +transaction, byte-equal drop-ins, a move-aside receipt, and a root-runner |
| +witness that a hand-disarmed box applies and recovers exactly as main does. |
| + |
| +## 4. Flagship |
| + |
| +Flagship has none of this residue. The evidence, all from 2026-10-21 to 10-25: |
| + |
| +- **No guard on any flagship box.** `ls /opt/carlos/system/guard` answers "No such file or directory" on all four boxes before both the v0.28.15 and the v0.28.16 roll (`own/after236/flagship-roll-v0.28.16.md:56,93,130,167`, `flagship-roll-v0.28.15.md:56,92,128,164`). |
| +- **No floor.** |
| + - Flagship rolls with plain `carlos system update` (`flagship-roll-v0.28.16.md:252-264`) and never runs a signing session or `publish-identity`. With a floor published, `reserveHostUpdate` would refuse a release that has no identity (`hostactivation.go:84-87`). |
| + - Root's apply on flagship logs `no moves protocol floor is armed on this box` (`flagship-roll-v0.28.6.md:372`, `v0.28.7.md:471`, `v0.28.8.md:534`, `v0.28.9.md:618`), which is the `floor == nil` branch at `systemapply.go:1131`. |
| +- **The console is unguarded.** It runs `/opt/carlos/versions/<sha>/console` with no `90-host-floor.conf` or `91-claim-runtime.conf` in its drop-ins. It has `CONSOLE_HOME_REGION=ie` and no `CARLOS_CONSOLE_ID` (roll-v0.28.10.md F1, 2026-10-23). It rolls by `ship-app.sh` and promote (`flagship-roll-v0.28.16.md:604-607`). |
| +- **Never in scope.** The runbook names dev cohort 1 only. Memory (host-lifecycle-claim, 2026-10-19) says "FLAGSHIP boxes have the same layout: probe and remediate before any arming", and no arming happened. |
| + |
| +Two parity points to check read-only, because they are not claims: |
| + |
| +1. Whether flagship's bucket carries `deployment_box_records` (I3). That depends on the module tag `carloku-infrastructure` pins. |
| +2. Whether pointer digests are on for `bab` on flagship (R11). |
diff --git a/docs/superpowers/notes/offline-move-pause-trim.md b/docs/superpowers/notes/offline-move-pause-trim.md| new file mode 100644 |
| index 000000000..93139d086 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/offline-move-pause-trim.md |
| @@ -0,0 +1,244 @@ |
| +# Offline move: where the pause goes, and what to trim |
| + |
| +Read-only investigation, 2026-10-25, at origin/main 9b81d97b. Self-serve branches read with `git show`: self-serve-moves-2 (5992af09), self-serve-moves-3 (84917d06), self-serve-moves-4 (b84a8ddb); spec `docs/superpowers/specs/2026-10-21-self-serve-offline-moves-design.md` (on main since 953b9fda). |
| + |
| +**Measured** means the flagship runs of 2026-10-21 on v0.28.7 (runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md` §5 table, §6, History). **Inferred** means read from the code with no timing behind it. Everything inferred should be checked against the target's `woke` journal line (the wake's step marks: checks, lease, restore, identity, seed, spawn, settle, replicate; `internal/activator/activator.go:2267-2669`, `wakesteps.go`) and the `serial pass stages` slow line (`internal/host/changeindex.go:254-262`) before anything is built. |
| + |
| +Measured totals (client: T0 just before `start` to the first 2xx through the target): |
| + |
| +| | 1.6 GB, 305 objects | 3.7 GB, 270 objects | |
| +|---|---|---| |
| +| start | 23.0 s | 23.3 s | |
| +| seal (0 to 2 objects copied) | 28.4 s | 30.6 s | |
| +| flip | 44.2 s | 57.7 s | |
| +| gate (move.sh, two SSM reads) | ~2 s | ~3 s | |
| +| open | 7.3 s | 15.9 s | |
| +| open returned to first 2xx | 40.2 s | 57.0 s | |
| +| of which promote + restore (journal) | 29 s | 52 s | |
| +| **offline, client** | **147.6 s** | **190.4 s** | |
| +| console `offline_s` | 99.9 s | 117.2 s | |
| + |
| +## 0. The machinery every step shares |
| + |
| +Each step is a door hop, and every hop pays the same fixed costs before any real work starts: |
| + |
| +1. **CLI.** Each verb is its own `carlos` process that posts its door, then polls the status door every 2 s (`move.go:108`, `poll: 2 * time.Second`; loop `move.go:1303-1318`). `move.sh` runs the verbs one after another. |
| +2. **Console.** The door writes the record and bumps the serial (`internal/console/apiinstancemove_offline.go:742`, `:775`). The status view decides "next" by running the next door's checks (`offlineStepFor`, `:909`). |
| +3. **Box.** The serial is read every 2 s (`fastTickEvery`, `internal/host/agent.go:2246`). A full pass runs at most once per 5 s (`fastFullClamp`, `agent.go:2247`; checked at `:2775`), so a bump that lands within 5 s of the last pass waits out the rest of the 5 s. The moves pass runs **last** in the pass set, after reconcile, build states, telemetry and plans (`changeindex.go:265-292`). |
| +4. **Reports.** A box's report is rewritten only by a pass (one per serial bump) or by `offlineReassertLoop`, every 15 s plus up to 5 s of jitter (`offlineReassertEvery`, `internal/host/movesoffline.go:461`; loop `agent.go:3714`, `:3753`). That loop covers only the source role (stopping to landed) and the sealer role (sealed to landed) (`offlineReassertRoles`, `movesoffline.go:471-483`). **The target is never reasserted**, so a landing item that waits on its first pass waits for the next bump, or for the 5 to 6 minute instances loop (`agent.go:3715-3717`). |
| + |
| +Inferred cost per hop, before any work: 0 to 2 s serial poll, 0 to 5 s clamp, the pass set ahead of the moves pass (seconds on a busy box), and 0 to 2 s CLI poll. About 3 to 8 s per hop. There are four hops in the window (start, seal, flip, open), plus the box-side CAS steps (sealed, landed) that the CLI only sees on its next poll. |
| + |
| +**No lease TTL is waited on anywhere in the window.** The seal writes its tombstone directly (`lease.Tombstone`, `internal/host/movesoffline_seal.go:420`; `TombstoneTTL` 7 days, `internal/moves/offline.go:450`). The landing accepts an absent, lifted or expired target lock (`movesoffline_land.go:608-651`). The wake takes an absent lease. `StagingLeaseTTL` (45 min, `internal/moves/lease.go:19`) and `SignatureLife` (15 min, `lease.go:13`) bound crashes, not waits. **No certificate step is in the window either.** TLS through the target is a pre-check (runbook §3.1). |
| + |
| +## 1. The sequence, step by step |
| + |
| +### Step A. `start`: the instance stops serving (measured 23.0 / 23.3 s, 16% / 12%) |
| + |
| +| # | What | Where | Who | |
| +|---|---|---|---| |
| +| A1 | The start door writes `offline-stopping` and stamps `requested_at` (the console figure's start) | `apiinstancemove_offline.go:607-631`; `internal/provision/offline_move.go:226-247` (stamp at `:245`) | console | |
| +| A2 | Serial bump, then the box's tick and full pass | `agent.go:2750-2780` | every source-region box agent | |
| +| A3 | Reconcile holds the row `moving` under the move id | `offlineHold`, `movesoffline.go:92-111` | source box agent | |
| +| A4 | The edge reloads, the activator retires the child: SIGTERM drain, final checkpoint, lease release, **asynchronously** (`go a.stop(e)`) | `internal/edge/edge.go:1064`; `internal/activator/activator.go:5100-5168`; `actStopTimeout` 20 s at `activator.go:2676` | source box (edge + activator) | |
| +| A5 | The moves pass installs the fence with a **2 s bound** on the stop (`FenceAs`), then writes the source report: held, fenced, quiesced, process count, local TXID | `movesoffline.go:391-399` (2 s at `:393`); `offlineSourceStop` `:822-834`; `sourceReport` `:802-817` | source box agent | |
| +| A6 | The stager (staged moves) writes its "stopped" acknowledgement | `offlineStagerStopped` via `movesoffline.go:650-652` | source box agent | |
| +| A7 | `start` exits once the status view's next is `seal`: every source box reports held, fenced, quiesced and no longer lists the host in its edges file, and the stager says stopped | `move.go:1586-1606`; `offlineSealCheck`, `apiinstancemove_offline.go:994-1050` | CLI, console | |
| + |
| +**Where the 23 s goes (inferred).** The stop in A4 is asynchronous and A5 waits for it for at most 2 s. Any stop that takes longer (a drain, then a final Litestream sync of a 1.6 to 3.7 GB instance) leaves a report that says `quiesced: false`. Nothing rewrites it until the reassert loop, 15 to 20 s later. That `start` took 23.0 s and 23.3 s at two very different sizes fits "one reassert cycle plus a hop" much better than work that scales with size. The edges-file condition costs little: the edges file is republished within a 2 s registry watch (`internal/host/edgesfile.go:883-898`, `edgesFileWatchInterval` at `:1055`). |
| + |
| +### Step B. `seal` (measured 28.4 / 30.6 s, 19% / 16%; copied 2 objects / 0 objects) |
| + |
| +| # | What | Where | Who | |
| +|---|---|---|---| |
| +| B1 | The seal door writes `offline-sealing`, names the sealer and the boxes | `apiinstancemove_offline.go:929-938` | console | |
| +| B2 | Hop: tick, clamp, pass set; this box's source step first, then the sealer step | `offlineRound`, `movesoffline.go:416-454` | sealer (a source box) agent | |
| +| B3 | Checks its own report is from this pass (fresh within 2 min) | `movesoffline_seal.go:97`, `:319-325` | sealer | |
| +| B4 | **Lists the replica, reads the lock, then checkpoints again**: `ReplicateWithLease` + `SyncAndWait` takes the lease, syncs and releases it | `movesoffline_seal.go:386-411`; `Checkpoint`, `internal/host/movespass.go:315-322` | sealer | |
| +| B5 | Tombstone | `movesoffline_seal.go:420` | sealer | |
| +| B6 | Lists the replica again (final position), carries the request record | `:427-460` | sealer | |
| +| B7 | **The final mirror round** into the target's `moves/<host>/` (8 at once), then a source listing and a staged listing (cross-region), then a listing comparison | `:465-490`; `DefaultMirrorWorkers` 8, `internal/lease/mirror.go:370` | sealer | |
| +| B8 | **The files archive** (build, seal, cross-region put, up to 256 MiB), the timers put, the env report put | `:494-575`; `offlineArchive` `:724` | sealer | |
| +| B9 | Lock read, seal.json create-only, re-assert, lock read, record CAS to `offline-sealed`, serial nudge, living report | `offlineSeal` `:260-305`; `offlineKeepStop` `:892-977` (CAS `:951`, nudge `:958`) | sealer | |
| +| B10 | `seal` exits on `offline-sealed` with next `flip` | `move.go:1608-1632` | CLI | |
| + |
| +**Where the 28 s goes (inferred).** With 0 to 2 objects to copy, the size-dependent copy is gone, but about 15 S3 round trips remain, several of them cross-region: 4 replica or staged listings, the receipts get and put inside `MirrorPrefix`, 3 lock reads, the tombstone, 3 puts, the CAS and the report. On top of that come the B4 checkpoint (a lease acquire, a Litestream open, a sync and a close), the B8 archive (its size for these instances is not recorded), and one hop at each end. Without the source journal's per-step lines, this cannot be split further. |
| + |
| +### Step C. `move.sh` process check (a few seconds, operator-only) |
| + |
| +SSM reads of the source slice (runbook §5 step 3). Self-serve has no such step. |
| + |
| +### Step D. `flip` (measured 44.2 / 57.7 s, 30% / 30%) |
| + |
| +| # | What | Where | Who | |
| +|---|---|---|---| |
| +| D1 | The flip door writes `offline-landing` and the record's region becomes the target | `apiinstancemove_offline.go:939-943`, `:1061-1084` | console | |
| +| D2 | Hop on the target; reconcile mints the row held `landing` in the same pass, before the moves pass | `offlineHold` `movesoffline.go:105-108`; `changeindex.go:265` | target box agent | |
| +| D3 | The landing ensures, in order: row, seal, warm-cache absent, key adoption, lease, **db**, files, config, env, env-pin, timers, next-due, replication, release | `landReport`, `internal/host/movesoffline_land.go:414-470` | target box agent | |
| +| D4 | **db: lists `moves/<host>/`, then `lease.VerifyReplica`: a full Litestream restore of the staged replica into a scratch file plus `PRAGMA integrity_check`. The file is deleted afterwards** | `movesoffline_land.go:700-756` (restore `:746`, delete `:745`); `internal/lease/check.go:44-117` | target box agent | |
| +| D5 | files: fetch, decrypt and extract the archive; config: `RenderHeld` and its ack; timers: read and write the rows; release: resolve the channel, check the live link | `:812-862`, `:919-955`, `:1071-1115`, `:1185-1266` | target box agent | |
| +| D6 | Report, then CAS to `offline-landed` | `offlineLand`, `:77-111` | target box agent | |
| +| D7 | `flip` exits on `landed` with next `open` | `move.go:1634-1658` | CLI | |
| + |
| +**Where the 44 to 58 s goes.** Flip grew by 13.5 s as the replica went from 1.6 GB to 3.7 GB. The only size-dependent work in the landing is D4's restore and integrity check (inferred). D4 is the **first of two full restores inside the window**. Its output is thrown away (`:745`), and the first wake restores the same objects again (step G). |
| + |
| +### Step E. The gate (measured 2 to 3 s; `move.sh` only) |
| + |
| +### Step F. `open` (measured 7.3 / 15.9 s, 5% / 8%) |
| + |
| +| # | What | Where | Who | |
| +|---|---|---|---| |
| +| F1 | The open door writes `offline-open` and stamps `opened_at` (**the console figure's end**) | `apiinstancemove_offline.go:944-948`, `:1094-1129`; `offline_move.go:371-389` (stamp at `:384`) | console | |
| +| F2 | Hop on the target. `landReport` runs once more; `db` skips the restore when the listing equals the last report's | `offlineTargetOpen`, `movesoffline_land.go:134-226`; skip at `:733-737` | target box agent | |
| +| F3 | Releases the hold, so the row is ready; deletes the archive prefix; reports opened | `:166-186`, `:208`, `:221` | target box agent | |
| +| F4 | The source boxes park the old directories | `offlineSourcePark`, `movesoffline.go:1069` | source box agents | |
| +| F5 | `open` exits only when next is `finish`, which also needs **every source box parked** | `move.go:1660-1700`; `apiinstancemove_offline.go:949-953` | CLI | |
| + |
| +F4 and F5 matter for the measurement: `open` returns only after the source has parked, and `move.sh` starts probing only after `open` returns. Nothing wakes the instance before the first request, so in the measured runs the wake started late by up to open's tail (inferred). |
| + |
| +### Step G. Open to first 2xx (measured 40.2 / 57.0 s, 27% / 30%; promote + restore measured 29 / 52 s) |
| + |
| +| # | What | Where | Who | |
| +|---|---|---|---| |
| +| G1 | The edge sees the ready row (2 s registry watch). The target answers 404 for the first 10 to 15 s (measured, runbook §5) | `edgesfile.go:883-898` | target edge | |
| +| G2 | Adoption can start only now: `Adoptable` requires status "" or "ready", so a held row is never staged | `internal/release/adopt.go:1294-1297`; spec §7.5 | target agent, then root's stage pass | |
| +| G3 | The first request wakes the instance: lease, then `restorePlain` | `activator.go:2282`, `:2325`; `internal/activator/backend_exec.go:784` | target activator | |
| +| G4 | **Promotion**: `moves/<host>/` mirrored over `instances/<host>/`, server-side, 8 at once | `promoteStagedReplica`, `backend_exec.go:3429-3463` (call at `:819`) | target activator | |
| +| G5 | **Second full restore** from `instances/<host>/`, then **a second `integrity_check`** | `:829`, `:842` | target activator | |
| +| G6 | **The staged copy is dropped with one DeleteObject per key, serially**, before anything starts | `dropStagedReplica`, `backend_exec.go:3469-3473` (call at `:873`) | target activator | |
| +| G7 | Identity: the live link is materialized through root's stage relay if adoption has not finished yet; **this comes after the restore** | `ensureLiveLink`, `backend_exec.go:1739-1752`; mark `activator.go:2385` | target activator, root | |
| +| G8 | Spawn, settle (readiness), replicate | `activator.go:2560`, `:2609`, `:2636` | target activator | |
| +| G9 | The probe asks every 2 s with 10 s timeouts; a request waiting on the wake gets a 503 at the 30 s bound (measured, runbook §5) | runbook Appendix A `move.sh` | operator | |
| + |
| +**Where the 40 to 57 s goes.** 29 to 52 s is promote + restore (measured, from the journal). By inference that 29 to 52 s holds the promotion copy, the second restore, the second integrity check and 270 to 305 serial deletes. The other 11 / 5 s is route visibility, the build (G7), spawn and settle, and up to 2 s of probe granularity. |
| + |
| +**Not in the client figure, but customers see it.** Other edges learn that the target homes the host from a 30 s home-map poll (`homeMapInterval`, `internal/edge/homemap.go:123`). DNS traffic that lands on a source-region edge can 404 for about 20 s after the target serves (measured, runbook §5). |
| + |
| +## 2. Shares at a glance |
| + |
| +| Bucket | 1.6 GB | 3.7 GB | Kind | |
| +|---|---|---|---| |
| +| Two full restores + two integrity checks + promotion + serial drop (D4 + G4-G6) | ~29 s + part of flip | ~52 s + part of flip | measured (G), inferred (D4 share) | |
| +| Door hops and fixed waits (4 hops × ~3-8 s, the reassert wait in start) | ~25-45 s | ~25-45 s | inferred | |
| +| Seal's S3 round trips, checkpoint and archive | ~20 s of the 28 | ~22 s of the 31 | inferred | |
| +| Landing work other than the restore | rest of flip | rest of flip | inferred | |
| +| Build after open, spawn, settle, probe | ~11 s | ~5 s | measured remainder | |
| +| Operator-only (process check, gate) | ~4 s | ~5 s | measured | |
| + |
| +## 3. Why the console reads 50 to 75 s low |
| + |
| +`offline_s` is `opened_at - requested_at` (`offline_move.go:463-473`). `requested_at` is the start door's write (`:245`), about a second after the client's T0. `opened_at` is the **open door's write** (`:384`). That is before the target has even seen the open, released its hold, adopted the build, promoted, restored or started. |
| + |
| +So it leaves out all of `open` after the door's write, plus the whole of step G: |
| + |
| +- 1.6 GB: open 7.3 s + open to 2xx 40.2 s = 47.5 s, against a measured gap of 147.6 - 99.9 = **47.7 s**. |
| +- 3.7 GB: 15.9 s + 57.0 s = 72.9 s, against 190.4 - 117.2 = **73.2 s**. |
| + |
| +**Fix.** End the figure at the target's first successful wake after open. For example, the target's opened report gains `served_at`, written by the first wake that reaches `settle`. Or the self-serve health check's first 2xx (spec §7.4) records it. `OfflineFinish` then uses that instead of `OpenedAt`. This touches `offline_move.go`, which all three self-serve branches change (+471 lines), so fold it into their "phase timings" item (spec §11). |
| + |
| +## 4. Ranked trims |
| + |
| +Savings are inferred unless marked. Every trim keeps the three guarantees: one writer (the tombstone and the lease), deletes by version id, and no write lost. |
| + |
| +### T1. Restore once, on the held target, before open. Saves about 25 to 50 s. |
| + |
| +**Change.** |
| + |
| +- **(a) At landing:** promote `moves/` to `instances/` in the target bucket at the same time as `VerifyReplica` reads `moves/`. Server-side, no lease needed: `lock.json` is never mirrored, `mirror.go` skips it. Then require the promoted listing to equal `seal.Staged`. In-bucket copies keep their ETags (`backend_exec.go:3450-3454`). |
| +- **(b)** Keep the verified restore in the move's verify park directory instead of deleting it (`movesoffline_land.go:745`). |
| +- **(c) At open,** inside `offlineTargetOpen` after the final `landReport` and before the hold release (`:146-170`): |
| + - sweep the sidecars; |
| + - rename the verified file to the row's `dbPath` (same filesystem, under `/data`); |
| + - delete the staged keys, in parallel. |
| + |
| + The first wake then finds the database warm (`backend_exec.go:795-797`) and skips promotion, restore, the second integrity check and the drop. |
| + |
| +**Why it is safe.** |
| + |
| +- **One writer:** nothing runs and no lease is taken until the wake, exactly as today. |
| +- **No write lost:** the file is the verified restore at the sealed `FinalTXID`. It is placed only at open, which is already the point of no return. |
| +- **No stale staging:** staging is dropped before the hold release, so "staging wins" can never put an old copy back over later writes (`backend_exec.go:3430-3442`). |
| +- **Litestream:** an ordinary wake also starts it on a freshly restored file with no meta directory (`PurgeLocalDBArtifacts`, `backend_exec.go:807`), so its starting state is the same. |
| +- **A crash between the rename and the release:** the next pass's `warm-cache` item parks the file, and the wake falls back to today's path. |
| + |
| +**Risks.** |
| + |
| +- It changes the landing's invariants ("nothing here starts the instance or takes its lease" stays true, but the landing now writes `instances/<host>/` in the target bucket). |
| +- An abort after landing must remove the promoted objects by version id. That is self-serve-moves-4's `internal/lease/cleaning.go` territory. |
| +- Whether Litestream continues the lineage without writing a new snapshot must be checked on dev. |
| + |
| +**Collides.** |
| + |
| +- `movesoffline_land.go`: +263 lines on self-serve-moves-2 and -3. |
| +- Spec §7.5 and §10 Q3. **This is Q3 alternative (a), and Q3 was ruled "as stated" on 2026-10-22, so it needs Paul's ruling.** It also moves a failed promotion or restore from after open to before it, so the abort returns the instance with nothing lost. |
| +- The estimate's promotion term (§6.3). |
| + |
| +**T1a, the cheap half that can ship alone:** run `dropStagedReplica` (`backend_exec.go:3469-3473`) with `forEachParallel` and `DefaultMirrorWorkers`, still before spawn. Saves 5 to 12 s (inferred: 270 to 305 serial deletes at 20 to 40 ms each). Very low risk. No collision: `backend_exec.go` is untouched on all three branches. |
| + |
| +### T2. Report the stop when it happens. Saves about 10 to 18 s of start's 23 s. |
| + |
| +**Change.** While this box has a move in `offline-stopping`, run the source step again as soon as the activator's stop for that host completes. Two ways: |
| + |
| +- a callback from `stop` that kicks `offlineReassert`; |
| +- a 2 s reassert tick, only in the stopping state. |
| + |
| +Today a stop longer than the 2 s `FenceAs` bound (`movesoffline.go:393`) waits 15 to 20 s for the next reassert (`:461`, `agent.go:3753`). |
| + |
| +**Risk.** Low. A few extra report PUTs and record GETs per source box, only while a move is stopping, and none while idle. That keeps to the S3 request budget rule (#336). |
| + |
| +**Collides.** Lightly: `movesoffline.go` and `agent.go` are rewritten on self-serve-moves-2 and -3 (the reassert roles are now by box id). The constant itself is unchanged there (`offlineReassertEvery`, self-serve-moves-3 `movesoffline.go:765`). The job would gain the same seconds. |
| + |
| +### T3. Cut the hop latency between steps. Saves about 10 to 25 s for self-serve, 3 to 6 s for the CLI. |
| + |
| +**Change.** |
| + |
| +- **Self-serve job.** It ticks every 5 s and advances a row at most one step per tick (`selfServeTickInterval`, self-serve-moves-3 `internal/console/selfserve_pass.go:144`; `selfServeStep`, `selfserve_job.go:203`). That is 2.5 s on average and up to 5 s at each of about 8 step boundaries in `cutting`. Re-evaluate the row at once after a step that wrote, and tick at 1 s while any row is cutting. |
| +- **Box.** A serial bump from an offline door that lands inside `fastFullClamp` (5 s, `agent.go:2247`) waits out the clamp. Let a bump whose index scope is a record with an offline move bypass the clamp once. Or run the moves pass ahead of telemetry and plans; reconcile must still run first, because flip needs the held row minted. |
| +- **CLI (operators only).** `carlos move offline start --through open` chains the verbs in one process and keeps the 2 s poll. |
| + |
| +**Risk.** Low. Each step still waits on the same evidence. |
| + |
| +**Collides.** Directly with the self-serve job code. Do it on that branch. |
| + |
| +### T4. Have the build ready before open. Saves about 3 to 15 s (unmeasured; read the `identity` mark in the `woke` line). |
| + |
| +**Change.** During landing, stage the sealed build's version directory on the target through the held-stage path Phase 1 already has (`heldMaterialize`, `internal/host/movesstage.go:19`; `release.MaterializeHeld`). Point the live link only at open, just before the release: the `release` item accepts a link that names the sealed build (`movesoffline_land.go:1231-1266`). Today the build can stage only once the row is ready (`adopt.go:1294-1297`), and a wake materializes it after the restore (G7). |
| + |
| +**Risk.** Low to medium. |
| + |
| +- Never create the link before open: a link left after an abort is #339's stale-link trap. |
| +- A version directory left after an abort is inert, but it uses disk. |
| + |
| +**Collides.** Spec §7.5 and Q3 (the "materialising the build" half of alternative (a)), and the landing's `release` item on self-serve-moves-2 and -3. Ask for Q3 together with T1. |
| + |
| +### T5. Wake at open; don't wait for the first request. Saves 0 to 15 s in the measured runs, less with live traffic. |
| + |
| +**Change.** Right after the hold release in `offlineTargetOpen` (`:166-186`), the target starts a wake for the host itself, the way a probe wake does. Promotion and restore (or T1's rename) then begin at once. In the measured runs the first request came from `move.sh`, after `open` had also waited for the source to park (F5). |
| + |
| +**Risk.** Low. Any request would start the same wake. |
| + |
| +**Collides.** The self-serve health probe (spec §7.4) also triggers the wake; this only makes it earlier. |
| + |
| +### T6. Source-region edges learn the new home sooner. Saves up to about 20 to 30 s for DNS clients on those edges. |
| + |
| +**Change.** On the open bump, the source boxes (still participants: they park at open) refresh their home map at once instead of waiting for the 30 s poll (`homemap.go:123`). |
| + |
| +**Risk.** Low. |
| + |
| +**Collides.** self-serve-moves-3's holding page (`internal/edge/holding.go`, spec §6.4 "Reopening"), which decides when edges stop showing the holding page. Build it there. |
| + |
| +### T7. Pre-stage the files archive. Saving unknown. |
| + |
| +Today the seal builds and uploads the whole files tree, up to 256 MiB, while offline (B8). A per-file, content-addressed stage with a final delta at the seal would move that work out of the window. This is a bigger change to `internal/moves/archive`. Record `files_bytes` for the next moves before deciding. |
| + |
| +### T0. Measure before building T2 to T7 |
| + |
| +Record each phase's time on the move: the reports already carry `At`, and the wake already logs its steps. Fix the console figure (§3). The spec wants phase timings anyway (§11). |
| + |
| +### Rejected, because each weakens a guarantee |
| + |
| +- **Skip the landing's `VerifyReplica`** (saves one restore). A corrupt staged replica would then be found only after open, when there is no automatic return. T1 keeps the verification and reuses its output instead. |
| +- **Stage straight into the target's `instances/<host>/` from the source box.** The staging grant deliberately never covers `instances/*` (runbook §2.4). This would let a non-owner write the target's live lineage. |
| +- **Drop the staged copy after spawn, in the background.** A crash before the drop lets "staging wins" (`backend_exec.go:3430-3442`) put the move-time copy back over writes taken since. No write lost would break. T1a parallelises the drop instead. |
| +- **Skip the seal's second checkpoint (B4) when the positions are equal.** The comment at `movesoffline_seal.go:375-384` says why it runs, and `movespass.go:746-749` adds that the stop logs and swallows a failed final checkpoint, and the tail may still be in the WAL. Acceptable only with proof that the WAL is empty. Without that proof, rejected. |
| +- **Shorten `actStopTimeout`, drop the "every source box stopped" barrier, or loosen report freshness** (`offlineReportFresh`, 2 min, `apiinstancemove_offline.go:67`). Each one weakens the single-writer stop for a few seconds of gain. |