carlos / platform Public

plan #658: Astra plan round 3 findings (NOT READY)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 0cd5df8d6ac49491ba58b1e910144233c53e431d parent 769a26f
1 file changed, +59 −0
  • docs/superpowers/plans/CODEX-FINDINGS-instance-restore-658-plan-R3.md +59 −0

CI passed — run details

diff --git a/docs/superpowers/plans/CODEX-FINDINGS-instance-restore-658-plan-R3.md b/docs/superpowers/plans/CODEX-FINDINGS-instance-restore-658-plan-R3.md
new file mode 100644
index 000000000..44c66b83f
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-FINDINGS-instance-restore-658-plan-R3.md
@@ -0,0 +1,59 @@
+# Instance restore #658: implementation-plan review, round 3
+
+1. **R2 P1-1 — partly resolved.** Table rows 3 and 4 now put pending work before duplicates, and Task 5 covers the three pending-retirement states. Existing gates outside `restoreProof` can still return first between evaluations; carried forward as P1-1 below.
+2. **R2 P1-2 — resolved.** Task 7's independent oracle includes the current mode and requires R2 after invalidation, with a deterministic invalidation/reactivation trace (plan:201).
+3. **R2 P2-3 — resolved.** Placement and pool are explicit inputs, the region block retains validation, the placement fixture uses the store setter, and the deciding proof is outside the `DataKind()` conditional (plan:160, :181, :185, :187).
+4. **R2 P2-4 — resolved as to reduced-priority execution in CI.** Task 7 now launches a niced child and preserves its failure. The new launcher's priority assertion and missing short-mode propagation introduce the separate defects below (plan:202).
+5. **R2 P2-5 — resolved.** `NewestRetirement` adds descending `rowid`, with equal-incarnation/equal-timestamp tests in both insertion orders (plan:94, :98).
+
+Reviewed `design-instance-restore-658` at `f663b1e9a94ac93f0d80968dc042ff161f5f4981`. The brief names `aede9e3389721f2244bea8f88c5fb04f9f793f04`; only the brief's commit reference differs. **plan** below means `docs/superpowers/plans/2026-11-08-instance-restore-658.md`; **spec** means the approved rev 5 `docs/superpowers/specs/2026-11-07-instance-restore-658-design.md`.
+
+Amadan's main was verified read-only at `c0a65b0e36d101f5e5e93042e34384a4af1e408b`. The create, retirement, history, activation, replica-request and CI code cited below is identical there and in this checkout. The branch changes only design, plan and review documents relative to its merge base. No subagents or Go test suites were run. A short, file-free Linux priority probe checked the scheduling assertion. Only this findings file was written.
+
+## P1
+
+### 1. Existing admission and duplicate gates can return before the deciding proof
+
+**Tasks:** 5 and 6. **Fault family / invariant:** restore response precedence, carried from rounds 1 and 2. The admission table must decide the response again under the create locks, including pending work that appears after the advisory evaluation.
+
+**Problem and evidence:** Task 6 puts the second proof immediately before the mark block (`plan:173`, `plan:181`). That block is at `internal/console/lifetimes_create.go:138`. Before reaching it, the core calls `s.admit` at `:99` and `planCreateLocked` at `:103`. `admit` returns `errLifetimeSettling` for pending work (`internal/console/lifetimes.go:224`), which becomes the existing 409 response at `:143`, not table row 3's R1/503 (`plan:35`). `planCreateLocked` also returns its duplicate result before the proposed proof (`internal/console/lifetimes_create.go:213`).
+
+The handler has another earlier duplicate return: `leftoverReplicaRefusal` calls `exists` and returns `c.duplicate` before its prefix checks (`internal/console/createleftovers.go:151`, `:156`). Task 6 only skips the `instances/<host>` test for restore (`plan:187`); it does not route that existing-record decision through the admission table.
+
+**Failure scenario:** Restore A passes the early proof over an eligible retired host and pauses before acquiring the create locks. Restore B begins an allocation for the same host, but its slot write fails, leaving a pending row and no record (`internal/console/lifetimes_create.go:146`, `:151`, `:328`). A resumes. Its leftover record check sees no record, then the core's `admit` returns 409 before the second proof can answer R1/503. The corrected table and its direct unit tests do not prevent this real-door result.
+
+There is also the original pending-before-N1 case between evaluations: B completes its restore, then deletion starts and N1 fails before landing. A's leftover record check can return `already exists` while retirement is pending, again bypassing the table. The existing `pendingRetire("begin")` fixture establishes that record-plus-pending state (`internal/console/lifetimes_retire_test.go:707`, `:715`).
+
+**Concrete fix:** Specify the restore path through these earlier gates. Run the deciding proof under the app/hostname locks before the existing pending/duplicate decisions or cleanup in `planCreateLocked`, then carry its eligible verdict to the mark step within that hold. Ensure the leftover rail cannot independently return a restore duplicate before that proof checks pending work. Preserve ordinary-create behavior. Add paused real-door witnesses for both traces above, asserting the R1 status and body and no allocation by A. Keep the completed-restore retry witness.
+
+### 2. The Linux priority assertion rejects the prescribed local run
+
+**Task:** 7, Steps 2b and 3. **Fault family / invariant:** simulation launcher correctness. The guard must run successfully at reduced priority and verify the scheduling property it claims.
+
+**Problem and evidence:** Step 2b obtains priority with `syscall.Getpriority` and requires a value of at least 10 (`plan:202`). On Linux, Go returns the raw syscall value, `20 - nice`, rather than the conventional nice value. The installed toolchain passes the result through unchanged at `/home/paulca/.local/go-dist/src/syscall/zsyscall_linux_amd64.go:516` and `:518`.
+
+Step 3 explicitly runs the parent with `nice go test` (`plan:203`); Step 2b adds another `nice -n 10` for the child. Starting at nice 0, the child reaches nice 19 and `syscall.Getpriority` returns 1. The planned lower-bound assertion fails before the simulation runs. Conversely, a non-niced process returns 20 and satisfies that assertion. A file-free probe on this machine confirmed `(nice, raw)` values `(0, 20)`, `(10, 10)` and `(19, 1)`.
+
+**Concrete fix:** Normalize the Linux result with `niceValue := 20 - raw` after checking the syscall error, then require `niceValue >= 10`. Keep platform-specific code in an appropriate helper. Verify both a normal parent and the already-niced parent required by Step 3; both children must pass, while a deliberately non-niced child must fail the priority check.
+
+## P2
+
+### 3. Re-executing the simulation drops the short-test bound
+
+**Task:** 7, Step 2b. **Fault family / invariant:** simulation execution budget. A short run must retain its stated 50-seed, 30-step limit across the child-process boundary.
+
+**Problem and evidence:** Step 2 specifies 50 × 30 for `-short` and 200 × 40 otherwise (`plan:201`). The child command contains only `-test.run` and `-test.v` (`plan:202`). Go test flags are process arguments; the new process does not inherit the parent's `-test.short` value.
+
+**Failure scenario:** A developer runs `go test -short` for this test. The parent starts the specified child, whose `testing.Short()` is false, so it executes the full simulation despite the requested bound.
+
+**Concrete fix:** Forward `-test.short=true` when `testing.Short()` is true. Make the selected seed/step counts observable in the child output so the parent/child path can be checked in both modes. Also give the child an explicit timeout or parent-controlled deadline, rather than relying on the parent's test flags to propagate.
+
+## P3
+
+None.
+
+Task 4 now captures the candidate from the observation bound to `RecordETag`, excludes both nil-body cases, persists evidence before advancing or deleting the tombstone, and clears evidence atomically on cleanup conversion (`plan:133` through `:139`). Its hooks fit the existing retirement dispatcher. The fixed Q/P trace has a usable timestamp wrapper and asserts the surviving P mark and absent origin; the simulation's revised oracle removes round 2's incorrect unconditional success requirement. These resolve the earlier findings in those areas.
+
+This is round 3 of 3. The two P1s have different causes: a deciding proof placed after competing gates, and an inverted interpretation of Linux priority. Refusing pending work up front under the create locks through the existing admission table removes P1-1 without adding a new product restriction. Cutting restore would remove that race, but restricting supported shapes would not; neither addresses P1-2 while the launcher remains. P1-2 needs the local test-launcher correction. No fourth review round is authorized by this review.
+
+**NOT READY**