Astra round 1 on region HA without claims rev 1: findings and brief, unedited
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+74
−0
docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r1.sh+3 −0docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md+71 −0
CI failed — run details
diff --git a/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r1.sh b/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r1.sh| new file mode 100755 |
| index 000000000..308b8a85d |
| --- /dev/null |
| +++ b/docs/superpowers/notes/reviews/ASTRA-BRIEF-region-ha-no-claims-r1.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/findings1.md "Review rev 1 of docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md at d316e3f1 on branch design-region-ha-no-claims, against the code at that commit (read AGENTS.md). Read-only; leave GOCACHE unset. 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 1 of at most 3." </dev/null > /home/paulca/.cache/tmp/claude-1001/rha-nc/astra1.log 2>&1 |
diff --git a/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md| new file mode 100644 |
| index 000000000..99bba6436 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md |
| @@ -0,0 +1,71 @@ |
| +NOT READY |
| + |
| +1. **P1 — A2’s checksum proof does not exist in the pinned Litestream version.** |
| + Spec lines 119–125 compare pre/post-apply database checksums. Litestream v0.5.14 writes `HeaderFlagNoChecksum` (`/home/paulca/go/pkg/mod/github.com/benbjohnson/litestream@v0.5.14/db.go:1946`, also `:2412`). LTX requires both database checksums to be zero in that mode (`/home/paulca/go/pkg/mod/github.com/superfly/ltx@v0.5.1/ltx.go:251`, `:355`). Thus different histories at the same transaction ID compare equal, and an unrelated local tail can pass the extension test. Separately, `DB.Open` refuses the proposed missing replica client (`litestream@v0.5.14/db.go:730`). |
| + **Fix:** cut the checksum-based reuse optimization from this release; restore whenever equality cannot actually be proved. Rebudget that path. Any later optimization needs witnesses using files produced by the pinned library, including divergent histories with equal transaction IDs. |
| + |
| +2. **P1 — Ordinary expiry bypasses “never take over a hung box before termination.”** |
| + Spec line 305 explicitly permits this. `AcquireTTL` delegates existing locks to Litestream (`internal/lease/lease.go:193`); its acquisition accepts an expired lock without checking termination (`litestream@v0.5.14/s3/leaser.go:96`). A stopped agent can therefore leave its app processes running while another box acquires. A11 fences replica uploads, not those processes’ local DB/files writes or established WebSocket handlers. Its acknowledged check-to-request pause also permits a delayed upload after ownership changes. |
| + **Fix:** for HA instance leases, expiry alone must not authorize cross-box acquisition: require confirmed termination or a completed graceful release. Refuse unsupported takeover cases up front. The existing five-second margin also needs an explicit **relative** clock-skew bound: two clocks each within ±4 seconds differ by eight seconds, exceeding it (`internal/lease/health.go:19`, `:53`). |
| + |
| +3. **P1 — A16 cites a proof that deliberately skips nested/rootfs instances.** |
| + Spec line 299 treats successful `wakeHostProven` as proof that the old writer is gone. That function returns success without checking `Backing=unit`, nested instances, or backends lacking `hostEmptier`; it also accepts missing cgroup delegation (`internal/activator/opset.go:437–453`). An agent restart can leave independently managed instance units running; startup cleanup is explicitly best-effort (`internal/host/agent.go:592–598`). Taking the lease and restoring underneath one is unsafe. |
| + **Fix:** initially refuse same-box takeover for these layouts, or require their actual unit/cgroup emptiness proof before takeover and restore. A different PID is not that proof. |
| + |
| +4. **P1 — The files marker does not prove local files equal the manifest.** |
| + Spec lines 232–234 keep a directory when `.files-gen` matches. After installing manifest M, an app can modify or create files and crash before publication; the marker still names M. The next wake keeps those unpublished changes. On the mismatch path, `hostfiles.Restore` explicitly preserves paths absent from the manifest (`internal/hostfiles/restore.go:42–47`) and skips unpublished entries (`:165–168`), so it does not produce the promised exact tree either. |
| + **Fix:** restore into a clean tree before startup, or verify the complete local tree against the manifest, removing unlisted paths and handling skipped entries explicitly. Do not use the marker alone as freshness evidence. |
| + |
| +5. **P1 — H3’s approximately one-second DB loss window is not implemented by the retained settings.** |
| + The local WAL monitor runs every ten seconds (`internal/lease/lease.go:96–104`, applied at `:406`). The replica’s one-second interval cannot upload changes not yet captured locally. Existing replication classes additionally permit five-minute and daily intervals (`internal/activator/activator.go:438–443`). Spec lines 11 and 505 nevertheless promise roughly one second. |
| + **Fix:** make the HA admission/readiness check reject incompatible replication classes and use a local capture cadence that meets H3. Measure committed-write loss in the terminate drill; distinguish local polling cost from S3 request cost. |
| + |
| +6. **P1 — The key/token ownership rule misses existing producers and H6’s app-directory exceptions.** |
| + Spec line 211 restricts minting to the lease holder, but the current schedule runner prepares its token **before** delivery/wake (`internal/schedule/runner.go:564–586`), calling `EnsureAdminToken` locally (`internal/host/schedule_wiring.go:186–205`). Its preparation fence grants no durable authority (`internal/activator/scheduled_token.go:3–6`). Instance-key backfill also runs independently after startup (`internal/host/instancekeys.go:14–27`, `:75–85`). Moreover, §8 classifies `instance.key` and `report.token` as app files, while only platform files are explicitly continuous on snapshot plans—contrary to H6. |
| + **Fix:** enumerate and change these producers. Prepare delivery credentials on the holder after restore; disable non-holder key backfill. Explicitly make all three H6 exceptions continuous, and durably publish newly minted keys before an app can depend on them. |
| + |
| +7. **P1 — HRW assignment can strand once-timers even without a failure.** |
| + Spec line 209 exports timers on sleep and imports them on wake. Suppose H runs on A but its HRW owner is B. H registers a once-timer in A’s registry; B never wakes H and therefore never imports the row. Hash-gating A prevents delivery, while B has nothing to deliver. Persisting the row in S3 does not give B a wake trigger. `ExportWake` includes timers separately from `NextDue` (`internal/hostfiles/wake.go:33–59`); no automatic equivalence exists. |
| + **Fix:** define delivery ownership and discoverability for app-registered timers, including while H remains awake. Publish their earliest outstanding deadline through the already-budgeted wake advertisement, then have the selected actor obtain the durable timer state before delivery; otherwise refuse that feature in HA. |
| + |
| +8. **P1 — Due-wake handoff can delete the only remaining trigger.** |
| + Spec lines 274–275 copy the dead box’s due entries into the confirmer’s **next** publication, then delete the original. If the confirmer dies before publication, every survivor loses the trigger. The representation also needs explicit handling for sidecars: the existing edges publisher excludes them entirely (`internal/host/edgesfile.go:481–500`), although their due wake is their only timer source (`internal/activator/activator.go:5032–5044`). |
| + **Fix:** acknowledge a durable publication of transferred wake metadata before deleting the source file. Carry non-routable duty metadata separately from served-host advertisements, and specify how consumed deadlines stop being resurrected by older copies. |
| + |
| +9. **P1 — The few-minute timeline omits normal delays introduced elsewhere in the design.** |
| + Spec line 206 makes an HRW owner that encounters a live holder wait until lease expiry. If that holder subsequently dies, nothing explicitly cancels the wait; the promised “one sweep after the event” at line 327 does not follow. Also, the proposed 15-minute ASG grace period can protect a newly serving but hung instance from replacement for most of that period. AWS documents that grace suppresses unhealthy replacement after `InService`. [https://docs.aws.amazon.com/autoscaling/ec2/userguide/health-check-grace-period.html](https://docs.aws.amazon.com/autoscaling/ec2/userguide/health-check-grace-period.html) |
| + **Fix:** invalidate duty backoffs when their holder disappears or termination is confirmed, without probing every lease periodically. Separate boot allowance from the advertised serving failure bound, and include a hang shortly after first healthy service in acceptance tests. |
| + |
| +10. **P1 — Forwarded requests cannot perform the takeover needed to recover them.** |
| + Spec lines 169–172 allow a forwarded request to wake only a **free** lease; a terminated owner’s unexpired lease therefore produces another 503. Cross-region requests are necessarily forwarded, and their originating box cannot perform §9’s own-region termination confirmation. Additionally, §6.5 requires the returned holder to be in the sender’s “view,” while §4.3 defines that view as same-region only—contradicting §6.9’s cross-region retry/cache. The existing hop guards prevent onward forwarding (`internal/edge/edge.go:3097–3119`), so this needs an explicit local decision. |
| + **Fix:** let the receiving home-region box perform authorized takeover locally, while retaining the no-onward-forwarding rule. Define holder validation against the destination region’s cached membership for cross-region callers. |
| + |
| +11. **P1 — “Named units are box-local and never adopted” is false for `Record.Unit`.** |
| + Spec line 214 cites the prohibition on adopting existing `Backing=unit` rows. But records can themselves carry `Unit`; `RouteFor` copies it (`internal/provision/reconcile.go:478–483`). Same-region scope admits the record (`:443–448`); the `Unit` exclusion applies only to cross-region “everywhere” adoption (`:325`). A group box can therefore mint a local route for a platform unit it does not run. Local matches precede backhaul (`internal/edge/edge.go:1596`, `:1611`), defeating §14’s platform forwarding requirement. |
| + **Fix:** explicitly exclude platform/named-unit records from group-box local routing, or refuse them outside the platform box. Inventory non-hibernating socket routes too; the `Backing=unit` check alone does not cover them. |
| + |
| +12. **P1 — Relaxing the two offline-move refusals is insufficient and can select stale source data.** |
| + Spec lines 497–499 remove the single-target and single-local-copy restrictions. Today the latter restriction also determines which box seals the move (`internal/console/apiinstancemove_offline.go:1024–1049`). The sealer checkpoints its local DB when its transaction ID is equal to or ahead of S3 (`internal/host/movesoffline_seal.go:398–408`), then archives local files/env (`:724`, `:747`). Multiple HA caches make that selection unsafe. On landing, freshness must also preserve staging precedence: current promotion occurs only after the warm-cache return (`internal/activator/backend_exec.go:819`, `:833–851`). |
| + **Fix:** retain an up-front refusal for moves involving HA regions in this release. Supporting them requires a separate complete source-selection, files/timers, landing, promotion and rollback contract—not just two changed predicates. |
| + |
| +13. **P1 — The promised rollback uses an already terminated box.** |
| + Spec line 421 terminates the old box, line 422 waits seven days for acceptance, and line 426 promises to reattach the EIP to that same box throughout the intervening period. That rollback is impossible. |
| + **Fix:** honour N-HA2 by removing the empty old box, but make rollback after removal restore onto a freshly provisioned compatible box from S3. Otherwise explicitly end the old-box rollback window at termination. Rehearse the sequence actually documented. |
| + |
| +14. **P1 — #199 is not closed by assuming every box observes deletion.** |
| + Spec line 500 recommends purging local data when each box sees the record disappear. A stopped/disconnected box can miss deletion and first reconcile the recreated record; reconciliation updates an older row’s lifetime without purging its local DB (`internal/provision/reconcile.go:2300–2320`). A2 then keeps that DB when S3 has no replica. Nearest-region rev 2 still permits recreation in the console region, whose rail checks LTX files, not all local copies or the new files manifest (`internal/console/createleftovers.go:53–75`). |
| + **Fix:** for this release, refuse reused hostnames in HA regions unless a complete purge procedure has excluded every returning stale installation. Include `files/0/` and platform secrets in the reuse check. “Every box adopts records” does not prove every box observed an intermediate absence. |
| + |
| +15. **P2 — Backfill cannot acquire an always-on instance’s already-held lease.** |
| + Spec line 248 describes acquiring, publishing and releasing each local instance’s lease. An always-on instance already holds and renews it; ordinary acquisition returns `HeldError` even for the same owner (`internal/activator/backend_exec.go:725–733`). A16 applies only to an older agent, so it cannot unblock this. Retirement nevertheless requires `files_unsynced = 0` before drain. |
| + **Fix:** attach the initial files publisher to the existing live lease handle. For sleeping instances, acquire normally. Readiness must distinguish successful publication from “a manifest exists” and remain false after a skipped or failed backfill. |
| + |
| +16. **P2 — The request budget assumes bounded listings that the implementation does not provide.** |
| + Spec lines 119, 137 and 524 budget one LIST for the newest L0 file. Litestream iterates the entire level (`litestream@v0.5.14/replica.go:220–234`) through an S3 paginator (`s3/replica_client.go:1404`); more than 1,000 objects require more requests. Hourly compaction/retention permits multi-page L0 histories (`internal/lease/lease.go:56–60`, `:106–113`). An expired-lock acquire is also **two PUTs plus one GET**, not one PUT plus GET (`:193–195`; `s3/leaser.go:114`). Each due-state edges write can trigger a LIST plus every edges GET on every reader (`internal/edge/homemap.go:456–491`). |
| + **Fix:** budget pagination, expired-lock CAS, and deployment-wide reader amplification. The stated dollar arithmetic is reasonable for the assumed counts; those counts are not reliable upper bounds. Recalculate after fixing A2. |
| + |
| +17. **P2 — A8 does not honour H4, and drain forwarding contradicts A20.** |
| + Spec line 162 chooses the receiving box whenever eligible, even when the already-known view contains a roomier box. That is not H4’s most-capacity choice; `ChooseRoomiest` already implements that comparison (`internal/boxchoice/policy.go:77–99`). At line 165, a draining ingress returns 503 when all serving peers are below headroom thresholds, although those peers would wake the same existing host if contacted directly. This can block the old EIP during retirement solely because of headroom. |
| + **Fix:** select cold placement from the cached eligible serving set using the shared chooser. For A20’s existing-instance fallback, forward from drain/platform ingress to a serving peer even when none meets the placement thresholds. |
| + |
| +Read-only review completed against `d316e3f1`. No files changed, no tests or live drills run, and `GOCACHE` was not set. |
| \ No newline at end of file |