spec #658: Astra round 2 findings (NOT READY)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+68
−0
docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R2.md+68 −0
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R2.md b/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R2.md| new file mode 100644 |
| index 000000000..f2235e426 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-instance-restore-658-R2.md |
| @@ -0,0 +1,68 @@ |
| +# Instance restore #658 — round 2 findings |
| + |
| +Reviewed rev 3 at `aa5f30048bda6bcb807a2bbc37ade5330f04e706`. The brief names `b3da0bf982b36bba20034d26a03b6c5dc75afdf1`; the design is unchanged between those commits. Read both authority specs and checked the implementation in this checkout, whose diff against `origin/main` contains only the four instance-restore documents. No unmerged implementation was used. No subagents or test suites were run. |
| + |
| +## Round 1 dispositions |
| + |
| +1. **P1 provenance — partly resolved.** Checking every recorded allocation closes the recorded earlier-lifetime case, but the timestamp is not activation evidence and an allocation history can be empty. Carried forward as P1 findings 1 and 2 below. |
| +2. **P1 staging — resolved.** §3 item 3 now requires an error-free, whole-prefix listing of `moves/<host>/` in the console's own region. This matches `MovesPrefix` and the promotion boundary (`internal/activator/backend_exec.go:3800`, `:3849`, `:3862`), including a lone `build-state.json`. The finished-move cleanup defect remains #661, not a new finding here. |
| +3. **P1 seeds — resolved.** §2 and §4 item 6 exclude seeded/imported predecessors and requests. They no longer admit the no-seed successor that purges a seed-marked warm database (`internal/activator/seedplace.go:273`, `:282`, `:290`). |
| +4. **P2 retirement evidence — resolved.** §5 distinguishes a proven normal tombstone from the other terminal outcomes. Numbered creates introduce the sequence (`internal/console/lifetimes_create.go:438`); migration does too (`internal/console/lifetimes_migrate.go:287`, `:338`). Subsequent writes preserve and advance it even without the enabling context (`internal/provision/record_sequence.go:161`, `:167`). N1 uses the captured ETag and advances that sequence (`internal/console/lifetimes_retire.go:317`, `:323`), so the proposed incarnation/sequence check supports recovery of a lost N1 response. The evidence must be persisted before its tombstone is removed, as §5 requires. |
| +5. **P2 local-file freshness — resolved by the accepted scope.** For the admitted unseeded, unlabelled plain shape, the same region/pool selects the same boxes (`internal/provision/reconcile.go:524`, `:549`), and the same warm-file/replica selection applies (`internal/activator/backend_exec.go:985`, `:991`, `:1031`). No additional sibling-box freshness guarantee is required by this review. |
| +6. **P2 refusal order — resolved for the reported disclosure.** §3 item 1 puts the first authorization check before the region, staging and holder checks, and requires a second evaluation under creation's locks. The existing checks before that insertion point concern the authenticated app or supplied syntax (`internal/console/apiinstances.go:1525`, `:1549`, `:1561`, `:1622`, `:1662`). A separate ambiguity about which failures may receive detailed responses is P2 finding 3 below. |
| +7. **P2 response boolean — resolved.** §3 reports acceptance with `restore: true`, consistent with the response being sent after record publication rather than a verified wake (`internal/console/apiinstances.go:2593`, `:2603`). |
| + |
| +## P1 |
| + |
| +### 1. `At > @mode.At` does not prove admission under the current activation |
| + |
| +**Section:** §4 item 2 and its provenance conclusion (`docs/superpowers/specs/2026-11-07-instance-restore-658-design.md:57`, `:63`). |
| + |
| +**Problem and evidence:** The assertion that only activation and invalidation change `@mode.At` is false. `admitManagedHistory` reads the active state, extends its fleet targets, assigns `st.At = time.Now().UTC()`, writes it and replaces the console's cached state (`internal/console/managedhistory.go:35`, `:52`, `:60`, `:68`). Both managed-fleet preparation and box enrollment call it (`internal/console/managedhistory.go:239`, `internal/console/managedenrol.go:107`). This happens without an inventory or reactivation and affects the global mode, including plain platform instances. |
| + |
| +There is also no durable ordering guarantee between a mark's timestamp and activation's timestamp. Both are wall-clock values serialized into separate objects: `markHost` uses `time.Now().UTC()` (`internal/console/hostsused.go:613`), and activation independently samples it before writing its marks and active state (`internal/console/hostsused_activate.go:441`, `:468`). Neither write validates clock progression. Inventory preserves an existing mark on conflict (`internal/provision/hostsused.go:82`), while an incomplete-mode create accepts a conflicting mark (`internal/console/hostsused.go:621`). |
| + |
| +**Failure scenarios:** |
| + |
| +- With an ordinary advancing clock, activate, create and delete an eligible plain instance, then prepare or enroll an unrelated managed fleet. The mark now predates `@mode.At`; restore is refused even though the hostname was first marked under the still-current activation. Creating another managed box can withdraw restore eligibility across the deployment. |
| +- With a backward clock correction, the round-1 cross-owner case still passes. Q leaves an untracked warm database at H. Before activation, P creates H without waking it, writing a `create` mark and an allocation for P's current lifetime at clock value 110. The clock is corrected; activation inventories Q's file at value 100 but preserves P's existing mark. P deletes after restore ships. The proposed comparison accepts `110 > 100`; every allocation names P and the new retirement is restorable. Restore can read Q's warm database (`internal/activator/backend_exec.go:991`). The rule has admitted exactly the pre-activation lineage it promises to refuse. |
| + |
| +The ordinary first-box enrollment path preserves `At` by copying the state (`internal/console/hostsused.go:414`, `:426`), and group-member coverage writes no mode (`:263`, `:289`). Those paths do not fix the managed writer or turn the timestamps into a causal ordering. |
| + |
| +**Concrete fix:** Use durable activation identity, recorded on a mark only when its first create is admitted under that active identity. Preserve it through fleet enrollment; change it on reactivation; refuse marks lacking that evidence. Do not substitute the mode object's ETag, which also changes during fleet enrollment. Cover clock rollback, managed preparation/enrollment, and invalidation/reactivation in the guard witnesses. This needs the stopping-rule decision below, not another timestamp adjustment. |
| + |
| +**Fault family:** Hostname data provenance across owners and app lifetimes — the same family as round 1 P1 finding 1. |
| + |
| +### 2. An empty allocation history authorizes a different app lifetime |
| + |
| +**Section:** §4 items 1–3 and §5 (`docs/superpowers/specs/2026-11-07-instance-restore-658-design.md:56`, `:58`, `:67`). |
| + |
| +**Problem and evidence:** “Every allocation names A, P and L” supplies no evidence when there are no allocations. Current activation does not require lifetimes to be on: it rejects claims/moves and pending rows, but does not check the lifetime cutover (`internal/console/hostsused_activate.go:324`, `:334`). The create door can therefore take its lifetimes-off path after history activation (`internal/console/apiinstances.go:2509`, `:2516`). That path writes a `Source: create` mark and a record, without `BeginAllocation` (`internal/console/hostsused.go:668`, `:709`, `:717`). |
| + |
| +Later migration creates a `record_migrations` intent and a numbered slot, not a `host_allocations` row or an app-lifetime binding (`internal/console/lifetimes_migrate.go:139`, `:314`, `:338`). Normal deletion lazily migrates such a record if necessary, then retires it (`internal/console/lifetimes_retire.go:142`, `:171`). The proposed retirement evidence stores its body, but neither that body nor the retirement schema proposed in §5 carries the original app lifetime. |
| + |
| +**Failure scenario:** Activate the history while lifetimes are off. App P in lifetime L1 creates H, writes data, and receives a post-activation create mark. Turn lifetimes on. After restore ships, delete H normally; migration and N1 produce a retired slot and a restorable retirement. Purge P and recreate the same app name as L2 (`internal/console/lifetimes_store.go:387`, `:401`). H has no current record or pending intent, so the purge's inventory does not supersede its completed retirement (`internal/console/lifetimes_purge.go:49`, `:53`, `:57`). A restore by L2 passes every stated condition: the mark and retirement name the same account/app, the slot matches, and there are no non-void allocations contradicting L2. L2 receives L1's data. |
| + |
| +**Concrete fix:** Require positive evidence binding the original data-bearing create and the retired incarnation to the current app lifetime, as well as rejecting any conflicting lineage. For the narrow release, refuse a migrated/no-allocation predecessor rather than treating an empty query as authorization. A matching committed allocation for the retired incarnation must be established, and the first data-bearing create's lifetime must be accounted for. Add the post-activation legacy-create → cutover → delete → app-purge/recreate witness. Merely requiring `lifetimesOn()` at restore time does not close it. |
| + |
| +**Fault family:** Hostname data provenance across owners and app lifetimes — the same family as round 1 P1 finding 1. |
| + |
| +## P2 |
| + |
| +### 3. The ownership-first rule suppresses several promised eligibility refusals |
| + |
| +**Section:** §3 item 1, §4 and §7 (`docs/superpowers/specs/2026-11-07-instance-restore-658-design.md:38`, `:56`, `:58`, `:60`, `:61`, `:85`). |
| + |
| +**Problem and evidence:** §3 says to evaluate the §4 proof and return S1 for any failure other than an unreadable source; only a passing proof may receive R4–R8. But §4 includes the very conditions that produce R2, R4, R7 and R8: mode, app lifetime, mark age, restorable evidence and plain shape. Consequently those refusals cannot be reached by following the stated first evaluation. R5 and R6 are separate later checks and do not have this contradiction. §8 nevertheless requires witnesses for all these responses (`docs/superpowers/specs/2026-11-07-instance-restore-658-design.md:101`). |
| + |
| +**Failure scenario:** The rightful account/app asks to restore its seeded predecessor or an instance with no restorable retirement evidence. The first full proof fails and returns S1, while §7 promises R7 or R8. A builder must choose between two conflicting contracts; another could return a detailed eligibility error before checking all ownership evidence and reopen round 1's disclosure. |
| + |
| +**Concrete fix:** Distinguish account/app ownership authorization from restore eligibility. Specify exactly which ownership evidence must pass before any detailed refusal, then evaluate mode, activation provenance, app lifetime, retirement eligibility, shape, region and staging with the intended responses. Revalidate both stages under the existing creation locks. Keep unknown or foreign ownership at S1 and keep C2 dependent on full eligibility. Add paired rightful-owner/foreign-owner cases for each detailed refusal. |
| + |
| +**Fault family:** Refusal precedence at the ownership/eligibility boundary. The original round-1 P2 finding 6's late-authorization placement is fixed; this is the new response-contract ambiguity in that fix. |
| + |
| +## Stopping-rule decision |
| + |
| +Round 1 had three P1s; round 2 closes staging and seed identity but again finds P1s in the hostname-provenance family. AGENTS.md stopping rule 2 applies: do not start a third incremental fix in that family. The choices are to refuse ambiguous existing lineages with a pre-admission gate and operator report; cut/defer restore; or establish the activation-and-original-app-lifetime invariant in one place with guard tests or a randomized simulation. Recommend the narrow refusal gate, using explicit provenance for newly eligible creates rather than reconstructing it from timestamps or an empty allocation history. No spec or implementation fixes were made in this review. |
| + |
| +**NOT READY** |