spec #658 rev 3: answer Astra round 1
Mark must postdate the current activation; lineage bound to the app lifetime; own region only with a whole-prefix staging check; seeds and imports refused; proven retirement evidence; ownership checked first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+168
−62
docs/superpowers/specs/2026-11-07-instance-restore-658-design.md+71 −62docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R1.md+97 −0
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/specs/2026-11-07-instance-restore-658-design.md b/docs/superpowers/specs/2026-11-07-instance-restore-658-design.md| index 3bec01887..155a8d7af 100644 |
| --- a/docs/superpowers/specs/2026-11-07-instance-restore-658-design.md |
| +++ b/docs/superpowers/specs/2026-11-07-instance-restore-658-design.md |
| @@ -1,111 +1,120 @@ |
| # Restore a deleted instance with its own data (#658) |
| -Rev 2, 2026-11-07 (rev 1 plus the builder check and Paul's ruling on older deletions). Branch `design-instance-restore-658`. Discussion #658 on carlos/platform (taken by Paul, 2026-11-07). |
| +Rev 3, 2026-11-07. Branch `design-instance-restore-658`. Discussion #658 on carlos/platform (taken by Paul, 2026-11-07). Rev 2 had the builder check and Paul's ruling on older deletions; rev 3 answers Astra round 1 (`CODEX-FINDINGS-instance-restore-658-R1.md`, NOT READY, three P1s and four P2s; dispositions in §10). |
| ## 1. Why |
| -An app that installs other apps onto its own account (a front door) uninstalls an app by deleting its instance, and later reinstalls it on the same hostname. The person expects their data back. Today the create refuses with S1 ("<host> is in use or has held an app's data before, so it can't be created. Choose another address.") because the hostname history never lets a name be created twice (docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md §1). In the home region the leftover rail (#199) would refuse it too: "<host> still holds data from a deleted instance. Choose another address, or ask an operator to purge it." (apiinstances.go:2311). |
| +An app that installs other apps onto its own account (a front door) uninstalls an app by deleting its instance, and later reinstalls it on the same hostname. The person expects their data back. Today the create refuses with S1 ("<host> is in use or has held an app's data before, so it can't be created. Choose another address.") because the hostname history never lets a name be created twice (docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md §1). In the home region the leftover rail (#199) would refuse it too (apiinstances.go:2311). |
| -The history protects against a new record surfacing data that is not its own: another tenant's, or an older copy left by a move. It has no reason to refuse the same account and app taking back their own latest data. This spec adds that, and only that. |
| +The history protects against a new record surfacing data that is not its own: another tenant's, or an older copy left by a move. It has no reason to refuse the same account and app taking back their own data. This spec adds that, and only that. |
| -**Success:** the front door deletes an instance, then creates it again on the same hostname with `restore` set, and the instance comes back with the database it had when it was deleted. A request that cannot be proven to be the same owner taking back its own newest copy is refused, with a message that says why. |
| +**Success:** the front door deletes an instance, then creates it again on the same hostname with `restore` set, and the instance wakes with the data it had when it was deleted. A request that cannot be proven to be the same owner taking back its own data is refused. |
| ## 2. Goals, non-goals, anti-goals |
| Goals: |
| -- A restore through the existing create door, for the CLI and for a service credential with the `instance` role (the same handler serves both, `handleAPIInstanceCreate`, apiinstances.go:1524). |
| -- Delete keeps a durable note of where the instance's last copy lived, so a restore of a moved instance lands on the right copy. |
| -- Instances deleted before this ships are refused (R8). Without a stored body nothing says which copy is newest, and the console cannot list other regions' buckets to look (Paul, 2026-11-07, on this spec: "Refuse older is fine"). The live case on account oficina keeps the front door's interim: a fresh address. |
| - |
| -Non-goals: |
| -- Reusing a hostname for a different account, app or purpose. The never-reuse rule stays exactly as it is for every create without `restore`. |
| -- Bringing back the old record's configuration. The caller sends a full create body, as for any create; only the data comes back. |
| -- A stop/start state (route off, data kept). It may still be useful later; restore covers the ask without it. |
| -- Restoring sidecars, HA instances, rootfs instances, pool or fleet-placed instances, addr-backed instances, or replicas. Each is refused up front (§4, R7). |
| -- Restoring with claims on. Production runs claims off (shelved 2026-10-25); restore refuses if `HostClaim` is set. |
| - |
| -Anti-goals (a failure even if restore "works"): |
| -- A restored instance serving any copy other than the newest one its own last record wrote. |
| -- Any path where one account or app can reach data another account or app wrote. |
| +- A restore through the existing create door, for the CLI and for a service credential with the `instance` role (one handler serves both, `handleAPIInstanceCreate`, apiinstances.go:1524). |
| +- Delete keeps durable, proven evidence of the record it retired (§5). |
| + |
| +Non-goals (each refused up front): |
| +- Instances deleted before the release that ships this, and instances whose hostname was first marked before the current activation of the hostname history (R8). Paul, 2026-11-07: "Refuse older is fine". The live case on account oficina keeps the front door's interim: a fresh address. |
| +- Restoring outside the console's own region (R5). The console cannot read another region's data bucket (apidb.go:40 `ErrResidency`), so it cannot make the staging check of §3 there. |
| +- Sidecars, HA, rootfs, pool, fleet-placed, addr-backed, replica, demo, seeded and imported instances, as the old record or the request (R7). A seeded database carries a seed marker that an unseeded successor purges before its warm-cache test (seedplace.go:273, backend_exec.go:988), so a seeded instance cannot keep its data under a new record without wake-path changes. |
| +- Restoring with claims on (R2). Production runs claims off (shelved 2026-10-25). |
| +- Reusing a hostname for a different account, app or app lifetime. The never-reuse rule stays exactly as it is for every create without `restore`. |
| +- Bringing back the old record's configuration. The caller sends a full create body; only the data comes back. |
| +- A stop/start state. Restore covers the ask without it. |
| + |
| +Anti-goals: |
| +- Any path where one account, app or app lifetime can reach data another wrote. |
| +- A restored instance reading any copy that waking the same instance from hibernation would not read (§6). |
| - Any weakening of S1, S4, S5 or the leftover rail for a create without `restore`. |
| +- Any refusal that tells a caller about another owner's use of a hostname (§4, order). |
| ## 3. The door |
| -The create body gains `"restore": true`. The CLI flag is `carlos instances create --restore` (the CLI lives in its own repo; this repo owns the door and docs/site/cli.md). Everything a create checks today is still checked, in the same order, with three changes, and only when `restore` is set: |
| +The create body gains `"restore": true`. The CLI flag is `carlos instances create --restore` (the CLI lives in its own repo; this repo owns the door and docs/site/cli.md). A restore runs every check a create runs today, with these changes and only when `restore` is set: |
| -1. **Region.** The region is the restore region from §5, never nearest-region or app-region placement. A request that names a different region is refused (R5). `checkPlacement` and the region's other create checks still apply. |
| -2. **The leftover rail** (createleftovers.go:136) does not refuse on the host's own replica prefix `instances/<host>`. It still refuses on move staging `moves/<host>` (R6), because a staged copy wins over the replica on wake (backend_exec.go restorePlain, "Staging wins when present") and is not the last record's data. |
| -3. **The mark step.** `markForCreate` (hostsused.go:631) treats a conflicting mark as a pass when, and only when, the ownership proof in §4 holds. The proof runs at the mark step under the same app lock and lifetime admission the create already holds (lifetimes_create.go:63), so nothing changes between the check and the write. |
| +1. **Ownership first.** Right after the body is decoded and the host validated, and before region resolution, the leftover rail or any other history-dependent check, the door evaluates the ownership proof (§4). If it fails for any reason other than an unreadable source, the answer is S1, unchanged, whatever else is wrong with the request. Only once it passes can a caller see R4 to R8. The proof is evaluated again at the mark step, under the app lock and the lifetime admission the create already holds (lifetimes_create.go:63), and that second evaluation decides. |
| +2. **Region.** The region is the stored body's `Region` (§5), which must be the console's own region (`s.cfg.Region`), else R5. A request naming a different region is refused (R5). Nearest-region and app-region placement are not consulted. `checkPlacement` and the region's other create checks still apply. |
| +3. **Staging.** The door lists the whole prefix `moves/<host>/` in the console region's data bucket, every object of any name (the boundary promotion uses: backend_exec.go:3849 lists `MovesPrefix(host)` and mirrors all of it). Any object refuses (R6); a listing error refuses (R1). This replaces the LTX-only test of `hostHoldsReplicaData` for a restore. Staging that survives a finished move is a live hazard beyond restore and is filed separately (§10). |
| +4. **The leftover rail** (createleftovers.go:136) does not refuse on the host's own replica prefix `instances/<host>` for a restore. Item 3 covers staging. |
| +5. **The mark step.** `markForCreate` (hostsused.go:631) treats a conflicting mark as a pass only when the second evaluation of the proof passes. |
| -`gateDataCreate` (S2, S4, S5) is unchanged and runs first, as today. |
| +`gateDataCreate` (S2, S4, S5) runs as today. |
| The restored record is a new lifetime: incarnation N+1 from `LastIncarnation`, over the retired slot, as `planCreateLocked` already allows. The replica and the warm file are keyed by hostname alone (activator.go `HibernatePrefix`; provision.go `DefaultDBPath`), so the first wake finds the old data with no copying. |
| -The response is the create's response plus `"restored": true`. A restore that finds no data in the restore region still succeeds (the data was never written or is gone, which §1 of the history spec already calls harmless), and says so: `"restored": false`. **My call**: refusing would leave the owner unable to ever use the name again, for no safety gain. |
| +The response is the create's response plus `"restore": true`: the record was accepted as a restore. It does not claim data came back; the console cannot see the box's warm file, and the wake happens later. A restore over data that turns out to be absent wakes empty, which the history spec's §1 already calls harmless for the same owner. |
| -When an ordinary create (no `restore`) hits S1 and the ownership proof in §4 would pass, the refusal says how to restore (copy C2), so a caller learns the option from the error. |
| +When an ordinary create (no `restore`) hits S1 and the proof would pass, the refusal says how to restore (C2). C2 depends on the complete proof, so another owner never sees it. |
| ## 4. Ownership proof |
| -A restore of `<host>` by account A, app P passes only when all of these hold. Any read that fails refuses with "could not check" (R1), never as a pass. |
| +A restore of `<host>` by account A and app P, whose current app lifetime is L (`apps.lifetime`), passes only when all of these hold. A source that cannot be read refuses with R1, never as a pass. |
| -1. The history mode is `active`. In any other mode, refuse (R2). |
| -2. Lifetimes are on (`lifetimesOn`, lifetimes_cutover.go:309). Otherwise refuse (R2). |
| -3. The mark `control/hosts-used/<host>.json` has `Source` `create` or `recovery` and names A and P (`HostUse`, provision/hostsused.go). An `inventory` mark (written at activation for a host already holding data, owner unknown) refuses (R3). So does a mark naming anyone else. |
| -4. The slot `control/host-incarnations/<host>.json` is `retired` and names A and P. |
| -5. Every `host_allocations` row for the host that is not `void`, and every `record_retirements` row for the host, names A and P, and at least one committed allocation exists. This is the single-lineage check: before activation a mark conflict did not refuse (hostsused.go `markPass`), so a host could have passed from one owner to another while the mark kept naming the first. A host created before the lifetimes cutover has no allocation row (the lazy migration writes only `record_migrations`, store.go:501, with no body and no app lifetime), and before the cutover a hostname could change hands leaving no rows at all. So a host with no committed allocation refuses (R3). **My call** (builder check): no safe proof exists for that era. |
| -6. The newest committed retirement's incarnation equals the slot's, and no allocation or retirement for the host is pending (`hostSettling`). |
| -7. The app's lifetime is the one the last allocation was bound to (`host_allocations.app_lifetime`). An app deleted and recreated under the same name is a different app: refuse (R4). **My call**, conservative. It does not block the front door: its uninstall deletes only the instance and keeps the app (carlos/base internal/platform/http.go:134, `DeleteInstance`). |
| -8. The last record's shape is restorable (§2 non-goals), and so is the requested one: kind `instance`, paths derived, no HA, no runtime, no pool, no fleet placement, no replica role. Otherwise refuse (R7). |
| +1. The history mode `@mode` is `active`, and lifetimes are on (`lifetimesOn`, lifetimes_cutover.go:309), and claims are off. Otherwise R2. |
| +2. The mark `control/hosts-used/<host>.json` has `Source` `create`, names A and P, and its `At` is later than `@mode.At`. `markHost` stamps `At` at write (hostsused.go:614); only activation and invalidation write `@mode.At` (hostsused_activate.go:468, hostsused.go:485, :536, hostsused_activate.go:496). So the mark was written by a create admitted under the current activation, when activation's inventory had already marked every hostname holding data on any examined target, and S4 refused creates on targets it had not examined. That is the provenance: no data under the hostname predates this mark. A mark written before the current activation (any `create` or `recovery` mark from the incomplete window, which `markPass` let conflict, or one from an earlier activation that was later invalidated) is refused (R8): its predecessors cannot be ruled out. |
| +3. Every `host_allocations` row for the host that is not `void` names A, P and L. Under item 2 the first of them is the mark's create, since S1 refuses every later create; the rest are earlier restores. A row bound to another app lifetime refuses (R4). |
| +4. The slot `control/host-incarnations/<host>.json` is `retired` and names A and P. No allocation or retirement for the host is pending (`hostSettling`). |
| +5. The newest `record_retirements` row for the host names A and P, has the slot's incarnation, and is marked restorable (§5). Any other outcome refuses (R8), and no older row is consulted. |
| +6. The stored body and the request are both plain (§2 non-goals): kind `instance`, paths derived, no HA, runtime, pool, fleet placement, fleet box, replica role or assignment, seed, demo or demo claim, and the request carries no `from` or import. Otherwise R7. |
| -Why this is enough: once the history is active, a host whose mark came from a create had no data on any examined target at activation (activation marks every host it finds as `inventory`), and no second create of it could pass S1. Items 4 to 6 cover the window before activation and the lifetime era. Together they say the only data that can exist under the hostname was written by A's app P. |
| +Items 2 and 3 together say the only data that can exist under the hostname was written by app P in lifetime L, under this mark's lineage. |
| -## 5. The restore region |
| +## 5. Retirement evidence |
| -### 5.1 Instances deleted from this release on |
| +`record_retirements` gains two nullable columns: `record_body` and `restorable`. |
| -At the delete door, `BeginRetirement` (lifetimes_store.go:208) stores the record body whose ETag it already captures, in a new column `record_retirements.record_body`. N1 tombstones only when the record still has that ETag (lifetimes_retire.go:317), so the stored body is exactly the last record. The restore region is that body's `Region`, and its shape is what §4 item 8 checks. |
| +- `BeginRetirement` (lifetimes_store.go:208) stores the body whose ETag it captures, as a candidate. |
| +- `restorable` is set only for a normal retirement, and only when the tombstone over that body is proven: either N1's own write landed (lifetimes_retire.go:317, CAS on the captured ETag), or recovery observes, before N3, a tombstone at the record key whose incarnation is the row's and whose `record_seq` is the candidate's plus one. `TombstoneBody` keeps `record_seq` and `WriteRecord` advances it by exactly one (provision/lifetime.go:151), so that pair names the tombstone written over exactly the captured body. This covers a lost N1 response. |
| +- Every other outcome leaves `restorable` unset: a slot found already retired (lifetimes_retire.go:266), an absent record (:288), a conversion to cleanup (:294, which replaces the ETag), orphan and cleanup retirements, and any path that removes a data-kind record without a retirement row. Plan task 1 lists every writer of `record_retirements` and every remover of a data-kind record and shows each either takes this rule or leaves no restorable row. |
| +- The column lives in the console database. A console restored to an older snapshot loses rows; the newest row no longer matches the slot's incarnation (item 5) and restore refuses. |
| -The restore region may be any region, not only the console's own: the record is all the console writes, and the region's box restores from its own bucket on wake. The console cannot read another region's data bucket (IAM, by design: apidb.go:40 `ErrResidency`), so it checks staging (R6) only when the restore region is its own, through the leftover rail's listing. Elsewhere it relies on the move invariant: a staged copy exists only while an inbound move is landing (backend_exec.go:1013), and delete is refused while a move is live (`refuseDeleteDuringMove`, M-C19), so no staged copy can outlive the record. Plan task 1 confirms that invariant holds for aborted and finished moves alike; if it does not, restore refuses outside the console's region. |
| +## 6. Box disks |
| -The column lives in the console database. A console restored to an older snapshot loses rows; restore then finds no body and refuses (R8) rather than guessing. |
| +On wake, a present local file is used before the replica (backend_exec.go:991, "Warm cache"). Platform boxes take records by region and pool alone (reconcile.go:524, `inScope`; `ownsRecord`), so any box in the region may hold an older local file of a host it once served, and the existing wake prefers it. |
| -### 5.2 Instances deleted earlier, or with no stored body |
| +**My call:** restore gives exactly the guarantee waking the same instance from hibernation gives, no more. Between delete and restore no box reads, writes or purges the host's files: delete removes the route only (`reg.Delete`), and boxes purge nothing (self-serve moves plan 1). The restored record has the same hostname, region and pool (both empty), and the shape rules of §4 item 6 exclude everything keyed by more than the hostname: seed markers, rootfs markers, labels and replica assignments. So the set of local files and replica objects a restored wake can read is the set a wake of the never-deleted, hibernated instance would read. Whether that wake can prefer a stale file on a sibling box (Astra R1 finding 5) is a property of the wake path for every hibernating instance in a multi-box region, not of restore; plan task 1 checks it and, if it is real, files it as its own issue with the scenario. Restore does not wait on it and does not claim more. |
| -Refused (R8): the newest committed retirement for the host has no `record_body`. This covers every delete before the release that adds the column, and any row lost to a console restore. No fallback looks for the data: a move keeps the source's replica (offline moves spec, "kept so an operator's return has it"), so finding data in a region does not show it is the newest copy, and the console cannot list other regions' buckets in any case (§5.1). |
| - |
| -### 5.3 Box disks |
| - |
| -On wake, a present local file is used before the replica (backend_exec.go restorePlain, "Warm cache"). Delete does not remove the serving box's file. In the restore region the readers are therefore: the region's replica, the last serving box's warm file (the newest copy, written by the same process that replicated), and any other box's file at the derived path. |
| - |
| -**For the builder to establish** (plan task 1, before any code): whether a box in the restore region other than the last serving one can hold a file at the host's derived path, and if so whether the restored record could be served there. Moves park source files (movesoffline.go `.offline-moves/<host>/<id>/source`) and landing parks a differing file, so I expect no stale file to remain at the live path. If one can, restore refuses when the region has more than one box that could serve the host, or the plan adds a park of that file before the record is written. Report the finding before choosing. |
| - |
| -## 6. Copy |
| +## 7. Copy |
| New user-facing strings, to go through copy review before they are written into code or docs. Placeholders in angle brackets. |
| - R1: "Could not check whether <host> can be restored. Try again." |
| - R2: "<host> can't be restored on this platform yet. Ask an operator." |
| -- R3: "<host> held data before this platform kept a record of who owned it, so it can't be restored." |
| - R4: "<host> belonged to an earlier app named <app>, so it can't be restored into this one." |
| -- R5: "<host> can only be restored in <region>, where its data is." |
| -- R6: "<host> has a move's copy waiting in <region>, so it can't be restored. Ask an operator." |
| +- R5: "<host> can only be restored from the console in <region>." (the stored body's region) |
| +- R6: "<host> has a move's copy waiting, so it can't be restored. Ask an operator." |
| - R7: "<host> can't be restored: restore works for plain instances only." |
| - R8: "<host> was deleted before restore was available, so it can't be restored." |
| -- Ownership refusal (mark, slot or lineage names someone else): the existing S1 text, unchanged. A restore attempt by another owner learns nothing new. |
| +- Ownership failure (mark, slot, lineage or retirement names someone else, or the mark is not this owner's): the existing S1 text, unchanged. |
| - C2 (S1 when the proof would pass): "<host> held this app's data before. To bring it back, create it with --restore." |
| - docs/site/cli.md: a short "Restoring a deleted instance" section beside the delete text at line 1230. |
| -## 7. Delivery |
| +R3 is gone (rev 2's pre-cutover refusal is now R8 through §4 item 2). |
| -One plan, one merge (AGENTS.md rule 6): the door, §4 and §5.1 together, since restore needs a stored body to do anything. What Paul can see: on dev, an instance deleted after the roll comes back with its data. No switch: restore is a request field, on from the release that carries it (rule 5). Who asks: the front door app (#658). The witness: on dev, create a data-kind instance, write a row, delete it, restore it, read the row back; then the refusal cases R2 to R8 and the other-owner S1. |
| +## 8. Delivery |
| -Review: specs and plans per AGENTS.md stopping rules (three Astra rounds at most; stop at the first round with no P1). Census: the change is in `internal/console`, outside the root binary, so no census card is expected; the plan confirms with `make census-card`. |
| +One plan, one merge (AGENTS.md rule 6): the door, §4 and §5 together, since restore needs a restorable row to do anything. What Paul can see: on dev, an instance created and deleted after the roll comes back with its data. No switch: restore is a request field, on from the release that carries it (rule 5). Who asks: the front door app (#658). |
| -## 8. Left to the builder |
| +Witnesses, through the real door: create, write a row, delete, restore, read the row back; delete and restore twice; and refusals: another account and another app with a conflicting region, staging, missing body and older app lifetime, all answering the same S1; R2, R4 to R8; staging holding only `build-state.json`; a lost N1 response proven by `record_seq`; a mark older than `@mode.At`. |
| -- Where in `handleAPIInstanceCreate` and `createRecordWithLifetimeLocked` the restore flag travels, and how the proof's reads are shared with the mark step. |
| -- The SQLite migration for `record_body` (nullable; older rows stay null). |
| +Review: AGENTS.md stopping rules (three Astra rounds at most; stop at the first round with no P1). Census: the change is in `internal/console`, outside the root binary; the plan confirms with `make census-card`. |
| + |
| +## 9. Left to the builder |
| + |
| +- How the restore flag travels through `handleAPIInstanceCreate` and `createRecordWithLifetimeLocked`, and how the two evaluations of the proof share reads. |
| +- The SQLite migration (nullable columns; older rows stay null and are never restorable). |
| - Whether the mark's `Account` and the allocation's `account` use the same identifier (sqid or id), and normalising if not. |
| -- How the R6 staging check reuses the leftover rail's listing (`hostHoldsReplicaData`). |
| -- Test shape: production-wired witnesses through the real door, plus a table of the refusals. |
| +- Plan task 1's two inventories: the writers of `record_retirements` and removers of data-kind records (§5); the sibling-box warm-file check (§6). |
| + |
| +## 10. Round 1 dispositions |
| + |
| +1. P1 provenance: accepted. §4 item 2 now requires a mark written under the current activation; item 3 binds every allocation to the current app lifetime. |
| +2. P1 staging: accepted. §3 item 3 lists the whole prefix; restore is cut to the console's own region (R5). The leftover staging after a finished move (`dropStagedReplica` is best effort, backend_exec.go:3872) can make any later cold wake mirror stale staging over a newer replica, restore or not: filed as discussion #661. |
| +3. P1 seeds: accepted. Seeded and imported instances are refused (R7). |
| +4. P2 retirement evidence: accepted, §5. |
| +5. P2 local-file freshness: answered by scoping the guarantee to hibernation's (§6), with the check moved to plan task 1 and a separate issue if real. |
| +6. P2 order: accepted, §3 item 1. |
| +7. P2 `restored` boolean: accepted; the response reports acceptance only. |
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R1.md b/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R1.md| new file mode 100644 |
| index 000000000..5eefca602 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R1.md |
| @@ -0,0 +1,97 @@ |
| +# Instance restore #658 — round 1 findings |
| + |
| +Reviewed rev 2 at `8547372bca42c8abeda410501bb1239c9e31c00b`, including the two named authority specs and the implementation in this checkout. The brief's older commit identifies the same design revision. This is round 1 of the three-round budget. No subagents or test suites were run. |
| + |
| +## P1 |
| + |
| +### 1. A committed allocation does not prove that all earlier data belongs to its owner |
| + |
| +**Section:** §4 items 3, 5 and 7, and the sufficiency argument at design lines 54–61. |
| + |
| +**Problem and evidence:** Activation does not replace an existing create/recovery mark with an inventory mark. It calls `MarkHostUsed` for inventoried hosts (`internal/console/hostsused_activate.go:423`, `:443`), whose create-only conflict leaves the old body unchanged (`internal/provision/hostsused.go:69`, `:82`). Before activation, a conflicting mark also permits a create (`internal/console/hostsused.go:621`). The allocation table records individual allocations, not proof that nothing preceded its first row (`internal/console/lifetimes_store.go:98`). Requiring at least one committed allocation therefore does not exclude hosts with an unrecorded earlier owner. Checking only the last allocation's app lifetime also does not exclude earlier lifetimes under the same account/app names. |
| + |
| +**Failure scenario:** Before lifetime/history tracking, app Q uses H and is deleted, leaving a local database but no replica objects. Deletion intentionally preserves the database (`internal/console/apiinstances.go:3180`). After lifetimes turn on, but before history activation, app P creates H without waking it. The leftover rail checks replica objects, not the box's file (`internal/console/createleftovers.go:71`), so P obtains the first mark and a committed allocation. Activation inventories Q's file but preserves P's create mark. P deletes its record after restore ships. All eight checks now pass: the mark, slot and all recorded rows name P, its current app lifetime matches, and its newly captured retirement body is plain. Restore wakes Q's database through the warm-file path (`internal/activator/backend_exec.go:991`). This sequence needs neither a second box nor a foreign-region read. |
| + |
| +A related case remains entirely within the allocation era: before activation, app P can be purged and recreated under a new app lifetime, then allocate H again. Both lifetimes have identical account/app names, and item 7 checks only the last one. App row recreation mints a new lifetime (`internal/console/lifetimes_store.go:387`); the checks do not establish that remaining hostname data belongs to that lifetime. |
| + |
| +**Fix:** Require durable evidence that the host's original data allocation was admitted against a completed, valid inventory, with no earlier ambiguous use. Refuse existing hosts for which that provenance cannot be established; an existing create/recovery mark plus a later allocation is insufficient. Define how invalidation/re-activation affects this evidence. Bind the entire accepted data lineage to the current app lifetime, rather than checking only its latest allocation. Add witnesses for the unrecorded-predecessor and same-name/new-app-lifetime cases. |
| + |
| +**Fault family:** Hostname data provenance across owners and app lifetimes. |
| + |
| +### 2. R6's proposed listing can miss staging that deletes the current replica |
| + |
| +**Section:** §3 item 2, §5.1 and §8's reuse of `hostHoldsReplicaData` (design lines 37, 69 and 110). |
| + |
| +**Problem and evidence:** The proposed helper checks only LTX files at the replica levels (`internal/console/createleftovers.go:55`, `:79`, `:98`). Wake instead tests whether *any* object exists under `moves/<host>/`, then mirrors that whole prefix over the ordinary replica (`internal/activator/backend_exec.go:3849`, `:3862`). The mirror deletes destination objects absent from staging (`internal/lease/mirror.go:332`). Staging includes `build-state.json`, as the existing witness confirms (`internal/activator/promote_buildstate_test.go:13`). Its cleanup ignores each deletion error (`internal/activator/backend_exec.go:3872`, `:3895`). |
| + |
| +**Failure scenario:** A move lands and wakes successfully. Cleanup removes the staged LTX files but fails to remove `build-state.json`. The instance continues writing newer data to its ordinary replica, then is deleted. A restore in the console's own region passes the proposed R6 listing because staging contains no LTX. On a cold wake, promotion sees `build-state.json`, mirrors it, and deletes the current replica's LTX files because staging has none. Restore can then boot fresh despite recoverable data having existed immediately before promotion. A retained staged LTX instead permits rollback to the move-time copy outside the home region if the proposed remote exception is used. |
| + |
| +The asserted move invariant is already false, not an unanswered implementation question. The legacy move clears `Move` before the destination wakes (`internal/host/movespass.go:1639`), and successful wake does not require staging deletion to succeed. Also, `refuseDeleteDuringMove` returns immediately when `MovesEnabled` is false (`internal/console/apiinstancemove.go:1746`); hostname-history activation requires that switch off (`internal/console/hostsused_activate.go:324`). It cannot supply the stated claims-off deletion guarantee. Abort cleanup does have an explicit delete-before-clear sequence (`internal/host/movespass.go:1535`), but that does not establish the same property for finished moves. |
| + |
| +**Fix:** Make R6 prove the entire current staging prefix empty, using the same prefix boundary and object scope as promotion; refuse on any object or listing failure. Apply §5.1's stated cut now: refuse restore where the console cannot make that check, unless a separate durable box-side proof is designed. Do not weaken the existing rail for ordinary creates. Test a staging prefix containing only `build-state.json`, partial cleanup failure, and completed moves with leftover staging. |
| + |
| +**Fault family:** Staging completeness and precedence over the latest replica. |
| + |
| +### 3. A previously seeded plain instance loses its warm data on restore |
| + |
| +**Section:** §3's new-record/no-copy mechanism and §4 item 8 (design lines 42 and 59). |
| + |
| +**Problem and evidence:** The permitted old-record shape does not exclude seeds or committed imports. A placed seed remains on its record for life, and its database carries a seed marker (`internal/activator/seedplace.go:129`, `:147`). The proposed full create body does not retain that old identity. Before testing for a warm database, `restorePlain` runs `reconcileSeedMarker` (`internal/activator/backend_exec.go:988`). When the new row has no seed, an existing seed marker is foreign and the database and its artifacts are purged (`internal/activator/seedplace.go:273`, `:290`). `TestPlainRestoreNeverServesAnotherSeedsDatabase` explicitly covers the no-seed successor (`internal/activator/seedplace_linux_test.go:812`). |
| + |
| +**Failure scenario:** A plain instance created from a seed or committed import accumulates new writes. Its final replication checkpoint fails during stop; the failure is logged and the activator entry is removed (`internal/activator/activator.go:5273`, `:5289`), leaving the newest data locally. Delete and restore pass the eight checks on a single box. The new unseeded record purges that latest local copy and restores the older replica. This violates the promise even with no moves and no other box. |
| + |
| +**Fix:** For the first release, explicitly refuse old records carrying `Seed`, and refuse requests combining restore with `from` or `import`. Alternatively, design a narrowly bound transfer of the old seed's data identity that preserves the latest local file without rerunning the seed or weakening foreign-marker protection. That alternative changes the wake path and needs the corresponding census/review scope; it is not a console-only implementation detail. |
| + |
| +**Fault family:** Local data identity across a new record incarnation. |
| + |
| +## P2 |
| + |
| +### 4. A committed retirement is not necessarily evidence that N1 tombstoned the captured body |
| + |
| +**Section:** §4 item 6 and §5.1 (design lines 57 and 67). |
| + |
| +**Problem and evidence:** The ETag argument is correct for N1 itself (`internal/console/lifetimes_retire.go:317`), but the dispatcher also commits after finding the slot already retired (`:266`), retires a normal row whose record is absent (`:288`), and converts a normal retirement into cleanup when it observes corrupt bytes (`:294`). Conversion replaces the captured ETag (`internal/console/lifetimes_store.go:265`). Cleanup and orphan retirements also commit without N1. The existing absent-record witness confirms this is intentional behavior (`internal/console/lifetimes_retire_test.go:511`). |
| + |
| +**Failure scenario:** A valid body is captured at `BeginRetirement`, but recovery takes one of those other paths. With only the proposed non-null body and `state=committed` checks, restore treats a pre-retirement observation as proof of the exact last record. In particular, preserving the original body through conversion would divorce it from the retirement's updated ETag. The spec supplies no eligibility rule for these cases. |
| + |
| +**Fix:** Define explicit restore evidence for a successfully tombstoned normal retirement, including recovery after a lost N1 response. Make orphan, cleanup, converted, and otherwise unproven outcomes ineligible; never search backward for an older usable body. Capture and persist the evidence in the shared retirement protocol, so delete, seed/import cleanup, purge and recovery have the same rule. Missing SQLite rows must fail the slot/incarnation match rather than permit fallback. |
| + |
| +**Fault family:** Binding restore-region authority to the record actually retired. |
| + |
| +### 5. Counting currently eligible boxes is not a proof of local-file freshness |
| + |
| +**Section:** §5.3's deferred decision and fallback (design line 81). |
| + |
| +**Problem and evidence:** Plain platform records are scoped by region and pool, not pinned to their last serving box (`internal/provision/reconcile.go:524`, `:549`). The assignment reconciliation leaves an unlabelled row untouched (`internal/activator/startrule.go:175`), and an existing warm file wins without comparison to the replica (`internal/activator/backend_exec.go:991`). The offline landing park cited by the spec is a particular move participant's action (`internal/host/movesoffline_land.go:550`, `:573`), not a general check of every disk in a region. |
| + |
| +**Failure scenario:** A region has two eligible plain-instance boxes. A holds an older local copy; B subsequently serves and replicates newer data. B is removed from service before restore. There is now only one eligible box, A, so the suggested “refuse when more than one box could serve” fallback does not reject it. A's old file still wins over the newer regional replica. |
| + |
| +**Fix:** Decide the required freshness evidence in the spec. A safe gate must establish which local copies the restored record can read and why each is current, including prior roster changes; current box count alone is insufficient. Refuse when that cannot be established, or define a durable, fenced park/restore protocol before admitting the record. The builder may work out mechanics after that decision, but the current fallback cannot serve as its safety rule. |
| + |
| +**Fault family:** Local-file freshness across serving-box changes. |
| + |
| +### 6. Ownership must precede detailed region and staging refusals |
| + |
| +**Section:** §3's check order and §6 R3–R8 (design lines 34–38 and 89–95). |
| + |
| +**Problem and evidence:** The spec puts ownership proof at the mark step while region selection and the leftover rail occur earlier. The current rail returns its response before entering lifetime creation (`internal/console/apiinstances.go:2295`, `:2313`); `markForCreate` runs later inside the locked lifetime protocol (`internal/console/lifetimes_create.go:142`). R5 exposes the saved region, and R6 confirms a move copy and its region. The promise that another owner gets S1 does not specify how those earlier answers are suppressed. |
| + |
| +**Failure scenario:** A caller tries a syntactically valid host formerly belonging to another app, supplying a different region. Following the stated order returns R5 from that app's retirement body before the late ownership proof can return S1. The analogous home-region case can return R6 from the staging check. |
| + |
| +**Fix:** Specify that ownership/lineage authorization dominates every history-dependent detailed refusal. Compute region privately until that check passes; revalidate the evidence under the app and hostname locks used for creation. Unknown/foreign ownership must retain S1. Keep C2 dependent on the complete proof, as already stated. Add wrong-owner cases with conflicting region, staging, missing body and earlier app lifetime, asserting the same generic response. |
| + |
| +**Fault family:** Concealment of another app's hostname history. |
| + |
| +### 7. The synchronous `restored` boolean has no defined source of truth |
| + |
| +**Section:** §3's response contract (design line 44). |
| + |
| +**Problem and evidence:** Create returns after writing the record and bumping the serial; it does not wait for a wake (`internal/console/apiinstances.go:2590`, `:2603`). A warm file is observable only on the box (`internal/activator/backend_exec.go:991`), and the console cannot inspect a foreign region's data bucket (`internal/console/apidb.go:40`). No proposed field or protocol reports whether wake used data or booted fresh. |
| + |
| +**Failure scenario:** An empty home replica listing can mean either “no data exists” or “the box still holds the only warm copy.” The create response cannot distinguish them. Returning false on the listing misreports the second case; returning true merely because retirement evidence exists misreports the first. A later failed wake also cannot substantiate a claim that data was restored. |
| + |
| +**Fix:** Define the create response as acceptance of a restore request, and expose the eventual restored/fresh result through existing instance status with evidence bound to the new incarnation. Alternatively, explicitly add and bound a box-side check/wake before answering. Preserve the accepted policy that proven absence may boot fresh; do not equate an unavailable observation with absence. |
| + |
| +**Fault family:** Truthful reporting of data restoration. |
| + |
| +**NOT READY** |