carlos / platform Public

member backups: design rev 1 and review brief (#898)

Owner-visible backups: a backups door and tab, per-box restore-test
verdicts, an operator view, and a nightly export to the owner's own
S3-compatible bucket. Absorbs #893. Draft for Astra round 1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 3022418e21f038a5e54fa3cf1146da891783a435 parent 01d6ca7
2 files changed, +454 −0
  • docs/superpowers/notes/reviews/member-backups/CODEX-REVIEW-BRIEF-member-backups.md +35 −0
  • docs/superpowers/specs/2026-11-11-member-backups-design.md +419 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>a78adb8551f16e333</task-id> <tool-use-id>toolu_01WrkZbEsM9PXQX9xNsc7w6x</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/a78adb8551f16e333.output</output-file> <status>completed</status> <summary>Agent "Map code for backups spec" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I've answered all ten below. Two findings matter most for the spec. First, today's drill verdicts are probably being lost or never published at all. Second, nothing in main can store an owner's S3 credentials in a form the console can read back. All paths are relative to `/home/paulca/amadan.net/carlos/platform`. ## 1. `carlos db pull` / `db query` and `--at` - **CLI:** `db.go`. Verbs are at :58-74, flags and the `--at` parsing at :91-140, the pull itself at :283-306. - **Console routes:** `internal/console/authcli.go:858-859` (list LTX files for one level, and fetch one file by its TXID range) and `:862` (the cross-region forwarded read). The handlers are in `internal/console/apidb.go`. The gate, `dbGate` at :110-176, admits only a signed-in person (`PrincipalUser`) who belongs to the account, with any role (`apiAccountApp`). Every service credential is refused, because the routes are registered with an empty role set (`svcrole.Set{}`). - **Who restores:** the CLI, on the member's own machine, with no AWS credentials. The console reads the files with its own IAM role (`cachedReadReplica` → `lease.ReadReplicaClient`, apidb.go:490-497) and passes the bytes through. The restore runs in `internal/dbdoor/restore.go:136-215` using Litestream's own restore, then the `lease.CheckDB` integrity check. By stated design the console never holds a restored database (apidb.go:1-5, db.go:4-10). That design is the main constraint on idea (B). For an instance in another region, a box in that region does the restore (`internal/dbreads`, `apidbforward.go`) and sends the result back sealed. - **The position line:** `dbAsOf`, `dbPullHolds` and `dbQueryStatus` at db.go:232-256 print "It holds every change up to transaction N, written T". N and T come from the header of the newest LTX file the restore opened (`recorder.newest`, restore.go:469; `Restored` struct at :61-72). T is the header's write timestamp. - **Which instances:** any instance that can sleep, whether it is awake or asleep at the time. `dbreads.ClassRefusal` (`internal/dbreads/class.go:14-25`) refuses non-instance routes, routes served from their own address, and anything with `!HibernateOrDefault()` ("does not sleep"; `provision.go:546`). `resolveReplica` (apidb.go:54-72) also refuses pooled instances, fleet-placed instances and other regions. The reason is that only activator-managed instances replicate to the known prefix `&lt;hibernate prefix&gt;/&lt;host&gt;`, and they do so continuously while awake (lease.go:98-106). Non-sleeping databases are covered, if at all, by box-wide Litestream under hand-chosen prefixes. That runs on IE only; UK, US and AU have none (durability spec §4.2 and §4.4, `docs/superpowers/specs/2026-10-23-durability-design.md:286-289,389`). ## 2. Reading the replica's position without restoring it - **`dbdoor.PlanRestore`** (`internal/dbdoor/plan.go:44-106`) already does this cheaply: Litestream's level listings plus one ranged read of the newest file's header. It returns the newest transaction (TXID), its time, the restored size and the file count. The console's only use today is the seeded-instance door (`internal/console/apiinstanceseed.go:42`). - **History start:** there is no function for it. The oldest restorable time is worked out only as a side effect of an `--at` restore that fails (restore.go:259-293, from the earliest snapshot or first-transaction file). - **Retention is about 7 days, not exactly 7:** snapshots are taken daily and kept for 7 days (`internal/lease/lease.go:93-95`). Pruning only runs while the instance is awake (:70-78), so a sleeping instance's history can reach further back. - **`internal/ops/freshness.go`** compares the source database's change counter with a fully restored copy, on the box. That is not cheap, and the durability spec (§5.2) says equal counters cannot prove the replica is current. - **Other signals:** `lease.HasReplica` (`internal/lease/check.go:154`) only answers yes or no. For HA hosts, the release marker in `lock.json` carries TXID and time (`internal/hafresh/lock.go:15-33`), but only on release. Box status reports carry no replication position. ## 3. restore-verify and hibernate-verify drills - **restore-verify** (`internal/ops/litestream.go:493`, unit files in `internal/host/units/carlos-restore-verify.{service,timer}`, daily) checks every database in `/etc/litestream.yml`. Its result is printed only; the outcome is just the unit's `failed` state. - **hibernate-verify** (`internal/ops/ops.go:260-358`, `internal/ops/hibernate_verify.go`, daily at 03:00) checks hosts from the box registry (`HibernatingHosts` :45: leased by the activator, not stateless, not unit-backed). It visits the oldest verdict first (`OldestFirst` :147), capped at 25 per run. - **What it records:** it publishes `control/restore-verify.json` to the deployment bucket (`internal/dbverify/dbverify.go:29`). The record has the box, the check time, and per host `ok`, `unverified` (with a reason), the verification time and a detail. - **Defect:** it is one key for the whole deployment. `Merge` (:65) keeps only this box's hosts and `Publish` (:167) replaces the whole object, so with several boxes each run erases the other boxes' verdicts. The spec's planned fix is `control/verify/&lt;ref&gt;.json` (durability §5.2); it is not built. - **Both timers are off by default** (`internal/host/bootstrap.go:178-180`). - **Nothing reads the record:** not the console, not metrics, not alerts. Only `movespass.go:576` (`RemoveHost`) touches it. Durability §4.4:401 lists this gap too. ## 4. Console instance UI and permissions - **Routes:** `internal/console/server.go:2059-2060`. The handler is `handleAppInstance` (`instancepage.go:245`), rendered with `templates/app_instance.html`. The tab list is `AppLinks` (`mobilenav.go:60-80`) and the tab bar template is `templates/appnav.html`. - **The "Protection" tab is not about backups.** It shows what the edge guard checked and blocked for the app (`protectionview.go:1-9`, routes `server.go:2089-2091`; the operator version is `/fleet/protection` at :1964). - **Account roles:** only `owner` and `member` (`store.go:1136-1139`). `accountApp` (`server.go:4414`) admits either role. Owner-only actions check `role != RoleOwner` in the handler, and `page.IsOwner()` is used in templates (`server.go:2936`). - **Operators, two kinds:** - The fleet operator bit, `users.operator`. It is read by `operatorOnly` (`server.go:4123`, used by every `/fleet/*` page), which answers anyone else with the same 404 as a missing page, and by `Store.IsOperator` (`store.go:2664`). - Deployment operators listed in `CARLOS_STORE_OPERATORS`, checked by `apiSystemOperator` (`apisystem.go:44`) and `storeOperator` (`apistore.go:644`). - **CLI credential roles:** publish, deploy, instance, operate, service, run, team, admin (`internal/svcrole/svcrole.go:33-79`). ## 5. Background jobs and the change index - **Workers:** registered in `registerClaimWorkers` (`claim_workers.go:5-48`), started as goroutines from `cmd/console/main.go:754+`. Each pass is wrapped in `jobs.Run` (`jobs.go:183`), whose job registry is held in memory and assumes one console process. Each worker has its own `time.NewTicker`: - alert engine: 1 minute - billing sync: 1 hour - economics: 1 hour - plan grace: 1 hour - plan limits: 1 minute - expiry: 5 minutes - scan pass: 1 hour - **No per-instance nightly job exists.** The closest pattern is `scanpass.go:25-52`: it ticks hourly, works within a time budget, and only redoes a store once 24 hours have passed (`defaultScanInterval`). - **Each console serves one region** (the `cfg.Region` checks in apidb.go), so a nightly job would run per regional console. - **Change index:** `internal/release/changeindex.go` (key `control/changes.json` :24; `ChangeScope` :55; bump on mutation :183-203). Readers use `ChangeWatch` (`internal/release/changewatch.go`, 30-minute backstop poll). Readers today are the edge (`internal/edge/homemap.go`, `internal/edge/certsync.go`), boxes behind `CARLOS_CHANGE_INDEX=read`, and the console's `egressfleet.go` and `demo_claim_ready.go`. ## 6. Owner-supplied secrets - **App secrets:** `sealKeyFor` (`sealkey.go:99`) seals to the deployment public key or the fleet's key. The console holds public halves only. The envelope is ECDH-P256, HKDF and AES-GCM, with v2 bound to account and app (`internal/appconfig/crypto.go`). - **Console secrets slice 2 is not in main.** It is on the unmerged branch `design-console-secrets` (plan `docs/superpowers/plans/2026-11-08-console-secrets.md`). The browser seals with WebCrypto and "the console never handles a secret's plaintext". - **`CARLOS_CONSOLE_SECRETS_KEY` exists only in a spec** (`2026-10-28-console-config-design.md:194` on branch `design-console-config-453`). It is not built. - **Sealed escrow:** `internal/hostfiles/sealed.go` and `internal/activator/escrow.go:25-75`. A box seals an instance's env file, `instance.key` and `report.token` to its own `CARLOS_SECRETS_KEY`. - **Only existing store of a user's third-party credentials:** alert connectors (Slack and webhook URLs). They are sealed with AES-256-GCM using a key file beside `console.db` (`alertseal.go:16-26`; path `alert-connectors.key`, `cmd/console/main.go:520`), which the console can open itself. - **Consequence for (D):** owner S3 credentials sealed the normal way could only be opened on a box. If the console does the export, the alert-connector seal is the precedent. ## 7. Console email Call `s.deliver(ctx, to, subject, body, keymailShare)` (`internal/console/delivery.go:41`). It tries Keymail first, then falls back to Amazon SES (`consolemail.go:183`). Callers include alerts (`alertnotify.go:747,814`), invites (`server.go:3479`) and plan grace (`plangracepass.go:236`). ## 8. Plans and entitlements - **Plans:** free, personal, community and business (`internal/plans/testdata/example-catalog.json`). The `Limits` struct is at `internal/plans/catalog.go:29-55`. - **Check:** call `s.EffectiveLimits(acct)` (`internal/console/planlimits.go:136`). Nil means plans are off or the account is exempt. Then test a field, as `checkFleets` and `checkCustomDomains` do (`plancaps.go:211-227`), and refuse with a `*planCapError`. - **`HistoryDays` exists but nothing reads it** (`plansponsor.go:68`). Personal and business set it to 7. ## 9. Bucket layout and app files - **Instance replicas** live in the region data bucket (`CARLOS_HIBERNATE_BUCKET`) under `&lt;CARLOS_HIBERNATE_PREFIX&gt;/&lt;host&gt;/`: the LTX levels and `lock.json` (`internal/activator/activator.go:167`). The prefix is the same awake or asleep, and HA hosts use it too. - **Files publication** goes to `&lt;prefix&gt;/files/0/` (`internal/activator/hawake.go:684`): - HA hosts publish app files every 15 minutes plus the sealed env/key/token items (`hafiles.go:22-36`). - Non-HA hosts publish only the sealed env/key/token escrow (`escrow.go:25-30`), with no app files. The durability spec plans to extend publication to all hosts (§5.3), but it is not built. - **Moves staging:** `moves/&lt;host&gt;/`. - **Box-wide replicas:** hand-chosen prefixes on IE only (`db/` and others). The planned scheme is `boxes/&lt;ref&gt;/`. - **Off-account copy:** `control/offsite.json` and `carlos ops offsite` are spec only (§5.5). The live copy is an interim rclone job to Hetzner, eu-west-1 buckets only (§4.1). ## 10. Encryption libraries There is no `filippo.io/age` in `go.mod` or `go.sum`. What is available: Go's standard `crypto/ecdh` and `crypto/hkdf`, AES-GCM, and `golang.org/x/crypto` v0.57.0. For owner-supplied S3-compatible buckets, `internal/s3compat` already handles custom endpoints and per-provider quirks.</result> <usage><subagent_tokens>180774</subagent_tokens><tool_uses>92</tool_uses><duration_ms>508873</duration_ms></usage> </task-notification>

diff --git a/docs/superpowers/notes/reviews/member-backups/CODEX-REVIEW-BRIEF-member-backups.md b/docs/superpowers/notes/reviews/member-backups/CODEX-REVIEW-BRIEF-member-backups.md
new file mode 100644
index 000000000..8027477f6
--- /dev/null
+++ b/docs/superpowers/notes/reviews/member-backups/CODEX-REVIEW-BRIEF-member-backups.md
@@ -0,0 +1,35 @@
+# Review brief: backups owners can see and check (rev 1)
+
+You are reviewing a design spec cold. Spec:
+`docs/superpowers/specs/2026-11-11-member-backups-design.md` on branch
+`design-member-backups`. It builds on
+`docs/superpowers/specs/2026-10-23-durability-design.md` (rev 4.2).
+
+Read the spec, then check it against the code it cites in this repository.
+Verify every file:line citation you rely on.
+
+Look hardest for:
+
+1. **Overclaiming.** Any line the panel, CLI or export would show that a
+ record does not prove: "current", coverage that isn't there, an
+ off-account copy with no record, a restore test that didn't happen.
+2. **Security.** The owner's credential path (CLI seals to the deployment
+ key, boxes open it); whether a box, the console, a member, a service
+ credential or another account could read, redirect or misuse an
+ export or its credential; cross-account or cross-app confusion; the
+ put-only claim; the door leaking contents or another account's data.
+3. **Correctness of reuse.** Does `PlanRestore` really give what §1 says?
+ Is `history_from` from listing upload time conservative? Is the
+ per-box verdict scheme sound across fixed boxes, group boxes (HRW),
+ moves and host deletion? Does one restore really serve both drill and
+ export?
+4. **Request and resource cost.** New polling, unbounded loops, disk or
+ memory on boxes, the time budget versus export priority starving drills.
+5. **Provider neutrality** (no AWS dependency in core).
+6. Anything that should be refused up front rather than handled.
+
+Output: a numbered list of findings, each with severity P1 (blocks the
+design), P2 (must fix before build) or P3 (worth fixing), the spec
+section, the code evidence with file:line, and a concrete fix. Then a
+one-line verdict: READY, READY AFTER FIXES, or NOT READY. Do not rewrite
+the spec. This is round 1 of at most three.
diff --git a/docs/superpowers/specs/2026-11-11-member-backups-design.md b/docs/superpowers/specs/2026-11-11-member-backups-design.md
new file mode 100644
index 000000000..32d9e279d
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-11-member-backups-design.md
@@ -0,0 +1,419 @@
+# Backups owners can see and check
+
+Status: rev 1 draft, 2026-11-11. Not reviewed. 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 (the replica position without contents). #894 (an owner
+restoring a live instance in place) stays its own design.
+
+## Why
+
+Paul, 2026-11-11: "How do we give members/owners/operators confidence that
+their data is being backed up and that it's available in the event of a
+disaster? Should we also offer very easy offsite / nightly backups?"
+
+Durability is written for operators. Its drills, alerts and runbooks make
+the platform recoverable, and nothing in it tells an owner anything. An
+owner today has no way to see whether their instance is copied, how far
+back it reaches, or whether anyone has ever restored it.
+
+Two different fears need two different answers:
+
+1. **"Is my data safe if a box or a region dies?"** The answer is evidence
+ from the platform's own copies and drills, shown to the people whose
+ data it is.
+2. **"What if I lose the service itself?"** No copy inside the platform
+ answers this, however good it is. Only a copy in the owner's own hands
+ does, in a format they can open without CARLOS.
+
+Confidence comes from things people can check, not from a promise. So
+every line this design shows is backed by a record the platform wrote,
+with its age. Where no record exists, it says so.
+
+## Where things stand (2026-11-11, read from main 01d6ca78)
+
+What any surface must not overstate:
+
+- **Databases of sleeping instances** replicate continuously, awake or
+ asleep, to `<CARLOS_HIBERNATE_PREFIX>/<host>/` in the region's data
+ bucket (`internal/activator/activator.go:167`, `internal/lease/lease.go:98-106`).
+ Snapshots are daily and kept 7 days (`lease.go:93-95`), and pruning runs
+ only while awake (`:70-78`), so a sleeping instance's history can reach
+ further back.
+- **Other databases** (instances that don't sleep, unit-backed, pooled,
+ fleet-placed, served from their own address) are covered, if at all, by
+ box-wide Litestream under hand-chosen prefixes, on IE only
+ (durability §4.2, §4.4). `carlos db` refuses them
+ (`internal/dbreads/class.go:14-25`, `internal/console/apidb.go:54-72`).
+- **`carlos db pull --at`** restores on the member's own machine. The
+ console reads LTX files with its own role and passes the bytes through,
+ and by design never holds a restored database (`apidb.go:1-5`,
+ `db.go:4-10`, `internal/dbdoor/restore.go:136-215`). Any account member
+ may run it (`dbGate`, `apidb.go:110-176`); service credentials may not.
+- **The position line** ("It holds every change up to transaction N,
+ written T", `db.go:232-256`) comes from a full restore today. A cheap
+ version exists: `dbdoor.PlanRestore` (`internal/dbdoor/plan.go:44`)
+ lists the levels and reads one header. Nothing computes where history
+ starts except a failed `--at` restore (`restore.go:259-293`).
+- **Drills.** `hibernate-verify` (`internal/ops/ops.go:260-358`) restores
+ up to 25 sleeping hosts per run, oldest verdict first, and publishes
+ `control/restore-verify.json` (`internal/dbverify/dbverify.go:29`).
+ That is one key for the whole deployment, and each box's `Publish`
+ replaces the object (`:167`), so boxes erase each other's verdicts.
+ Both drill timers are inert by default (`internal/host/bootstrap.go:183`).
+ Nothing reads the record.
+- **App files** are published only for born-HA hosts (every 15 minutes,
+ `internal/activator/hafiles.go:22-36`). Non-HA hosts publish only their
+ sealed escrow (`escrow.go:25-30`). Durability step 6 is not started.
+- **Off-account copy:** the interim rclone job copies eu-west-1 buckets to
+ Hetzner. UK, US and AU have none. `control/offsite.json` is spec only
+ (durability §5.5).
+- **Instance restore (#658)** is inert until the lifetimes cutover.
+
+## Goals
+
+1. An owner or member can see, for each instance, how recent its copy is,
+ how far back it reaches, when a restore of it was last tested and with
+ what result, whether a copy exists outside the hosting provider, and
+ what isn't covered at all.
+2. An owner can get a copy into their own hands now, and every night
+ without thinking about it, in a format that opens without CARLOS.
+3. An operator can see the same evidence for the whole fleet in one place,
+ and is alerted when it goes bad.
+4. Nothing shown claims more than a record proves.
+
+## Non-goals
+
+- Restoring a live instance in place (#894).
+- A browser download of a restored database. The console never holds a
+ restored database (`apidb.go:1-5`). A browser path needs its own design
+ (in-browser restore, or a box streaming the file sealed to a browser
+ key). Slice 1 shows the CLI command instead.
+- The operator-side durability work itself (inventories, offsite copier,
+ restore-box). This design reads what that work publishes, and builds one
+ piece of it (§3) because the panel needs it first.
+- A public status or trust page. §6 records the intent; it waits for
+ durability steps 5 and 7.
+
+## Anti-goals
+
+- **A green tick, "backed up", or "up to date" anywhere.** A drill never
+ proves a replica is current (durability §3.1 item 12, #290). The panel
+ shows times and ages.
+- **"Not covered" for something that may be covered by a copy we can't
+ see.** Instances whose copies the console can't read are "not shown
+ here", with the reason.
+- **The console holding a restored database or an owner's plaintext
+ credential.**
+- **A new per-box poll, or a console loop that lists replicas.** Panel
+ reads happen on request and are cached; verdicts ride the change index
+ (§9).
+- **Requiring AWS for any of it.**
+
+## Refused up front
+
+1. **An export that lists, deletes or overwrites in the owner's bucket.**
+ It only writes new objects. A put-only key is enough, and object lock on
+ the owner's side works. A compromised platform cannot erase an owner's
+ backups.
+2. **Exporting a copy that failed its integrity check.** Nothing is
+ uploaded; the verdict says failed.
+3. **An export that wakes an instance.** It reads the replica.
+4. **Export for instances the console can't read a replica for** (the
+ `ClassRefusal` and `resolveReplica` refusals: doesn't sleep, pooled,
+ fleet-placed, unit-backed). Fleet-placed instances also seal to the
+ fleet's key, which only the fleet's boxes hold. Each refusal names its
+ reason. A later slice may lift them as durability §5.1 lands.
+5. **Showing an off-account copy that no record backs.** The line reads
+ `control/offsite.json` and nothing else.
+
+## Design
+
+### 1. The backups door (absorbs #893)
+
+`GET /api/cli/apps/{account}/{app}/instances/{host}/backups`
+
+Admitted for any account member (person), and for service credentials
+with the `deploy`, `operate` or `admin` role. It returns no database
+contents, so #893's case (release automation recording a restore point)
+is covered.
+
+```json
+{
+ "class": "replicated", // or "not_shown", with "reason"
+ "copied_to": {"transaction": 48213, "written_at": "2026-11-11T14:02:07Z"},
+ "history_from": "2026-11-04T09:10:00Z",
+ "last_test": {"result": "passed", "at": "...", "copy_written_at": "...", "box": "..."},
+ "files": {"state": "copied", "at": "..."}, // or "not_copied", "no_record"
+ "offsite": {"state": "copied", "pass_finished_at": "..."}, // or "not_shown"
+ "export": { ... } // §5, present when configured
+}
+```
+
+- **`copied_to`** is `PlanRestore(ctx, c, 0)`: the newest TXID and the
+ header time of the newest LTX file. It is the same transaction and
+ time `db pull` would restore to, and it is not a claim the replica is
+ current.
+- **`history_from`** comes from the same level listing: the time of the
+ oldest retained snapshot, using the listing's upload time. Upload time
+ is at or after the snapshot's own time, so the value never claims more
+ history than exists. A new `dbdoor.HistoryFrom` shares `PlanRestore`'s
+ listing so one request pays for both.
+- **`class`** is decided by the existing refusals (`ClassRefusal`,
+ `resolveReplica`) through one function, so the door, `db pull` and the
+ export never disagree about which instances are visible. A stateless
+ instance is `no_database`.
+- **`files`:** a born-HA host reports its newest files publication time
+ (one GET of the manifest). Every other host reports `not_copied` until
+ durability step 6 publishes its files.
+- **`offsite`** reads `control/offsite.json` for the host's region. With
+ no record it is `not_shown`. An optional carloku ops step can have the
+ interim rclone job write the same record after each finished pass, so
+ eu-west-1 shows truthfully before the copier verb exists.
+- **Another region's instance** goes through the same forwarding as
+ `db` reads (`apidbforward.go`).
+- **Cost:** computed on request only, cached per host for 5 minutes in
+ the console. §9 counts it.
+
+### 2. The Backups tab and the CLI
+
+- A **Backups** tab on the instance page (`AppLinks`, `mobilenav.go:60-80`;
+ `templates/app_instance.html`), for owners and members. "Protection" is
+ taken by the edge guard and stays as it is.
+- `carlos instances backups --app shop [--instance <host>]` prints the same
+ lines. `--json` prints the door's body.
+- **Get a copy:** the tab shows the exact command, ready to copy:
+ `carlos db pull --app shop --instance <host>`, plus an `--at` example
+ using a time inside the history. Any member can already run it.
+- Each line comes from one field of the door and shows its time. Draft
+ copy is in §8.
+
+### 3. Restore tests published per box (durability §5.2's tenant half)
+
+The panel's "last restore test" line needs verdicts that survive more
+than one box. This is the hibernate-verify half of durability step 5,
+built here because the panel needs it first. Durability's text is updated
+to point here.
+
+- `hibernate-verify` publishes `control/verify/<ref>.json`, one object per
+ box, under a new change-index scope `verify`. The single
+ `control/restore-verify.json` stops being written. Nothing reads it, so
+ nothing breaks; a later cleanup deletes it.
+- Each verdict carries: result (`passed`, `failed`, `unverified` with a
+ reason), when, the TXID and header time of the restored copy, its size,
+ and `stale` only when proved (the existing `freshness.go` arm). Never
+ "current".
+- **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 already says.
+- **The cap becomes a time budget.** A count of 25 per run means a
+ verdict could be weeks old on a busy box. The run works oldest-first
+ within a time budget (proposed 45 minutes) and reports how many hosts it
+ didn't reach. The panel shows the verdict's real date, whatever it is.
+- **Arming:** `hibernate-verify` leaves the inert list on every box that
+ holds sleeping hosts. This reverses "inert by long-standing choice"
+ (`bootstrap.go:183`), so it is ruling D4.
+- **The console** watches the `verify` scope with `ChangeWatch`, loads the
+ changed boxes' records, and keeps the newest verdict per host in memory.
+ It does not poll.
+- **Alerts (operator):** a failed verdict raises one at once, and so does
+ an `unverified` result whose reason isn't the time budget, three runs in
+ a row. Both go through the existing alert engine to operators. Owners
+ see the verdict in the panel; drills are the operator's job.
+
+### 4. The operator view
+
+`/fleet/backups`, behind `operatorOnly`, with the same JSON for system
+operators (`apiSystemOperator`). For each region it shows:
+
+- instances by class (replicated, not shown with each reason, no database)
+- verdicts: passed in the last 7 days, failed, never tested, the oldest
+ verdict's age, and hosts the time budget didn't reach
+- boxes whose drill is inert or hasn't published in 36 hours
+- the off-account copy's last finished pass, or "no record"
+- exports (§5): configured, succeeded last night, failing
+
+It reads only what §1, §3 and §5 already hold, so it adds no requests.
+
+### 5. A nightly copy to the owner's own bucket
+
+**Setting it up** (owner only):
+
+```
+carlos backups export set --app shop \
+ --endpoint https://s3.example.com --bucket my-backups --region auto \
+ [--prefix carlos/] [--age-recipient age1...]
+```
+
+The key ID and secret are read from a prompt or stdin, never argv.
+
+- **The CLI tests the destination before saving.** It holds the
+ plaintext, so it writes one small object
+ (`<prefix>.carlos-export-check/<time>`) and reports the provider's own
+ error if that fails. Owners get an answer in seconds, not the next
+ morning. The test object is left in place, because the export never
+ deletes.
+- **The CLI seals the credential** to the deployment's public key with the
+ v2 envelope bound to account and app (`sealKeyFor`, `sealkey.go:99`;
+ `internal/appconfig/crypto.go`), as app secrets are. The console stores
+ ciphertext plus the non-secret fields and never sees the secret. Boxes
+ open it as they open app secrets. A console form waits for console
+ secrets slice 2's browser sealing.
+- **The scope is per app.** Every exportable instance of the app is
+ exported. `carlos backups export show|off --app shop`.
+- **Plan:** a new `Limits` field, `OwnerExport bool`
+ (`internal/plans/catalog.go`), checked with `EffectiveLimits`
+ (`planlimits.go:136`) at set time and at each run. On a downgrade the
+ export stops, the config is kept, and the panel says why. Ruling D1.
+
+**Running it:**
+
+- It runs in the same nightly pass as §3, on the box that tests the host.
+ Exporting hosts go first and are outside the time budget, so an owner
+ who pays for a nightly copy gets one each night. **Each export is also
+ that night's restore test**: one restore serves both.
+- Steps: restore the replica into scratch on the box's data disk (not a
+ RAM-backed `/tmp`), run `integrity_check`, then stream the file,
+ age-encrypted if a recipient is set, to
+ `<prefix><app>/<host>/<YYYY-MM-DD>/<host>.sqlite3[.age]`, followed by
+ `manifest.json`: TXID, header time, plaintext SHA-256 and size, platform
+ version, and `"files": "not_included"`.
+- Writes use `If-None-Match: *` where the provider honours it
+ (`internal/s3compat` knows the quirks), and multipart above the
+ provider's single-PUT size. There is no list and no delete (refusal 1).
+- **Disk check:** if free space is under twice the size `PlanRestore`
+ reports, the host is deferred with a reason, and operators are alerted.
+- **Retention is the owner's.** Their bucket's lifecycle rules and object
+ lock decide what stays. The docs say so and show a recipe.
+- **The verdict** goes in the same per-box record as §3, under `export`:
+ result, time, the object key, the TXID, and an error class
+ (`credentials_refused`, `bucket_missing`, `unreachable`, `too_large`,
+ `restore_failed`, `deferred`). The console shows it in the panel.
+- **Owner alerts:** two failed nights in a row email the account's owners
+ (`s.deliver`, `delivery.go:41`) and fire the owner's alert connectors.
+ `restore_failed` and `deferred` are ours, so they alert operators too.
+- **Files:** when durability step 6 publishes files for every host, the
+ export adds `files.tar` (age-encrypted if a recipient is set) and the
+ manifest says `"files": "included"`. Until then the panel says files
+ aren't in the copy.
+
+**Encryption** (ruling D2): optional, to an age recipient only the owner
+holds, so owners decrypt with the standard `age` tool, not with CARLOS.
+That needs `filippo.io/age` added to `go.mod`. Our own envelope would
+force owners to use CARLOS to decrypt, which defeats the purpose of the
+copy.
+
+### 6. Public targets (later)
+
+Once durability steps 5 and 7 are live, a docs page states durability
+§2's RPO/RTO table and each region's coverage (offsite copy yes or no,
+drill pass rate over 30 days), generated from §4's data. Recorded here so
+§4 keeps that data in a publishable shape. Not in this design's slices.
+
+### 7. Order
+
+| Slice | What | Needs | Size |
+|---|---|---|---|
+| 1 | §1 door (with #893), §2 tab and CLI, the "get a copy" command; restore-test line reads "not shown yet" | nothing | small |
+| 2 | §3 per-box verdicts, arming (D4), console reader, the test line, §4 operator view, operator alerts | slice 1 | medium |
+| 3 | §5 owner export, database only; plan field; owner alerts | slice 2, D1-D3 | medium |
+| 4 | files in the export; browser download design; §6 page | durability steps 5-7 | later |
+
+Each slice goes through spec review, plan, build, Astra review (three
+rounds at most), release and roll, dev first.
+
+## 8. Draft copy (all through copy review before any build)
+
+Panel lines (times in the viewer's zone):
+
+- "Copied up to 14:02 today."
+- "You can restore to any point since 4 Nov, 09:10."
+- "Last restore test passed on 11 Nov at 03:12, using the copy up to 02:58."
+- "Last restore test failed on 11 Nov at 03:12. We've been alerted."
+- "Restore tests aren't shown here yet."
+- "Files this app keeps on disk aren't copied yet. Only the database is."
+- "Files on disk last copied at 14:00."
+- "Copy outside our hosting provider: last finished 40 minutes ago."
+- "No copy outside our hosting provider is shown yet."
+- "Backups for this instance aren't shown here, because it doesn't sleep.
+ Its database is copied a different way."
+- "Get a copy on your own computer:" followed by the command.
+
+Export:
+
+- "Every night we copy this app's databases to my-backups at s3.example.com."
+- "Last copy to your bucket: 11 Nov at 03:20, up to 02:58."
+- "The last two copies to your bucket failed: the bucket refused our key."
+- "Your plan doesn't include copies to your own bucket. Your settings are
+ kept if you change plans."
+
+## 9. Request budget
+
+- **Panel and door:** on request only, cached 5 minutes per host. One
+ LIST per Litestream level present (typically 3-4), one ranged GET of a
+ header, and for born-HA hosts one GET of the files manifest. No loop.
+- **Verdicts:** one PUT per box per drill run, plus a change-index bump.
+ The console reads changed records only.
+- **Export:** the restore it needs is the same restore the drill does,
+ so for exporting hosts the drill's cost moves rather than grows. A
+ restore lists the levels and GETs the LTX files in the plan, tens of
+ requests per host. At 1,000 exporting instances that is in the order of
+ 50,000 GETs a night, about $0.02 at S3 GET pricing. The writes go to the
+ owner's bucket and cost us nothing.
+- **Box CPU and disk:** one restore per exporting host per night, inside
+ the nightly pass, spread across boxes by the same choice as §3.
+
+## 10. Provider boundary
+
+Everything is core. The owner's destination is any S3-compatible store
+through `internal/s3compat`; the source is the deployment's own store.
+Email goes through `s.deliver` (Keymail first; SES is its existing AWS
+adapter). A deployment with no AWS loses nothing in this design. The
+off-account line depends on durability's copier, which is itself
+provider-neutral.
+
+## 11. Decisions for Paul (recommendation first)
+
+- **D1 plans.** The panel and `db pull` for every plan; the nightly export
+ for Personal and up. Alternative: export on every plan.
+- **D2 encryption.** An optional age recipient, adding `filippo.io/age`.
+ Alternatives: always required; or no encryption (the owner's bucket,
+ the owner's problem).
+- **D3 who.** Members see the panel and can pull, as today. Only owners
+ set up or stop the export.
+- **D4 arming.** `hibernate-verify` armed by default wherever sleeping
+ hosts live, with a time budget instead of the 25 cap.
+- **D5 schedule.** One nightly window per region in v1, not an
+ owner-chosen hour.
+- **D6 #893.** Absorbed into slice 1's door.
+
+## 12. Test plan (for the builder)
+
+- **One classification table.** Every refusal reason in `ClassRefusal`
+ and `resolveReplica` maps to exactly one class; the door, `db pull` and
+ the export share the function. A table test walks every reason.
+- **The export never lists, deletes or overwrites.** A recording fake
+ store is the destination. A seeded simulation over random failures
+ (restore errors, integrity failures, provider 403s and 5xx, short disk,
+ plan downgrade mid-run) checks the invariants after each run: no
+ non-list/delete op was ever sent, nothing was uploaded for a copy that
+ failed integrity, every host has exactly one verdict per run, and no
+ instance was woken.
+- **Verdicts survive several boxes.** Two or more boxes publish; the
+ console's merged view holds every host's newest verdict.
+- **Production-wired witnesses:** the door through the real router and
+ gate; the export through the real nightly pass against MinIO in CI
+ (`TestDeliveredContractMinio`'s setup), restored and opened by plain
+ `sqlite3` and decrypted by `age` in the test.
+- **Dev check after each slice's roll:** slice 1, the tab on a dev
+ instance matches `db pull`; slice 2, the test line appears within a
+ day; slice 3, a MinIO or Hetzner bucket on dev receives a copy that
+ opens.
+
+## 13. Left to the builder
+
+- The exact time budget, and the cache lifetime.
+- Whether `history_from` needs its own listing or can share
+ `PlanRestore`'s.
+- The tab's layout, using the console mockup kit (5b6d5374).
+- Multipart thresholds per provider.