carlos / platform Public

member backups: design rev 3 after Astra round 2 (#898)

Accepts round 2: the dbreads identity bracket around every drill and
export read, verdicts bound to that identity, a ReadGate backstop,
region availability per operation, drills skipping exporting hosts,
and refusal 1 limited to owner-enforced retention.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 60e7d8500e75b0aac307cc4565b56436b601276a parent 016391b
2 files changed, +139 −41
  • docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-member-backups-R2.md +49 −0
  • docs/superpowers/specs/2026-11-11-member-backups-design.md +90 −41

Intent

Human

<task-notification> <task-id>bhppdpo0f</task-id> <tool-use-id>toolu_01TBhTRKSUfDzuJ3fNjjcAgU</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/bhppdpo0f.output</output-file> <status>completed</status> <summary>Background command "Run Astra spec review round 2" completed (exit code 0)</summary> </task-notification>

diff --git a/docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-member-backups-R2.md b/docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-member-backups-R2.md
new file mode 100644
index 000000000..65300f5f8
--- /dev/null
+++ b/docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-member-backups-R2.md
@@ -0,0 +1,49 @@
+| Round 1 finding | Disposition | Assessment of revision 2 |
+|---|---|---|
+| R1-1 — Export immutability | **PARTLY — P2 remains** | Required conditional creation and unique attempts fix accidental replacement. Refusal 1 still calls **versioning alone** “tamper-proof.” Versions remain deletable with sufficient permissions; the repository implements that explicitly in [versioned.go:261](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/lease/versioned.go:261). **Fix:** remove that guarantee; describe protection as conditional on owner-enforced retention and permissions the uploader cannot bypass. |
+| R1-2 — Credential purpose | **FIXED** | §5 requires a distinct envelope, authenticated destination fields, rejection across envelope purposes, and an explicit console trust model. |
+| R1-3 — Internal destination access | **FIXED** | §5 specifies a separate client, owner credentials, HTTPS, connection-time address checks, and refusal of redirects and proxies. |
+| R1-4 — Files evidence | **FIXED** | Refusal 8 removes the unsupported owner-facing claim until per-instance evidence exists. |
+| R1-5 — Verdict invalidation | **PARTLY — P2 remains** | §3 compares verdict **completion time** with `copy_since`, but does not bind the verdict to the value observed before reading. A drill can read the old copy, finish after a move or restore, and pass this comparison. The listed replica prefix is also absent from the acceptance checks. Existing readers check instance identity before and after reading: [agent.go:209](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/dbreads/agent.go:209), [read.go:249](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/dbreads/read.go:249). **Fix:** capture the copy identity before reading, require it unchanged afterward, and accept verdicts only for that exact identity. |
+| R1-6 — Freshness on the wrong box | **FIXED** | §3 separates integrity from freshness and requires proof of live ownership before comparing counters. Otherwise freshness is unknown. |
+| R1-7 — History boundary | **FIXED** | §1 requires shared restore boundary rules, including next-second rounding, transaction-1 files and an absent boundary when undecidable. |
+| R1-8 — Export starvation | **FIXED** | Drills receive their own earlier budget; exports have deadlines, bounded retries and total nightly capacity. Periodic publication is required. |
+| R1-9 — Disk reservation | **FIXED** | §5 pins the transaction, reserves input and output space with a floor, and requires execution-time byte limits. |
+| R1-10 — Partial-upload retries | **FIXED** | Each attempt has unique keys; its manifest follows successful object uploads. Ambiguous completion starts another attempt. |
+| R1-11 — Metadata forwarding | **FIXED** | Refusal 7 defers metadata forwarding and preserves the person-only contents boundary. |
+| R1-12 — Change discovery | **PARTLY — P2 remains** | Per-box scopes solve identification. A six-hour **LIST alone** cannot recover a failed bump for an overwritten existing key: [Store.List returns names only](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/release/store.go:50). §3 still permits reads only when the generation changes. **Fix:** the backstop must conditionally GET existing records regardless of generation, reconcile missing keys, and budget those requests. [ReadGate already supports forced reads by age](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/release/changewatch.go:216). |
+| R1-13 — Planner cost | **FIXED** | §1 budgets all ten levels and pagination, with a deadline, file cap and coalesced concurrent requests. |
+| R1-14 — Regional coverage claim | **FIXED** | Refusal 8 removes instance-level offsite coverage; §4 labels the remaining evidence as regional progress. |
+
+1. **R2-1 — P1 — The export’s account/app check does not protect the complete replica read.**
+ **Section:** §5, lines 279–280 and 306–323. **Fault family:** source identity across an asynchronous read.
+
+ The box checks the envelope against the host’s record, then plans, restores and uploads. No second identity check is required. If the instance is deleted and its hostname reused after the initial check, the export can read the replacement’s replica and upload it using the previous account’s destination. Pinning a TXID does not identify an instance incarnation.
+
+ **Code evidence:** [agent.go:217](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/dbreads/agent.go:217) validates incarnation, account, app, region and movement state. [read.go:141](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/dbreads/read.go:141) requires checks before reading and after the last replica byte, before releasing output. [agent_test.go:31](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/dbreads/agent_test.go:31) covers recreation in the same and another account.
+
+ **Concrete fix:** require the same identity checks around export reads. Refuse moving or changed instances, discard the restored file, and send no destination bytes until the second check succeeds. Test deletion, recreation and movement during planning and download. This is distinct from the corrected envelope-purpose issue.
+
+2. **R2-2 — P2 — Sharing the region refusal with `db pull` would remove existing functionality.**
+ **Section:** §1, lines 159–162; §12’s shared-classification test. **Fault family:** preserving existing read capabilities.
+
+ Revision 2 requires the door, pull and export to share a classification including the region check “so the three never disagree.” But a remote-region instance can legitimately be unavailable to the new metadata door while remaining readable through `db pull`.
+
+ **Code evidence:** [apidb.go:144](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/console/apidb.go:144) routes residency failures through forwarding; [apidbforward.go:145](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/console/apidbforward.go:145) advertises both query and pull.
+
+ **Concrete fix:** share intrinsic instance classification only. Keep operation-specific region availability separate, preserve existing pull forwarding, and test that the metadata refusal does not disable it.
+
+3. **R2-3 — P2 — Drills-first scheduling contradicts the promised single restore.**
+ **Section:** §3, lines 216–219; §5, lines 301–314; §9, lines 400–403. **Fault family:** bounded restore scheduling and resource accounting.
+
+ Drills now run first, followed by exports that perform another restore. Nothing excludes exporting hosts from the first phase or retains their restored files. Consequently, “one restore serves both” and the unchanged restore-cost budget do not follow from the specified execution.
+
+ **Code evidence:** [hibernate_verify.go:85](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/ops/hibernate_verify.go:85) drills each selected host; [check.go:97](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/member-backups/internal/lease/check.go:97) deletes its restored file before returning.
+
+ **Concrete fix:** the smallest correction is to retain drills-first scheduling, remove the single-restore promise, and budget both restores. Reuse would require an explicit scheduling and scratch-retention contract.
+
+R1-5 and R1-12 remain findings in the same fault families for a second round. Under stopping rule 2, they need an explicit choice before another fix cycle; I recommend one enforced identity invariant for R1-5 and the existing age-based read gate for R1-12, each with a guard test.
+
+Reviewed `016391be3864be2f02de9b975d6938076f7f7e7f`. No files changed; no test suites run.
+
+NOT READY
\ No newline at end of file
diff --git a/docs/superpowers/specs/2026-11-11-member-backups-design.md b/docs/superpowers/specs/2026-11-11-member-backups-design.md
index 0375bc334..3a62f207c 100644
--- a/docs/superpowers/specs/2026-11-11-member-backups-design.md
+++ b/docs/superpowers/specs/2026-11-11-member-backups-design.md
@@ -1,9 +1,12 @@
# Backups owners can see and check
-Status: rev 2, 2026-11-11. Paul's rulings D1-D5 (§11). Astra round 1
+Status: rev 3, 2026-11-11. Paul's rulings D1-D5 (§11). Astra round 1
(`docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-member-backups.md`)
-was NOT READY with 3 P1s and 11 P2s; all 14 are accepted (§14), marked
-**(R1-N)** where they changed the text. Round 2 of at most three is next.
+was NOT READY with 3 P1s and 11 P2s; all 14 accepted (§14). Round 2
+(`CODEX-FINDINGS-member-backups-R2.md`) was NOT READY with one new P1, two
+new P2s and three round 1 fixes judged partial; all accepted (§15), taking
+Astra's recommended choice for the two repeat families. Findings are marked
+**(R1-N)** or **(R2-N)** where they changed the text. Round 3 is the last.
Discussion #898; branch `design-member-backups`. Builds on the durability
design (`2026-10-23-durability-design.md`, rev 4.2, called "durability"
below) and absorbs #893. #894 (an owner restoring a live instance in
@@ -110,9 +113,12 @@ that instance, with its time. Where no such record exists, the line says
## Refused up front
1. **Claiming the export can't be erased.** The export never lists,
- deletes or overwrites, but an uploader that is compromised could. Only
- the owner's own object lock or versioning makes the copies tamper-proof,
- and the docs say exactly that (R1-1).
+ deletes or overwrites, but an uploader that is compromised could, if
+ its key allows it. Versioning alone doesn't stop that: versions can be
+ deleted (`internal/lease/versioned.go:261`). Copies are protected only
+ by retention the owner enforces and the uploader's key cannot bypass,
+ such as compliance-mode object lock, and the docs say exactly that
+ (R1-1, round 2).
2. **A destination that doesn't honour create-only writes.** The CLI tests
`If-None-Match: *` at setup and refuses the destination if a second
create-only PUT to the same key succeeds (R1-1).
@@ -156,10 +162,14 @@ restore point) is covered. `db query` and `db pull` gates are unchanged.
}
```
-- **`class`** comes from one function over `ClassRefusal`,
- `resolveReplica` and the region check, shared with `db pull` and the
- export, so the three never disagree. Other region: `not_shown`,
- `reason: "other_region"`.
+- **`class`** comes from one function over the instance's intrinsic
+ refusals (`ClassRefusal`, and `resolveReplica`'s pool and fleet
+ checks), shared with `db pull` and the export, so the three never
+ disagree about what kind of instance it is. **Region availability stays
+ per operation (R2-2):** this door answers another region's instance
+ with `not_shown`, `reason: "other_region"`, while `db pull` and
+ `db query` keep forwarding it exactly as today (`apidb.go:144`,
+ `apidbforward.go:145`).
- **`copied_to`** is `PlanRestore(ctx, c, 0)`: the newest TXID and the
header time of the newest LTX file, the transaction `db pull` would
restore to. It is not a claim the replica is current.
@@ -195,17 +205,27 @@ updated to point here.
The single `control/restore-verify.json` stops being written. Move
landing's `RemoveVerifyEntry` (`movespass.go:576`) moves to the box's own
record (R1-5).
-- **Each verdict is bound to its copy (R1-5):** account, app, host, region,
- the replica prefix, the restored TXID and header time, size, the
- result (`passed`, `failed`, `unverified` with a reason), and when.
-- **The console shows a verdict only if** account, app, host and region
- match the instance's current record, and the verdict was reached after
- the instance's `copy_since`. The console stamps `copy_since` whenever a
- new copy starts: create, restore (#658), move landing, and a region
- change. The builder enumerates every such path, with a test that fails
- when a new one appears. Existing instances are stamped at the release
- that ships this. A verdict from a box that has left the roster for 7
- days is dropped.
+- **The identity bracket (R1-5, R2-1).** Every drill and export read is
+ bracketed by the check `db` reads already use (`internal/dbreads/agent.go:209`,
+ `read.go:141`): before planning, the record is read fresh and the
+ instance's identity captured (incarnation from `provision.Incarnation`,
+ account, app, host, region, not pooled, not fleet-placed, not moving);
+ after the last replica byte, the same check runs again and must give
+ the same identity. On any difference the restored file is discarded,
+ the verdict is `unverified` (`record_changed` or `moving`), and an
+ export sends nothing. This is one shared function, not a copy.
+- **Each verdict carries that identity:** incarnation, account, app, host,
+ region, replica prefix, the time the bracket opened, the restored TXID
+ and header time, size, the result (`passed`, `failed`, `unverified`
+ with a reason), and when it finished.
+- **The console shows a verdict only if** its identity equals the
+ instance's current identity and its bracket opened after the
+ instance's `copy_since`. The console stamps `copy_since` whenever a new
+ copy of an existing incarnation starts: restore (#658), move landing,
+ and a region change (a recreate is a new incarnation). The builder
+ enumerates every such path, with a test that fails when a new one
+ appears. Existing instances are stamped at the release that ships this.
+ A verdict from a box that has left the roster for 7 days is dropped.
- **Freshness (R1-6).** The drill reports restore integrity and the copy's
age. It compares change counters only when the box proves it holds the
live database (the instance's lease names this box). Otherwise freshness
@@ -213,19 +233,25 @@ updated to point here.
- **Which box tests which host:** on a fixed box, the box whose registry
holds it; on group boxes, its HRW box over serving(region), as
durability §5.2 says.
-- **The run (R1-8).** Drills run first, oldest first, inside a 45-minute
- time budget. Exports (§5) then run inside their own capacity. The record
- is published every 10 minutes and at the end, so an interrupted run
- keeps what it finished. Hosts the budget didn't reach are counted in the
- record.
+- **The run (R1-8, R2-3).** Drills run first, oldest first, inside a
+ 45-minute time budget, **over hosts not exporting tonight**. Exports
+ (§5) then run inside their own capacity, and each export is its host's
+ drill: one restore, one verdict. An exporting host whose export is
+ deferred gets no verdict that night; its verdict ages in the panel and
+ the deferral alerts operators. The record is published every 10
+ minutes and at the end, so an interrupted run keeps what it finished.
+ Hosts the budget didn't reach are counted in the record.
- **Arming (D4, Paul 2026-11-11).** `hibernate-verify` leaves the inert
list on every box that holds sleeping hosts.
- **Reading it (R1-12).** Each box's record is its own change-index scope,
`control/verify/<ref>` (a new `ChangeScope` arm). At start the console
lists `control/verify/` once and reads each record. After that it reads
- a record only when that box's scope generation moves, with a
- conditional GET. Every 6 hours it lists the prefix again, in case a
- bump failed.
+ a record when that box's scope generation moves, through a `ReadGate`
+ (`internal/release/changewatch.go:216`) whose maximum age is 6 hours,
+ so every known record is also re-read with a conditional GET at least
+ every 6 hours whatever its generation says (R1-12, round 2). The same
+ 6-hour pass lists the prefix to find new boxes' records and drop
+ deleted ones.
- **Alerts (operator):** a failed verdict at once, and an `unverified` one
(other than the time budget) three runs in a row. Both go through the
existing alert engine.
@@ -276,8 +302,8 @@ The key ID and secret come from a prompt or stdin, never argv.
own bucket. It can already read every replica, so this adds no reach
over data. It does add a quiet channel, so every `set`, change and `off`
emails every owner of the account, and the panel shows the destination
- to every member. The box checks again that the envelope's bound account
- and app match the host's record.
+ to every member. On the box, the envelope's bound account and app must
+ equal the identity the bracket captured (§3), at both checks.
- **Per app.** Every exportable instance of the app is exported.
`carlos backups export show|off --app shop`.
- **Plan (D1).** A new `Limits` field, `OwnerExport bool`
@@ -299,19 +325,22 @@ after setup are caught at connect time. A self-hoster who wants a LAN
destination is refused in this design (follow-up F2).
**Running it (D5: one nightly window).** The export runs on the box that
-tests the host, after that night's drills. **Each export is also that
-host's restore test for the night**: one restore serves both, and the
-verdict says so.
+tests the host, after that night's drills, which skip exporting hosts
+(§3). **Each export is also that host's restore test for the night**: one
+restore serves both, and the verdict says so.
-1. Plan with `PlanRestore` and **pin that TXID**; the restore targets it,
- not "latest" (R1-9).
+1. Open the identity bracket (§3, R2-1). Then plan with `PlanRestore` and
+ **pin that TXID**; the restore targets it, not "latest" (R1-9).
2. Reserve the plan's input bytes plus its restored size, plus a floor of
5 GiB or 10% of the disk, whichever is larger, on the box's data disk
(never a RAM-backed `/tmp`). If that isn't free, the host is
`deferred` and operators are alerted. Byte limits are enforced during
download and restore, following `dbreads/read.go:189` (R1-9).
-3. Restore, then `integrity_check`. On failure, upload nothing; the
- verdict is `restore_failed`, which alerts operators.
+3. Restore, then close the bracket: the second identity check runs after
+ the last replica byte and before any byte goes to the destination. If
+ it fails, the file is discarded and nothing is sent. Then
+ `integrity_check`; on failure, upload nothing; the verdict is
+ `restore_failed`, which alerts operators.
4. Upload, create-only, to a fresh attempt directory
`<prefix><app>/<host>/<YYYY-MM-DD>/<attempt>/`, where `<attempt>` is
the start time plus a random suffix: first `db.sqlite3` (`.age` when a
@@ -429,7 +458,13 @@ nothing in this design.
## 12. Test plan (for the builder)
- **One classification function**, walked by a table test over every
- refusal reason; the door, `db pull` and the export share it.
+ intrinsic refusal reason; the door, `db pull` and the export share it.
+ A test proves another region's instance is `not_shown` at the door and
+ still forwarded by `db pull` (R2-2).
+- **The identity bracket.** Deletion, recreation in the same and another
+ account, and a move, each injected during planning and during download,
+ for both a drill and an export: no verdict for the old copy is shown,
+ and no destination byte is sent (R2-1, following `agent_test.go:31`).
- **One history boundary function**, shared by the door and the restore,
with tests at a snapshot's exact upload second and a transaction-1 file.
- **Envelopes don't cross.** An export envelope is refused by the
@@ -445,9 +480,12 @@ nothing in this design.
no list, delete or unconditional PUT was ever sent; no PUT reused an
attempt key; every manifest's objects exist in its own attempt; nothing
was uploaded for a copy that failed integrity; drills got their budget;
- the published record holds every finished host; no instance woke.
+ the published record holds every finished host; no host was restored
+ twice in one night; no instance woke.
- **Verdict validity.** Several boxes publish; a move, a restore, a
- deletion and a box leaving the roster each hide the old verdict.
+ deletion, a recreate and a box leaving the roster each hide the old
+ verdict. A record overwritten with its change-index bump lost is read
+ within 6 hours.
- **Production-wired witnesses:** the door through the real router and
gate; the export through the real nightly run against MinIO in CI,
restored and opened with plain `sqlite3` and decrypted with `age`.
@@ -480,3 +518,14 @@ nothing in this design.
| R1-12 | P2 | one scope can't say which box changed | Accepted: per-box scopes, initial list, conditional reads, 6-hour relist |
| R1-13 | P2 | the planner's listing cost is understated | Accepted: ten levels budgeted, deadline, file cap, singleflight |
| R1-14 | P2 | a regional pass isn't an instance's copy | Accepted by cutting: off-account shown only as regional progress in the operator view (refusal 8) |
+
+## 15. Astra round 2: dispositions
+
+| # | Sev | Finding | Disposition |
+|---|---|---|---|
+| R1-1 | P2 (partial) | versioning alone isn't tamper-proof | Accepted: refusal 1 names only owner-enforced retention the uploader's key can't bypass |
+| R1-5 | P2 (partial) | completion time vs `copy_since` misses a move during the read | Accepted, Astra's recommended choice: the `dbreads` identity bracket around every read; verdicts bound to that identity; `copy_since` compared with the bracket's opening |
+| R1-12 | P2 (partial) | a LIST can't recover a lost bump on an overwritten key | Accepted, Astra's recommended choice: `ReadGate` with a 6-hour maximum age forces conditional GETs; the LIST only finds new and deleted keys |
+| R2-1 | P1 | the export's identity check doesn't cover the whole read | Accepted: the same bracket, second check before any destination byte |
+| R2-2 | P2 | sharing the region refusal would break `db pull` forwarding | Accepted: intrinsic classification shared, region availability per operation, with a test |
+| R2-3 | P2 | drills-first contradicts one restore per host | Accepted: drills skip exporting hosts; the export is that host's drill |