carlos / platform Public

Astra round 2 on region HA without claims rev 3: findings and brief, unedited

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 8e144c82d593a9be33043f4313796937f91b7c68 parent 1c3599a
2 files changed, +90 −0
  • docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r2.sh +3 −0
  • docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r2.md +87 −0

CI failed — run details

diff --git a/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r2.sh b/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r2.sh
new file mode 100755
index 000000000..66306082f
--- /dev/null
+++ b/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r2.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+cd /home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims
+exec nice -n 10 codex exec -s read-only -c 'sandbox_permissions=["disk-full-read-access"]' --add-dir "$HOME/.cache/go-build" -c model_reasoning_effort="high" -o /home/paulca/.cache/tmp/claude-1001/rha-nc/findings2.md "ROUND 2. Review rev 3 of docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md at 1c3599a3 on branch design-region-ha-no-claims, against the code at that commit (read AGENTS.md). Read-only; leave GOCACHE unset. Your round-1 findings are docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md; the spec carries a disposition table. FIRST give a disposition table of your round-1 findings (closed / partly / open, one line each), THEN only NEW findings. Paul has since added rulings N-HA4 (N-box moves and seed import join this series, gating flagship retirement) and N-HA5 (files sync 10 s app files, ~1 s for the H6 trio): fixed, do not re-argue. The central rev-2 change is a release marker written into lock.json at graceful release; verify it against the pinned litestream leaser and every lease reader. Also check the new §14 moves/seed design and the A22 S3-loss health rule (no churn on a regional S3 outage). Context: host lifecycle claims are shelved and being deleted (plan docs/superpowers/plans/2026-10-25-claims-cleanup.md on origin/design-live-moves-ha). Paul wants same-region HA without claims: a region's NLB keeps serving when one box (of N>=2) is killed; failover in a few minutes, lower is better; the Litestream S3 lease (internal/lease) is the only single-writer guard. Paul's rulings in the spec's rulings section (H1, H3-H6, H20-H22, H24, N-HA1..3) are FIXED: do not re-argue them, report only mechanisms that fail to honour them. Author's calls A1-A20 are open to challenge. Constraints: no new per-box S3 polling beyond what the spec budgets (S3 requests cost money), provider-neutral core with AWS as adapters, prefer a scope cut or an up-front refusal over machinery. Hunt with file:line evidence for: (1) any path where two boxes can both write the same instance DB or files (lease takeover CAS, owner-string parsing, frozen/hung box resuming after takeover, the write fence, same-box self-takeover A16, agent crash, clock skew vs SafeUntil); (2) any path where a box serves a stale local DB or stale files (the A2 freshness rule vs Litestream's actual replica layout at the pinned version; local-ahead copies; restore races); (3) forwarding loops, black holes, or a request served by a non-holder; concurrent cold wakes; (4) whether takeover after termination really meets a few minutes, and that a hung box is never taken over before termination; (5) LB health latch correctness at boot, drain and partial failure; (6) everything an instance runs that would run on more than one box (workers, schedule ticks, named units, sidecars, websockets, scheduled wakes, email, static sites, edge asset cache, rootfs apps) and whether the spec's A10 assignment is complete; (7) the old-box retirement sequence (N-HA2) and rollback; (8) the R3 keep/delete list against the real code and the claims-cleanup plan; (9) request budgets: are the numbers right; (10) interactions with offline moves, nearest-region #199 (see origin/design-nearest-region-199 spec docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md which also touches backend_exec.go:819), db pull/query --at and the change index #336. Output: first line READY FOR PLAN | READY WITH CHANGES | NOT READY, then numbered findings (P1 data loss, split writer, outage; P2 wrong or missing; P3 clarity), each with evidence and a concrete fix. This is round 2 of at most 3: prefer a scope cut or refusal over new machinery." </dev/null > /home/paulca/.cache/tmp/claude-1001/rha-nc/astra2.log 2>&1
diff --git a/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r2.md b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r2.md
new file mode 100644
index 000000000..b2af96609
--- /dev/null
+++ b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r2.md
@@ -0,0 +1,87 @@
+NOT READY
+
+| Round-1 finding | Disposition | Rev-3 assessment |
+|---|---|---|
+| 1. Missing checksum proof | **Closed** | Checksum reuse is removed. The release-marker JSON is compatible with the pinned Litestream decoder; epoch expiry is recognized by `LockState` and `leaseFree`. |
+| 2. Cross-box takeover on expiry | **Closed** | §9.4 requires release or confirmed termination for another box; §9.7 supplies the relative clock-skew bound. |
+| 3. Unsafe same-box recovery | **Partly** | §9.6 delays recovery until expiry but still permits it without stopping surviving nested/rootfs units. TTL does not establish emptiness: `internal/activator/opset.go:437–453`, `internal/host/agent.go:592–598`. Refuse recovery until that proof exists. |
+| 4. Files marker proves too little | **Partly** | Metadata verification and clean-tree restore address stale copies, but “successful publish” still permits skipped/unreadable files: `internal/hostfiles/sync.go:126–175`, `restore.go:165–168`. Reject incomplete publication for clean markers and retirement readiness. |
+| 5. Approximately one-second DB loss | **Partly** | Stream capture is corrected; §5.5 still admits five-minute/daily classes under HA. Those do not meet the fixed H3 window; refuse incompatible classes where H3 applies. |
+| 6. Key/token producers | **Closed** | §7.3 names the missing producers, moves preparation behind restore and ownership, and requires durable initial publication. H6 exceptions are explicit. |
+| 7. HRW strands once-timers | **Closed** | Duties now follow the holder/releaser, and once-timer deadlines enter wake state. |
+| 8. Due-wake transfer loses triggers | **Partly** | Acknowledged transfer fixes deletion ordering. But a newly sleeping host can die before its first batched duty-file publication; §7.4’s “first acquire” then has no trigger. Publish discovery before relinquishing responsibility, or recover omitted hosts during failure handling. |
+| 9. Failover timeline omissions | **Partly** | Holder backoffs are cancelled. The eight-minute grace still protects a box that has already served and then hangs (§10); describing the exception does not meet the few-minute bound. Remove that serving-time grace exposure. |
+| 10. Forwarded takeover | **Closed** | §6.4 permits local authorized takeover, and `view(region)` resolves cross-region holder validation. |
+| 11. Named-unit adoption | **Closed** | §6.1 explicitly excludes Unit, platform and non-hibernating socket routes from serving boxes. |
+| 12. Unsafe offline-move relaxation | **Partly** | S3-only sealing fixes stale source selection; §14 introduces the new blockers below. |
+| 13. Rollback to terminated box | **Closed** | §13 retains the stopped box through acceptance. |
+| 14. Recreated hostname reuses old data | **Closed** | Lifetime-bound reuse plus the expanded S3-leftover refusal addresses the reported path. |
+| 15. Backfill reacquires held lease | **Closed** | §8.4 uses the existing live handle and records publication success. |
+| 16. Request budget | **Partly** | Pagination and reader amplification are included. Transfer totals omit the edges deletion’s change-index GET+PUT, plus CAS retries (`internal/release/changeindex.go:108–150`). Rebudget mutations as well as readers. |
+| 17. Placement and drain | **Partly** | Drain’s headroom refusal is removed. §6.3 still chooses any eligible HRW box before the roomiest box, contrary to H4; use `ChooseRoomiest` for new placement and reserve affinity for proven reuse. |
+
+1. **P1 — A failed release-marker PUT does not reach the claimed retry path.**
+
+ [Spec:159](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:159) relies on the existing owed-release mechanism. That mechanism belongs to `Held.Release`, not `Replicator.Close`: [lease.go:497](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/lease/lease.go:497) returns the release error, and [activator.go:4401](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/activator/activator.go:4401) logs it and forgets the entry. Furthermore, `RetryRelease` retires failed obligations after expiry (`lease.go:341–350`), when HA peers still cannot acquire.
+
+ **Fix:** explicitly carry failed marker writes from replicator shutdown into the retry queue, retaining the exact marker and ETag. Expiry must not discharge that obligation. Witness a failed release PUT followed by restored S3 access and acquisition by another box.
+
+2. **P1 — A22 can terminate a box during a regional S3 outage.**
+
+ [Spec:382–388](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:382) accepts a peer’s success from the preceding two minutes. Counterexample: A has been isolated from S3 for three minutes; B successfully accessed both buckets thirty seconds ago; now S3 fails region-wide. B’s private listener still answers with qualifying historical successes, so A becomes unhealthy during the shared outage.
+
+ The “no other unhealthy box” check also lacks an atomic decision: two failing boxes can sample peers before either changes state. “Lower reference goes first” does not specify how both discover the contenders.
+
+ **Fix:** cut automatic S3-triggered replacement from this release and retain the alarm/manual termination path. Keep H20’s local hung-process health checks. Reintroduce A22 only with a precisely bounded decision protocol and staggered-outage witnesses; simultaneous outage tests alone miss this case.
+
+3. **P1 — Consuming the staging marker before promotion loses crash-recovery state.**
+
+ [Spec:365](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:365) replaces the staging marker with a normal lease, then [§14.2](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:544) promotes. A landing box can die between those operations or halfway through the mirror. The successor sees an ordinary dead-owner lease, without proof that the destination replica is complete.
+
+ Retaining today’s unconditional staging fallback creates another failure: [backend_exec.go:3509–3529](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/activator/backend_exec.go:3509) promotes any remaining staging objects as an exact mirror, while deletion errors are ignored at `:3555`. A later HA restore can replay partial old staging over newer committed data.
+
+ **Fix:** retain the pending move and sealed source identity durably through acquisition and renewal until promotion is verified complete. After completion, staging leftovers must never authorize another promotion. Cover crashes before promotion, during copying, and during staging cleanup.
+
+4. **P1 — View expiry is insufficient authority to replace a stager.**
+
+ [Spec:540](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:540) reselects the stager when it leaves the view. That can mean a paused or partitioned process, not termination. The old stager can resume copying or deleting after its replacement completes staging, after rollback, or during landing.
+
+ The existing implementation deliberately pins the stager and requires its stopped acknowledgement: [movesoffline_stage.go:59–80](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/host/movesoffline_stage.go:59), `:222–228`. Copy idempotence does not make delayed writes safe across those phase changes.
+
+ **Fix:** retain the pin. Replace a stager only after an acknowledged stop or confirmed termination; otherwise refuse to advance. No additional periodic S3 polling is needed.
+
+5. **P1 — §14.4 describes database replacement, not the existing seed-import operation.**
+
+ [Spec:570–576](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:570) assumes an existing leased instance with a replica and manifest to save under `previous/`. Actual import replaces an **unprovisioned address route** identified by `Replaces`; hibernating and provisioned routes are explicitly refused: [seedswap.go:28–53](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/provision/seedswap.go:28).
+
+ Rollback needs the original route and environment provenance, stored today in [ImportJournal](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/registry/importjournal.go:45). Neither is reconstructed by restoring a previous replica, which may not exist.
+
+ **Fix:** specify region-wide replacement and rollback of the legacy route, including its ownership checks, verification gate and `EnvBefore` state. Persist those before exposing the imported route. Refuse unsupported legacy layouts up front; keep N-HA4’s retirement gate until the actual import contract works.
+
+6. **P1 — The proposed target security-group rules block public NLB traffic.**
+
+ [Spec:448–449](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:448) preserves client IPs but permits target ports 80/443 only from the VPC CIDR. Internet client addresses are outside that CIDR. Health checks can pass while public requests fail. Today’s module permits public 80/443 traffic at [main.tf:97–107](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/infra/modules/region-host/main.tf:97).
+
+ **Fix:** give the NLB a security group and allow its security-group identity on the targets’ traffic and health ports; separately preserve the required cross-region backhaul ingress. AWS documents this configuration at [https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-register-targets.html](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-register-targets.html). Verify from outside the VPC.
+
+7. **P2 — The source stager lacks permission to write the destination marker.**
+
+ [Spec:544](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:544) assigns the destination `instances/<host>/lock.json` write to the source-region stager. Its sibling-bucket permissions allow writes only under `moves/*`, and listing only that prefix: [main.tf:238–247](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/infra/modules/region-host/main.tf:238). §12.2 adds no relevant authority.
+
+ **Fix:** have a destination-region actor validate the completed staging and conditionally write its own lock. Keep the source’s existing push-only permissions rather than granting access to sibling live replicas.
+
+8. **P2 — Mixed HA/non-HA moves have incompatible files and timer formats.**
+
+ [Spec:520](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:520) promises unchanged non-HA processing on that side of a mixed move. But non-HA sources produce an encrypted archive and separate timer snapshot, not the new files manifest: [movesoffline_seal.go:716–767](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/host/movesoffline_seal.go:716). Non-HA targets require that archive and snapshot: [movesoffline_land.go:812](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/internal/host/movesoffline_land.go:812), `:1071`.
+
+ Neither direction has a defined conversion. A copied `hostfiles` manifest also contains bucket-root-qualified object keys, not staging-relative names (`internal/hostfiles/manifest.go:26–32`).
+
+ **Fix:** define one explicit transport conversion in each supported direction, including keys, platform files and timers. Until implemented, refuse mixed-mode moves before stopping anything.
+
+9. **P2 — The required cleanup dependency no longer matches the referenced cleanup plan.**
+
+ [Spec:616 and :671](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-no-claims/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md:616) requires R3 before P1 and relies elsewhere on R4a/R6 deletions. On the requested `origin/design-live-moves-ha`, `docs/superpowers/plans/2026-10-25-claims-cleanup.md:37–39` explicitly stops that deletion series after R0/R1/R2/T1 and retains HA 2a/2b.
+
+ **Fix:** make the necessary removals explicit tasks owned by this HA series. Do not depend on parked cleanup rows landing independently; preserve the live helpers and claims-off witnesses listed in the inventory.
+
+Reviewed against `1c3599a3`. No files changed, tests or live drills run, or processes started. `GOCACHE` remained unset.
\ No newline at end of file