carlos / platform Public

member backups: 1b plan rev 5, final (review budget spent; Paul) (#898)

Strict shared replica-prefix contract enforced at plan time, in the MinIO
script and at runtime; CI runs the refusal test; completion pickup waits
for admission readiness; Fable's round 3 P2s applied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev dbcaa54da9166b12f5a612e8761b5f8576a73f12 parent 4f72db5
1 file changed, +66 −41
  • docs/superpowers/plans/2026-11-12-member-backups-slice1b.md +66 −41

CI failed — run details

Intent

Human

<task-notification> <task-id>ad34c2ecab73f571d</task-id> <tool-use-id>toolu_01Xf6XTgdahXqJu7nkVzXKJB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/ad34c2ecab73f571d.output</output-file> <status>completed</status> <summary>Agent "Write slice 1b plan (download)" 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>The plan is now rev 5, final and uncommitted, still 13 tasks (Task 0 to Task 12). I declined nothing from either round-3 file; I checked each cited line against the code first. Three things you might not expect: - **Prefix rule is stricter than your list.** Following Fable, each segment must match `[A-Za-z0-9][A-Za-z0-9_-]*`. That covers every case you named and also refuses dots and other punctuation inside a segment; `instances` and `instances/eu` still pass. - **New file, `internal/dbreads/testdata/replica-prefixes.txt`.** It is the one shared table of allowed and refused prefixes, so tofu, the script and the Go check can't drift apart. Go, the shell test and a check against both modules' tofu test files all read it. - **Two new console values.** The console gets a `HibernatePrefixRaw` config field, so its run-time check sees the untrimmed environment value. The two audit strings move into a new `internal/console/downloadcopy.go` in Task 8, ahead of Task 10's page strings.</result> <usage><subagent_tokens>440982</subagent_tokens><tool_uses>9</tool_uses><duration_ms>168942</duration_ms></usage> </task-notification>

diff --git a/docs/superpowers/plans/2026-11-12-member-backups-slice1b.md b/docs/superpowers/plans/2026-11-12-member-backups-slice1b.md
index 5aa9eb7e9..ce1a0bcd2 100644
--- a/docs/superpowers/plans/2026-11-12-member-backups-slice1b.md
+++ b/docs/superpowers/plans/2026-11-12-member-backups-slice1b.md
@@ -4,7 +4,7 @@
**Goal:** An account member presses "Download a copy" on an instance's Backups section and, a minute or two later, downloads a zip holding a checked copy of that instance's database plus a manifest, from a short-lived signed link, without the console ever holding the database.
-**Plan rev 4** (2026-11-12): Astra's plan round 2 (`CODEX-FINDINGS-plan-1b-R2.md`, reviewed rev 2, NOT READY, 3 P1 + 1 P2) applied on top of rev 3, with the controller's choices under stopping rule 2 for the two repeat families (lifecycle isolation: refuse installation up front; task dependencies: one complete pass, see "Dependency check"); dispositions at the end. The next round is the last. **Rev 3:** Fable's plan round 2 (`FABLE-FINDINGS-plan-1b-R2.md`, READY AFTER FIXES, 2 P2 + 4 P3) applied; dispositions at the end. Astra's round 2 is rerun on this revision. **Rev 2:** plan review round 1 applied (Astra `docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-plan-1b.md`, NOT READY, 5 P1 + 2 P2; Fable `FABLE-FINDINGS-plan-1b.md`, READY AFTER FIXES, 1 P1 + 4 P2 + 4 P3), with the controller's rulings on Fable P1, Fable P2-4/Astra P1-3 and Fable P3-6; dispositions at the end. Rev 1.1: Paul's rulings on D-H and D-E applied (header); the email task removed and the tasks renumbered.
+**Plan rev 5 (final, review budget spent; Paul 2026-11-12).** Round 3 applied: Astra (`CODEX-FINDINGS-plan-1b-R3.md`, NOT READY, 1 P1 + 2 P2) and Fable (`FABLE-FINDINGS-plan-1b-R3.md`, READY AFTER FIXES, 4 P2 + 5 P3); dispositions at the end. **Rev 4:** Astra's plan round 2 (`CODEX-FINDINGS-plan-1b-R2.md`, reviewed rev 2, NOT READY, 3 P1 + 1 P2) applied on top of rev 3, with the controller's choices under stopping rule 2 for the two repeat families (lifecycle isolation: refuse installation up front; task dependencies: one complete pass, see "Dependency check"); dispositions at the end. The next round is the last. **Rev 3:** Fable's plan round 2 (`FABLE-FINDINGS-plan-1b-R2.md`, READY AFTER FIXES, 2 P2 + 4 P3) applied; dispositions at the end. Astra's round 2 is rerun on this revision. **Rev 2:** plan review round 1 applied (Astra `docs/superpowers/notes/reviews/member-backups/CODEX-FINDINGS-plan-1b.md`, NOT READY, 5 P1 + 2 P2; Fable `FABLE-FINDINGS-plan-1b.md`, READY AFTER FIXES, 1 P1 + 4 P2 + 4 P3), with the controller's rulings on Fable P1, Fable P2-4/Astra P1-3 and Fable P3-6; dispositions at the end. Rev 1.1: Paul's rulings on D-H and D-E applied (header); the email task removed and the tasks renumbered.
**Architecture:** The console stores a durable job in `console.db` first, then publishes a signed `dbreads` request with a new operation, `export`, to the region's queue. The elected box runs the identity bracket around a capped plan and restore inside its sandboxed worker, which streams the checked database back after check B. The trusted agent zips it with a manifest, uploads it to `downloads/<job-id>.zip` in its own region's data bucket, confirms it and writes `result.json`. The console reconciles the job from that known key on status requests and at start, then presigns one exact GET per press. A lifecycle rule on `downloads/` is the only deletion, and the console keeps downloads off until it has read that rule back.
@@ -17,6 +17,8 @@
- **D-H, home scope: export-only home scope approved.** §2b refuses other regions and rides the `dbreads` queue. But the only console runs in the home region with `CARLOS_REGION` empty, home records keep `region: ""`, and `dbreads` can't address home: `Request.valid` and `ParseQueueKey` require `ValidRegion` (`ids.go:40`, `envelope.go:52`), and `dbReadsSettings` won't start on a box without a region (`internal/host/dbreads.go:56`). Without a fix, 1b would refuse every instance on dev and the flagship. Task 3 adds an export-only home queue scope (`_home`) and starts the worker on home boxes for export jobs only; `db query` and `db pull` forwarding are unchanged. Only home boxes take exports: regional boxes get no export capability until a regional console exists (controller ruling on Fable P3-6). It is the slice's security-sensitive task: Astra AND Fable review it, and the census covers it.
- **D-E, email: drop the email sentence.** No background notify pass and no emails. `backups.preparing.note` becomes exactly "Usually a minute or two." (Paul approved this text in his answer, 2026-11-12). Task 0 updates the record and its pinned test.
+- **Round 3, no fourth review (Paul, 2026-11-12):** apply the strict replica-prefix contract (one shared rule, enforced before the tofu mutation, before any `mc` call and at run time) and the other round 3 fixes; no fourth plan round. The build's per-task reviews and the whole-branch review check them.
+
Decisions this plan takes (reviewers may overturn them):
- The worker streams only the checked database. The agent writes `manifest.json` from the plan's TXID and time and its own SHA-256 of the relayed bytes, because the worker has nothing else to add. §2b has the worker stream both.
- "Verified" means the console reads the data bucket's lifecycle back at start (`GetBucketLifecycleConfiguration`) and checks it. That needs `s3:GetLifecycleConfiguration` on the data bucket for the host role (Task 1).
@@ -25,7 +27,8 @@ Decisions this plan takes (reviewers may overturn them):
## Global Constraints
- Approved copy (Paul, copy review ddwtnxr27ojv5j7v5ntnrha6cq, record `docs/superpowers/plans/member-backups-slice1-copy.json`), verbatim: `backups.download` "Download a copy"; `backups.preparing` "Preparing your copy"; `backups.preparing.note` "Usually a minute or two." (re-approved by Paul 2026-11-12; the earlier text also promised an email); `backups.ready` "Download {file} ({size})"; `backups.ready.note` "Ready until {time} tomorrow."; `backups.toolarge` "Too large to download here. Use the command line below." Every other human-facing string (reasons, audit details, docs) comes only from Task 0's record. No em dashes.
-- Object key `downloads/<job-id>.zip` in the data bucket of the console's own region, derived from the job id on the server and never taken from browser input. Lifecycle on `downloads/`: current versions expire after 1 day, noncurrent versions after 1 day with no retained versions, delete markers go, and incomplete multipart uploads after 1 day, on every store (no provider waiver). The rule is never installed unless the replica namespace is declared disjoint from `downloads/`: both data-bucket modules install it only when `downloads_replica_prefix` is set, and refuse at plan time (before any bucket change) a prefix that is empty or whose first segment is `downloads`; the MinIO setup goes through a script with the same refusal. Downloads also stay off at run time on such a deployment (box and console), because the rule would reach replicas.
+- Object key `downloads/<job-id>.zip` in the data bucket of the console's own region, derived from the job id on the server and never taken from browser input. Lifecycle on `downloads/`: current versions expire after 1 day, noncurrent versions after 1 day with no retained versions, delete markers go, and incomplete multipart uploads after 1 day, on every store (no provider waiver). The rule is never installed unless the replica namespace is declared disjoint from `downloads/`: both data-bucket modules install it only when `downloads_replica_prefix` is set, and refuse at plan time (before any bucket change) any prefix that breaks the replica-prefix contract; the MinIO setup goes through a script with the same refusal before any `mc` call. Downloads also stay off at run time on such a deployment (box and console), checked on the raw `CARLOS_HIBERNATE_PREFIX` value through the same rule.
+- **The replica-prefix contract** (Astra R3 P1, Fable R3 P2-1; one rule, `dbreads.ValidReplicaPrefix` in Go, the same regular expression in tofu and the script, one shared table of cases): nonempty; relative (no leading `/`); segments joined by single `/` with no empty, `.` or `..` segment and no trailing `/`; no surrounding or inner whitespace; each segment matches `[A-Za-z0-9][A-Za-z0-9_-]*`; the first segment is not `downloads`. As one expression: `^[A-Za-z0-9][A-Za-z0-9_-]*(/[A-Za-z0-9][A-Za-z0-9_-]*)*$` plus the first-segment check. This matters because the box trims and `path.Join`-cleans the prefix (`activator.go:141`, `:166`), so `instances/../downloads` would place replicas under `downloads/`. The tofu variable is a declaration: tofu can't see `host.env`, so the operator docs say a wrong declaration still installs the rule, and the run-time checks are the second line.
- Job states `queued`, `preparing`, `ready`, `failed`, `expired`. One open job per instance (`queued`, `preparing` or unexpired `ready`) by an atomic unique key, and a second start returns it only when its binding (account, app, host, incarnation, region) is the instance's current one; an obsolete open job is retired in the same transaction. Owner deadline 20 minutes (`dbreads.OwnerDeadline`), no takeover, no job retries. `ready` only after the upload is confirmed. A result whose job or attempt id isn't the record's is refused. Records are deleted after 7 days.
- Caps: restored size ≤ the box's `MaxRestored` (2 GiB default); planned LTX bytes ≤ `PlanBytesFactor`×that (the worker's rule); planner files ≤ `dbdoor.MaxPlanFiles` (20,000); the archive is streamed (no third scratch file) and capped at restored + restored/64 + 1 MiB; at most 2 open jobs per account (`queued`, `preparing` and unexpired `ready` all count); at most 10 starts per instance in any 24 hours; worker slots shared with reads through the existing admission.
- `expires_at` = ready time + 24 hours, where ready time is `min(result.Ended, console now)`. After it, no link. A link's lifetime is the lesser of 15 minutes and the time left. Response: `Cache-Control: no-store`, `Referrer-Policy: no-referrer`, `response-content-disposition=attachment; filename="<file>"`. Signed URLs never appear in logs, audit details, `console.db` or analytics. There are no download emails.
@@ -35,7 +38,7 @@ Decisions this plan takes (reviewers may overturn them):
- Audit actions: `db-download` (start, written before anything is published; a start whose row can't be written publishes nothing), `db-download-link` (issuance). Never "downloaded".
- Request budget on boxes: an export-only home agent never lists the queue on a timer. It lists only when the fast converge loop sees the serial move, and once more after each export it finishes. Each such pass is 1 LIST (2 in the first 2 minutes of an hour, when the previous hour's prefix can still hold an in-window entry). The backstop and instances-floor passes send nothing, so an idle deployment costs 0 requests per home box per day. A request that no box sees in time ends `not_picked`, and the person presses again.
- No apply, release or roll in this plan: those are Paul's. The rule must be applied and verified on a deployment before `CONSOLE_DOWNLOADS=on` is set there.
-- Census: `internal/dbreads`, `internal/host`, `internal/lease` and every file under `infra/` are root-binary scope (Task 12, overlay `member-backups-1b`). The console isn't.
+- Census: `internal/dbreads`, `internal/host`, `internal/lease`, `internal/dbdoor/plan_from.go`, `go.mod`, every `.sh` file (`scripts/downloads-ilm.sh` and its test included, `plan14_root_reads_test.go:252`) and every file under `infra/` are census scope (Task 12, overlay `member-backups-1b`). The console isn't.
- Local verification: changed packages only, with `-run`. CI runs the full suite.
- Commit subjects under 80 characters, body after a blank line, ending `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. One amadan task per plan task.
@@ -66,20 +69,20 @@ Decisions this plan takes (reviewers may overturn them):
- Modify: `infra/modules/deployment-buckets/main.tf` (`aws_s3_bucket_lifecycle_configuration.data`), `infra/modules/region-remote-host/main.tf` (same resource)
- Modify: `infra/modules/region-host/main.tf` (`host_buckets` statements) and `infra/modules/region-host/group_iam.tf` (`group_bucket_statements`)
- Modify: `infra/modules/deployment-buckets/variables.tf`, `infra/modules/region-remote-host/variables.tf` (`downloads_replica_prefix`), both modules' `outputs.tf` (`downloads_lifecycle`)
-- Create: `scripts/downloads-ilm.sh` (the MinIO setup step) and `scripts/downloads-ilm_test.sh`
+- Create: `scripts/downloads-ilm.sh` (the MinIO setup step), `scripts/downloads-ilm_test.sh`, and `internal/dbreads/testdata/replica-prefixes.txt` (the shared case table: one `ok|<value>` or `no|<value>` per line, the value taken verbatim after the first `|`, spaces included)
- Modify: `infra/modules/README.md` (Task 0's operator section, verbatim)
- Test: create `infra/modules/deployment-buckets/tests/downloads.tftest.hcl`, `infra/modules/region-remote-host/tests/downloads.tftest.hcl`, `infra/modules/region-host/tests/downloads_lifecycle_read.tftest.hcl`; modify both `data_lifecycle.tftest.hcl` (their `one(...rule)` stops being one)
**Interfaces:**
- Produces:
- - `variable "downloads_replica_prefix"` (string, default `null`) in both data-bucket modules: the deployment's `CARLOS_HIBERNATE_PREFIX` for this bucket, which the operator states to opt in. Its `validation` refuses, at plan time and so before any bucket change, a value that is empty, starts with `/`, or whose first `/`-separated segment is `downloads`, with an error message naming the value and saying why the rule would expire replicas (Astra R2 P1-1, Fable P2-5). `null` installs nothing (today's deployments plan no change until the operator opts in).
+ - `variable "downloads_replica_prefix"` (string, default `null`) in both data-bucket modules: the deployment's `CARLOS_HIBERNATE_PREFIX` for this bucket, which the operator states to opt in. Its `validation` refuses, at plan time and so before any bucket change, a value that breaks the replica-prefix contract (Global Constraints: the regular expression and the first-segment check), with an error message naming the value and saying why the rule would expire replicas (Astra R2 P1-1, Fable P2-5). `null` installs nothing (today's deployments plan no change until the operator opts in).
- Only when it is set, the data bucket gains rules `downloads-expire` (filter prefix `downloads/`, expiration days 1, noncurrent days 1, abort multipart 1 day) and `downloads-delete-markers` (same prefix, `expired_object_delete_marker = true`; S3 refuses it beside days), as `dynamic` rule blocks, mirroring `db-reads-expire` in the deployment bucket. `expire-noncurrent` is unchanged.
- `output "downloads_lifecycle"`: `{ installed = bool, replica_prefix = string }`, the operator-visible report of what was checked and installed.
- - `scripts/downloads-ilm.sh <mc-alias>/<bucket> <replica-prefix>`: applies the same refusal (same message) and exits 2 before calling `mc`; otherwise runs `mc ilm import` of the AWS-shaped rules (abort included) and prints the read-back (`mc ilm export`).
+ - `scripts/downloads-ilm.sh <mc-alias>/<bucket> <replica-prefix>`: applies the same contract (the same expression through `grep -Ex` on the unmodified argument, then the first-segment check; same message) and exits 2 before any `mc` call; otherwise runs `mc ilm import` of the AWS-shaped rules (abort included) and prints the read-back (`mc ilm export`).
- The host role gets `s3:GetLifecycleConfiguration` on the data bucket ARN alone (both statement sets).
-- [ ] **Step 0: Measure the fast tick (before any build; Fable R2 P2-1).** The controller, who has box log access, reads the `agent: fast converge: … took …` lines (`agent.go:3201`) from the dev and flagship boxes' agent logs over at least the last 7 days and records the longest tick, per deployment, in Task 3's Latency bullet. Well under 45 s: accept and continue. Otherwise stop and take it to Paul before Task 3 is built.
-- [ ] **Step 1: Failing tests.** `downloads_rule_expires_everything_after_a_day` (both bucket modules, `downloads_replica_prefix = "instances"`: exactly one `downloads-expire` rule with the four values above and one `downloads-delete-markers` rule; `downloads_lifecycle.installed` true); `downloads_rule_absent_by_default` (both: unset → no `downloads-*` rule, `installed` false); `downloads_rule_refused_for_unsafe_prefix` (both: `""`, `"downloads"`, `"downloads/x"` and `"/instances"` each `expect_failures = [var.downloads_replica_prefix]`; `"downloadsx"` passes); `scripts/downloads-ilm_test.sh` (with a stub `mc` first on `PATH` that records its calls: every unsafe prefix exits 2 with the message and the stub was never called; `instances` calls `mc ilm import` once with the four values); `expire_noncurrent_unchanged` (both); `host_role_reads_data_bucket_lifecycle` (region-host, group off and group on: the action on `var.data_bucket_arn` only, never on the deployment bucket). Rewrite `data_noncurrent_days_is_configurable` to select the `expire-noncurrent` rule by id.
+- [ ] **Step 0: Measure the fast tick (before any build; Fable R2 P2-1, R3 P3-5).** The controller, who has box log access, reads the `agent: fast converge: … took …` lines (`agent.go:3201`) from the dev and flagship boxes' agent logs over at least the last 7 days. Those lines are per leg and appear only past 5 s (`slowLegAfter`, `agent.go:3191`; also `changeindex.go:404`, `agent.go:3357`), and the restart, wake and schedule legs are untimed, so record the longest tick as the sum of the legs logged for one tick, and treat a tick with no lines as under about 10 s, not zero. Record the result, per deployment, in Task 3's Latency bullet. Well under 45 s: accept and continue. Otherwise stop and take it to Paul before Task 3 is built.
+- [ ] **Step 1: Failing tests.** `downloads_rule_expires_everything_after_a_day` (both bucket modules, `downloads_replica_prefix = "instances"`: exactly one `downloads-expire` rule with the four values above and one `downloads-delete-markers` rule; `downloads_lifecycle.installed` true); `downloads_rule_absent_by_default` (both: unset → no `downloads-*` rule, `installed` false); `downloads_rule_refused_for_unsafe_prefix` (both: every `no` row of `replica-prefixes.txt`, at least `""`, `"."`, `".."`, `"downloads"`, `"downloads/x"`, `"/instances"`, `"instances/"`, `"instances//x"`, `" instances"`, `"instances "`, `" downloads"`, `"instances/.."`, `"instances/../downloads"`, `"./downloads"`, `"x/../downloads"`, each `expect_failures = [var.downloads_replica_prefix]`; every `ok` row, at least `"instances"`, `"instances/eu"` and `"downloadsx"`, passes); `scripts/downloads-ilm_test.sh` (reads `replica-prefixes.txt`; with a stub `mc` first on `PATH` that records its calls: every `no` row exits 2 with the message and the stub was never called; every `ok` row calls `mc ilm import` once with the four values); `expire_noncurrent_unchanged` (both); `host_role_reads_data_bucket_lifecycle` (region-host, group off and group on: the action on `var.data_bucket_arn` only, never on the deployment bucket). Rewrite `data_noncurrent_days_is_configurable` to select the `expire-noncurrent` rule by id.
- [ ] **Step 2:** `tofu -chdir=infra/modules/<module> init -backend=false && tofu -chdir=infra/modules/<module> test` for the three modules, and `sh scripts/downloads-ilm_test.sh` → FAIL. Where tofu or the provider cache is unavailable, say so in the task report; CI does not run these, so the reviewer reads the plans.
- [ ] **Step 3:** Implement. Comment each rule like the `db-reads` ones (why it exists, that it is the only deletion, that deletion is asynchronous).
- [ ] **Step 4:** Tests PASS.
@@ -87,7 +90,7 @@ Decisions this plan takes (reviewers may overturn them):
### Task 2: The `export` operation on the wire
-**Files:** Modify `internal/dbreads/protocol.go`, `envelope.go`, `ids.go`, `result.go`, `worker.go` (hello only); test in `internal/dbreads/envelope_test.go`, `ids_test.go`, `export_wire_test.go` (new).
+**Files:** Modify `internal/dbreads/protocol.go`, `envelope.go`, `ids.go`, `result.go`; create `internal/dbreads/prefix.go`; test in `internal/dbreads/prefix_test.go`, `internal/dbreads/envelope_test.go`, `ids_test.go`, `export_wire_test.go` (new).
**Interfaces:**
- Produces:
@@ -96,7 +99,8 @@ Decisions this plan takes (reviewers may overturn them):
- `Request` gains `Job string \`json:"job,omitempty"\`` after `IssuedAt` (last: the wire's field order). `valid()`: `OpExport` requires `SQL == ""`, `At == ""`, `ReplyKey == ""`, `ValidJobID(Job)`; every other op requires `Job == ""` and keeps today's reply-key rule.
- `type ExportOutcome struct { Job, Attempt, Key string; Bytes int64; TXID uint64; At time.Time }` (JSON `job, attempt, key, bytes, txid, at`); `Result` gains `Export *ExportOutcome \`json:"export,omitempty"\``.
- `func (r Result) ValidExport(job, attempt string) error`: today's state/code vocabulary; `LastSeq == 0`; `Sealed == ""`; `done` requires code `""` and `Export` with `Job == job`, `Attempt == attempt`, `Key == DownloadKey(job)`, `Bytes > 0`; any other state requires `Export == nil`.
- - `HelloReply` gains `Ops []string \`json:"ops,omitempty"\``; `ServeWorker` answers the hello with `Ops: []string{OpQuery, OpPull, OpExport}` beside `opt.Self()`'s view.
+ - `HelloReply` gains `Ops []string \`json:"ops,omitempty"\`` (the field only; Task 4's worker fills it, Fable R3 P3-1).
+ - `func ValidReplicaPrefix(p string) error`: the replica-prefix contract (Global Constraints) on the unmodified value, nil or an error naming the rule broken. The one Go copy: the box (Task 6) and the console (Task 8) both call it (Fable R3 P3-2).
- `readyMsg` gains `Bytes int64 \`json:"bytes,omitempty"\``.
- `type Manifest struct { V int; TXID uint64; At time.Time; SHA256 string; Bytes int64; PlatformVersion string; Files string }`, JSON `v, txid, at, sha256, bytes, platform_version, files`; `Files` is always `"not_included"`.
@@ -106,7 +110,8 @@ Decisions this plan takes (reviewers may overturn them):
- `TestExportRequestValid`: a table of an export with SQL, with At, with a reply key, without a job, with a malformed job, and a query with a job, all refused by `Sign`; a well-formed export signs and `Verify`s.
- `TestValidExport`: every row of the vocabulary; a `done` with a wrong job, a wrong attempt, a key not `DownloadKey(job)`, zero bytes, a `last_seq` or a `sealed` is refused; a `failed` carrying `export` is refused.
- `TestJobIDShape` (mirrors `ids_test.go`'s id tests).
-- [ ] **Step 2:** `go test ./internal/dbreads -run 'WireUnchanged|ExportRequest|ValidExport|JobID|Envelope|IDs' -count=1` → FAIL.
+ - `TestValidReplicaPrefixTable`: every row of `testdata/replica-prefixes.txt` (Task 1) gives its verdict; and `TestReplicaPrefixTableCoversTofuAndScript`: every `no` row's value appears in both modules' `downloads.tftest.hcl` refusal runs, and the script's expression is byte-identical to the one in `prefix.go` and both `variables.tf` files.
+- [ ] **Step 2:** `go test ./internal/dbreads -run 'WireUnchanged|ExportRequest|ValidExport|JobID|Envelope|IDs|ReplicaPrefix' -count=1` → FAIL.
- [ ] **Step 3:** Implement.
- [ ] **Step 4:** PASS, with the existing envelope and id tests.
- [ ] **Step 5:** Commit.
@@ -128,7 +133,7 @@ Decisions this plan takes (reviewers may overturn them):
- `probe` keeps the passing hello's `Ops`. `func (a *Agent) ExportCapable() bool`: `Capable()`, `ExportOnly`, a non-nil `Downloads`, and the last passing probe's `Ops` holds `OpExport`.
- `consider`, after `Verify` and before admission and the election, decides and logs without writing anything: any op but export on an `ExportOnly` agent, and an export on an agent that isn't `ExportCapable`.
- `func (a *Agent) listTick() (<-chan time.Time, func())`: the `ListEvery` ticker's channel and its stop, or a nil channel and a no-op when `ExportOnly`. `Run` selects on it, so an `ExportOnly` agent never lists on a timer and runs `Pass` only on its nudge channel or its own after-export pass (below). The probe stays on its timer (a local socket, no store call). A regional agent's `Run` is unchanged (Fable R2 P3-3).
- - After an export it owns has written its result, `serve` on an `ExportOnly` agent asks for one `Pass` (a non-blocking send on an internal `passAgain` channel `Run` also selects on). Every "a later pass may admit it" exit in `consider` and `Pass` (a transient `Get` error, draining, failed admission, `!Capable()`, a `List` error) relied on the 30 s list; with this, an export refused for a full box is picked when a slot frees (Fable R2 P2-2).
+ - Completion-triggered pickup waits for admission readiness (Astra R3 P2-3, Fable R3 P2-3; controller's choice under stopping rule 2: the single readiness invariant). `func (a *Agent) passWhenReady(ctx context.Context)` runs after `serve` has returned, so the deferred `adm.finish` has released the running slot (`read.go:25`). It then waits on `adm.settle(ctx, settlePoll)` until the orphan-unit condition is clear (`admission.go:46`; local `Units` reads, no store calls), bounded by `PickupWindow`, and only then makes the non-blocking send on the internal `passAgain` channel `Run` also selects on. A settle that hits its bound still sends once. Only `ExportOnly` agents do this, for exports. Every "a later pass may admit it" exit in `consider` and `Pass` (a transient `Get` error, draining, failed admission, `!Capable()`, a `List` error) relied on the 30 s list; with this, an export refused for a full box is picked when a slot frees (Fable R2 P2-2).
- `Pass` on an `ExportOnly` agent lists the previous hour's prefix only while `now` is within `PickupWindow + Skew` of the hour's start (the only time `InWindow`, `ids.go:113`, can admit an entry from it); a regional agent lists both hours as today (Fable R2 P3-6).
- `dbReadsEnv` gains `exportOnly bool`. `dbReadsSettings`: an empty `CARLOS_REGION` starts with `region ""`, `exportOnly: true`, unless `CARLOS_FLEET` is set (refused: a fleet box with an empty region is not a home box; Fable R2 P3-4); a non-empty invalid one (a fleet placement included) is refused as today. `CARLOS_FLEET` joins `dbReadsHostEnvKeys` (`host/dbreads.go:166`) so root's socket rule reads it too. Every home box with hibernation configured starts the export-only agent, pool and demo boxes included, as regional boxes do today (`dbReadsSettings` has no pool check); the census claim says so (Fable R2 P3-5). The identity bracket still refuses pooled records and no-copy classes, so a pool or demo box only ever exports shared home instances. `dbReadsSocketWanted` follows it, unchanged otherwise. `armDBReads` sets `ExportOnly` and, on an export-only box, passes `dbExportNudge` instead of `dbReadsNudge`.
- `var dbExportNudge = make(chan struct{}, 1)` and `func nudgeDBExports()`, sent only from the fast converge loop's serial-move branch (`agent.go:3280`), before `d.runFull`, never from the backstop, scoped or instances-floor passes (`nudgeDBReads` at `changeindex.go:444` is unchanged and still feeds regional agents).
@@ -139,8 +144,8 @@ Decisions this plan takes (reviewers may overturn them):
- `TestQueueKeyHomeScope`: round trip; a key under `queue/_home/` parses with region `""`; `queue/home/` is a region called `home`, not the home scope.
- `TestHomeScopeNeverQueryOrPull` (the ruling's first proof): for both `OpQuery` and `OpPull`, a `Region ""` request is refused by `Sign`; a hand-signed root envelope of one (bypassing `Sign`) is refused by `Verify` on a home agent; a queue entry under `_home` pointing at one is decided and logged with no `picked` written, no worker dialled and no `result.json`; an `ExportOnly` agent given a validly signed query or pull for a region (its own region set to that region in a test-only config that bypasses `NewAgent`'s refusal) still refuses it before the election. Only `OpExport` with `Region ""` is accepted.
- `TestNonHomeUnchanged` (the second proof): golden canonical bytes and queue keys for a regional query, pull and export are byte-identical to before the change; `QueueScope("uk") == "uk"`; `ParseQueueKey` gives the same entries for every existing `ids_test.go` key; a regional agent's `Pass` lists exactly the prefixes it listed before and its `Run` still lists every `ListEvery`; `dbReadsSettings` and `dbReadsSocketWanted` answer exactly as before for every non-empty `CARLOS_REGION` in `dbreads_test.go`'s table; a regional agent publishes `db-read-1` as before and never `db-export-1`, and refuses an export request before the election; `forwardable` still refuses a home record.
- - `TestHomeAgentIdleBudget` (Fable P1, R2 P3-3): an `ExportOnly` agent's `listTick` channel is nil and a regional agent's isn't; a counting store under an `ExportOnly` agent's `Run` (probe through `inProcWorkers`) with no nudge for a bounded real interval sees 0 store calls; one nudge at minute 30 of an hour gives exactly one LIST, and one at minute 1 gives two (the agent's `cfg.Now` is the seam); a backstop or instances-floor pass sends no `dbExportNudge`, and a serial move sends exactly one; an `ExportOnly` agent's `serve` of an export, whatever its ending, asks for exactly one more `Pass`.
- - `TestNewAgentRefusesMixedExportConfig`, `TestExportCapableNeedsAll` (each of the four conditions alone false → false).
+ - `TestHomeAgentIdleBudget` (Fable P1, R2 P3-3): an `ExportOnly` agent's `listTick` channel is nil and a regional agent's isn't; a counting store under an `ExportOnly` agent's `Run` (probe through `inProcWorkers`) with no nudge for a bounded real interval sees 0 store calls; one nudge at minute 30 of an hour gives exactly one LIST, and one at minute 1 gives two (the agent's `cfg.Now` is the seam); a backstop or instances-floor pass sends no `dbExportNudge`, and a serial move sends exactly one; an `ExportOnly` agent's export, whatever its ending, asks for exactly one more `Pass`, and only after its slot is released and `Units` reports no orphan (a `Units` stub that reports one lingering unit for three polls delays the send by three polls).
+ - `TestNewAgentRefusesMixedExportConfig`, `TestExportCapableNeedsAll` (each of the four conditions alone false → false; the probe's `Ops` come from a stubbed hello, since the worker fills them only in Task 4).
- `TestWithDBReadCapabilities` (all four combinations).
- `TestDBReadsSettingsHome`: empty region → started, `exportOnly`; empty region with `CARLOS_FLEET` set → refused; `fleet/x` and `bad region` refused; host claims and `CARLOS_DB_READS=0` still refuse. `TestDBReadsSocketWantedHome` (including the `CARLOS_FLEET` row, read from host.env).
- [ ] **Step 2:** `go test ./internal/dbreads ./internal/host ./internal/console -run 'HomeScope|NonHomeUnchanged|HomeAgentIdle|NewAgentRefusesMixed|ExportCapableNeedsAll|WithDBReadCapabilities|QueueKey|DBReadsSettings|DBReadsSocketWanted|Forwardable' -count=1` → FAIL.
@@ -150,11 +155,11 @@ Decisions this plan takes (reviewers may overturn them):
### Task 4: The worker's `export` operation
-**Files:** Modify `internal/dbreads/worker.go`; test `internal/dbreads/worker_export_test.go` (new).
+**Files:** Modify `internal/dbreads/worker.go` (the export path and the hello's `Ops`); test `internal/dbreads/worker_export_test.go` (new).
**Interfaces:**
- Consumes: Task 2's `OpExport`, `readyMsg.Bytes`.
-- Produces: `ServeWorker` accepts `OpExport` headers. It receives and checks the files as for a query (header names, the plan ending at its target, `planWithinBounds`), restores with `opt.Restore` (`dbdoor.RestoreLocal`, which runs the integrity check), refuses a file over `h.MaxRestored` with `CodeTooLarge`, and sends `frameReady` with `{txid, bytes: <restored file size>}`. On `frameStop` it ends. On `frameRun` with empty SQL it streams the file's bytes as `frameOutput` frames and ends with `endMsg{Code: ""}`; a run with SQL is `errProtocol`.
+- Produces: `ServeWorker` accepts `OpExport` headers. It receives and checks the files as for a query (header names, the plan ending at its target, `planWithinBounds`), restores with `opt.Restore` (`dbdoor.RestoreLocal`, which runs the integrity check), refuses a file over `h.MaxRestored` with `CodeTooLarge`, and sends `frameReady` with `{txid, bytes: <restored file size>}`. On `frameStop` it ends. On `frameRun` with empty SQL it streams the file's bytes as `frameOutput` frames and ends with `endMsg{Code: ""}`; a run with SQL is `errProtocol`. The hello answers `Ops: []string{OpQuery, OpPull, OpExport}` beside `opt.Self()`'s view.
- [ ] **Step 1: Failing tests:** `TestWorkerExportSendsTheCheckedFile` (output bytes equal a direct `RestoreLocal` of the same files; ready's bytes equal their length); `TestWorkerExportStopsWithoutSending`; `TestWorkerExportRefusesSQL`; `TestWorkerExportIntegrityFailure` (a `Restore` stub returning an error → `CodeCheckFailed`, no output frame); `TestWorkerExportTooLarge`; `TestWorkerHelloListsOps`.
- [ ] **Step 2:** `go test ./internal/dbreads -run 'WorkerExport|WorkerHello|Worker' -count=1` → FAIL.
@@ -179,7 +184,7 @@ Decisions this plan takes (reviewers may overturn them):
- `TestExportUploadFails`: `Upload` errors → `failed`/`interrupted`, never `done`; `Size` disagreeing → `interrupted`.
- `TestExportShortStream`: a worker that sends fewer bytes than ready said → `check-failed`.
- `TestExportCancelAndDeadline`: a cancel object mid-stream → `cancelled`; the owner deadline mid-upload → `failed`/`interrupted`; scratch reservations released as for reads.
- - `TestExportSharesReadSlots` (Fable R2 P2-2): two exports running on an `ExportOnly` agent; a third, queued, is not elected and writes no `picked`; when one finishes, the agent's after-export pass elects it, within the pickup window, with no nudge.
+ - `TestExportSharesReadSlots` (Fable R2 P2-2, Astra R3 P2-3): two exports running on an `ExportOnly` agent; a third, queued, is not elected and writes no `picked`. When one finishes, `inProcWorkers.linger` (`fixture_test.go:39`) keeps its worker counted as a live unit after the slot is released, forcing the release-order race. The agent's single after-export pass runs only once `settle` reports no orphan, and elects the third within the pickup window, with no nudge. With `passWhenReady` replaced by an immediate send, the same test fails (the pass is refused and the third ends `not_picked`).
- [ ] **Step 2:** `go test ./internal/dbreads ./internal/dbdoor ./internal/console -run 'Export|PositionAndHistory|BackupsFor' -count=1` → FAIL.
- [ ] **Step 3:** Implement in `export.go`; don't thread exports through `attempt` (whose sealing they don't use).
- [ ] **Step 4:** PASS, plus `go test ./internal/dbreads -count=1 -run 'Read|Pull|Loop|Agent'`.
@@ -193,10 +198,9 @@ Decisions this plan takes (reviewers may overturn them):
- Consumes: Task 3's `DownloadStore`, `ExportOnly` and arming.
- Produces:
- `func lease.NewDownloadStore(ctx context.Context, bucket, region string) (*DownloadStore, error)`: an S3 client built by `NewFilesStore`'s rule (region resolution, `s3compat.Options()`, when-required checksums); `Upload` through `manager.NewUploader` with `ContentType: application/zip`; `Size` by `HeadObject`. Both refuse a key not under `"downloads/"` (a literal: `lease` can't import `dbreads`).
- - `func downloadsPrefixSafe(hibernatePrefix string) bool`: false when the prefix is empty or its first path segment is `downloads` (Fable P2-5: replicas live at `<prefix>/<host>/`, `activator.go:166`, and a bare label is a valid host).
- - `armDBReads` builds `Downloads` from `hib.Bucket`/`hib.Region` only on an export-only box whose prefix is safe; otherwise nil, with the reason logged.
+ - `armDBReads` builds `Downloads` from `hib.Bucket`/`hib.Region` only on an export-only box whose raw `CARLOS_HIBERNATE_PREFIX` (read from the environment, not the trimmed `hib.Prefix`) passes `dbreads.ValidReplicaPrefix` and equals `hib.Prefix`; otherwise nil, with the reason logged (Fable P2-5, Astra R3 P1).
-- [ ] **Step 1: Failing tests:** `TestDownloadStoreRefusesOtherKeys`; `TestDownloadsPrefixAgrees` (in `internal/host`: the literal equals `dbreads.DownloadsPrefix`); `TestDownloadsPrefixSafe` (`instances` safe; `""`, `downloads`, `downloads/x` unsafe; `downloadsx` safe); `TestArmDBReadsWiresDownloads` (an export-only box with a safe prefix gets a store; a regional box and an unsafe prefix get nil).
+- [ ] **Step 1: Failing tests:** `TestDownloadStoreRefusesOtherKeys`; `TestDownloadsPrefixAgrees` (in `internal/host`: the literal equals `dbreads.DownloadsPrefix`); `TestArmDBReadsWiresDownloads` (an export-only box with `instances` gets a store; a regional box gets nil; every `no` row of `replica-prefixes.txt` as the raw environment value gets nil, ` instances` and `/instances` included even though the activator would trim them).
- [ ] **Step 2:** `go test ./internal/lease ./internal/host -run 'DownloadStore|DownloadsPrefix|ArmDBReads' -count=1` → FAIL.
- [ ] **Step 3:** Implement. A failed multipart upload is left to the lifecycle rule's 1-day abort (the host role has no `s3:AbortMultipartUpload`).
- [ ] **Step 4:** PASS; `GOOS=darwin go build . && GOOS=windows go build .` (the CLI links `internal/host`).
@@ -216,8 +220,9 @@ Decisions this plan takes (reviewers may overturn them):
- `func (s *Store) DBDownloadFor(ctx context.Context, accountID int64, app, host string) (dbDownload, bool, error)`: the newest row.
- `func (s *Store) OpenDBDownloads(ctx context.Context) ([]dbDownload, error)` (`queued`, `preparing`) and `OpenDBDownloadsFor(ctx, accountID int64)`.
- `func (s *Store) MoveDBDownload(ctx context.Context, id, from string, to dbDownload) (bool, error)`: `UPDATE ... WHERE id = ? AND state = ?`; false when another caller moved it first.
+ - `func (s *Store) DBDownloadCounts(ctx context.Context, accountID int64, app, host string, now time.Time) (open, startsToday int, err error)`: the account's `queued`, `preparing` and unexpired `ready` rows, and the instance's rows created in the last 24 hours, by the same rules `StartDBDownload` counts (Fable R3 P2-4).
-- [ ] **Step 1: Failing tests:** `TestStartDBDownloadOnePerInstance` (two concurrent starts from goroutines → one created, both return the same id); `TestStartDBDownloadReturnsReady` (an unexpired ready row is returned; an expired one is moved to `expired` and a new job starts); `TestStartDBDownloadRetiresObsolete` (Review Focus 2: an open row of another incarnation, and one of another region, is retired and returned, and a fresh job is admitted); `TestStartDBDownloadAccountCap` (with two unexpired ready jobs on two instances, a third instance is refused; once one expires it is admitted); `TestStartDBDownloadDailyCap` (the 11th start in 24 hours refused, the next day admitted); `TestDBDownloadPrune` (rows past 7 days go); `TestMoveDBDownloadCAS` (two moves from `preparing`: one wins).
+- [ ] **Step 1: Failing tests:** `TestStartDBDownloadOnePerInstance` (two concurrent starts from goroutines → one created, both return the same id); `TestStartDBDownloadReturnsReady` (an unexpired ready row is returned; an expired one is moved to `expired` and a new job starts); `TestStartDBDownloadRetiresObsolete` (Review Focus 2: an open row of another incarnation, and one of another region, is retired and returned, and a fresh job is admitted); `TestStartDBDownloadAccountCap` (with two unexpired ready jobs on two instances, a third instance is refused; once one expires it is admitted); `TestStartDBDownloadDailyCap` (the 11th start in 24 hours refused, the next day admitted); `TestDBDownloadPrune` (rows past 7 days go); `TestMoveDBDownloadCAS` (two moves from `preparing`: one wins); `TestDBDownloadCountsMatchStart` (for every cap row above, the counts predict `StartDBDownload`'s answer).
- [ ] **Step 2:** `go test ./internal/console -run 'DBDownload' -count=1` → FAIL.
- [ ] **Step 3:** Implement.
- [ ] **Step 4:** PASS.
@@ -234,19 +239,21 @@ Decisions this plan takes (reviewers may overturn them):
- `type downloadObjects interface { Rules(ctx context.Context) ([]lifecycleRule, error); Size(ctx context.Context, key string) (int64, error); PresignGet(ctx context.Context, key, filename string, ttl time.Duration) (string, error) }` (adapter in Task 9).
- `func lifecycleCoversDownloads(rules []lifecycleRule) error`. Each requirement is met by some enabled, un-narrowed rule whose prefix is a prefix of `downloads/`: expiry present with `1 ≤ days ≤ 1`; noncurrent expiry present with `1 ≤ days ≤ 1` and `NewerNoncurrent == 0`; delete markers; abort present with `1 ≤ days ≤ 1`. And no enabled rule covering `downloads/` retains noncurrent versions (`NewerNoncurrent > 0`), since S3 keeps that many versions whatever the days say (Astra P1-1). No store gets a waiver.
- `func checkDownloadsEndpoint(raw string, compatible bool, lookup func(context.Context, string) ([]netip.Addr, error)) error`. AWS (`raw == ""`, not compatible) passes. A compatible store needs `raw`: `https`, no userinfo or query, and a host that is not an IP literal and resolves only to addresses no `egressaddr` class or `egressaddr.FenceDeny` refuses.
- - `func (s *Server) VerifyDownloads(ctx context.Context) error`: with `cfg.Downloads` and a non-nil `s.downloadObjs` (nil until Task 9 builds the adapter; nil refuses), runs both checks and `downloadsPrefixSafe(cfg.HibernatePrefix)` (the same rule as Task 6, duplicated as a console function with a test pinning the two to the same table), and sets `downloadsReady`; logs why and leaves it false otherwise. It runs at console start only.
+ - `func (s *Server) VerifyDownloads(ctx context.Context) error`: with `cfg.Downloads` and a non-nil `s.downloadObjs` (nil until Task 9 builds the adapter; nil refuses), runs both checks and `dbreads.ValidReplicaPrefix(cfg.HibernatePrefixRaw)` with `cfg.HibernatePrefixRaw == cfg.HibernatePrefix` (`Config` gains `HibernatePrefixRaw`, the untrimmed environment value `cmd/console` reads), and sets `downloadsReady`; logs why and leaves it false otherwise. It runs at console start only.
- `func capabilityEvidence(snap edgesSnapshot, err error, region, capability, dataBucket string) string` (`dbForwardNone`, `dbForwardDead` or `""`); with a non-empty `dataBucket`, a file counts only when its published `DataBucket` equals it (Fable P3-8). `dbForwardEvidence` passes `""`; downloads pass `cfg.HibernateBucket`.
- Refusal whys (each maps to one Task 0 string): `downloadWhyOff`, `downloadWhyMoving`, `downloadWhyTooLarge`, `downloadWhyBusy`, `downloadWhyDaily`. Failure reasons stored on a job: `downloadReasonNotPicked = "not_picked"`, `downloadReasonTimeout = "timeout"`, `downloadReasonTooLarge = "too_large"`, `downloadReasonChanged = "changed"`, `downloadReasonNothing = "nothing"`, `downloadReasonGeneric = "generic"`.
- - `type downloadAvail struct { OK bool; Why string }`. `func (s *Server) downloadsAvailable(ctx context.Context, rec provision.Record) downloadAvail`, with `Why` one of `downloadWhyOff` (not ready, host claims, no root signer whose public half is `ReleasePub`, no capable or live box on complete evidence) or `downloadWhyMoving`. Incomplete evidence admits, as forwarding does.
+ - `type downloadAvail struct { OK bool; Why string }`. `func (s *Server) downloadsAvailable(ctx context.Context, rec provision.Record) downloadAvail`, with `Why` one of `downloadWhyOff` (not ready, host claims, no root signer whose public half is `ReleasePub`, no capable or live box on complete evidence) or `downloadWhyMoving`. Incomplete evidence admits, as forwarding does. `func (s *Server) downloadCapsWhy(ctx context.Context, accountID int64, app, host string, now time.Time) string`: `downloadWhyBusy` or `downloadWhyDaily` from `DBDownloadCounts`, else `""`, so the page can show them before a press (Fable R3 P2-4; the start's 303 has no carrier for a why).
- `func (s *Server) startDBDownload(ctx context.Context, acct *Account, app string, rec provision.Record, actor string, now time.Time) (dbDownload, string /*why*/, error)`: class must be `replicated` (`classifyBackups`), availability ok, `backupsFor`'s restored size ≤ `dbreads.DefaultMaxRestored` (else `downloadWhyTooLarge`; `backupsView` gains an unexported `restoredBytes` from the plan it already reads). Then it reconciles every open job of the account (`OpenDBDownloadsFor`, `reconcileDBDownload`, unthrottled here), so deadlines and expiry that passed while nobody was watching free the cap (Astra P1-2). Then job id `dbreads.MintJobID`, attempt `dbreads.MintID`, incarnation `provision.Incarnation`, `object_key = dbreads.DownloadKey(id)`; `StartDBDownload` (busy and daily map to `downloadWhyBusy`, `downloadWhyDaily`; a `retired` job gets `cancelDBRead(retired.Attempt)`). Only when created: `dispatchDBDownload`.
- - `func (s *Server) dispatchDBDownload(ctx context.Context, d dbDownload, actor string) error` (Astra R2 P1-3): everything after a successful insert runs on one bounded context detached from the browser request, `context.WithTimeout(context.WithoutCancel(ctx), downloadDispatchBound)` with `downloadDispatchBound = 30 * time.Second`, including every failure-state write. First the `db-download` activity row through `RecordActivityContext` (Task 0's detail); audit success stays mandatory: if it fails, `MoveDBDownload(queued→failed, downloadReasonGeneric)` and nothing is published (Fable P2-3). Then sign `Request{Op: OpExport, Job: d.ID, ID: d.Attempt, Account, App, Host, Incarnation, Region: d.Region, By, IssuedAt}`, then create `RequestKey`, then the `QueueKey` entry, then `BumpSerial` (best effort and logged: it is the only thing that wakes a home box, so a lost bump ends the job `not_picked` at the pickup deadline and the person presses again). If the request or queue create fails: `MoveDBDownload(queued→failed, reason downloadReasonGeneric)` and `cancelDBRead(d.Attempt)`, on the same detached context.
+ - `func (s *Server) dispatchDBDownload(ctx context.Context, d dbDownload, actor string) error` (Astra R2 P1-3): everything after a successful insert runs on one bounded context detached from the browser request, `context.WithTimeout(context.WithoutCancel(ctx), downloadDispatchBound)` with `downloadDispatchBound = 30 * time.Second`, Every failure-state write (`MoveDBDownload` to `failed`, `cancelDBRead`) gets its own fresh detached bound of 10 s, so a store call that spent the 30 s doesn't leave the failure unwritten (Fable R3 P3-4). First the `db-download` activity row through `RecordActivityContext` (its detail is Task 0's, placed by this task as a constant in a new `internal/console/downloadcopy.go`; Task 10 adds the page strings there and un-skips the pin test); audit success stays mandatory: if it fails, `MoveDBDownload(queued→failed, downloadReasonGeneric)` and nothing is published (Fable P2-3). Then sign `Request{Op: OpExport, Job: d.ID, ID: d.Attempt, Account, App, Host, Incarnation, Region: d.Region, By, IssuedAt}`, then create `RequestKey`, then the `QueueKey` entry, then `BumpSerial` (best effort and logged: it is the only thing that wakes a home box, so a lost bump ends the job `not_picked` at the pickup deadline and the person presses again). If the request or queue create fails: `MoveDBDownload(queued→failed, reason downloadReasonGeneric)` and `cancelDBRead(d.Attempt)`, each on its own fresh 10 s detached bound.
- `func (s *Server) reconcileDBDownload(ctx context.Context, d dbDownload, now time.Time) dbDownload`, at most one store read per job every `downloadReconcileEvery = 3 * time.Second`. `queued` with `picked` → `preparing`, `owner_deadline = min(picked.Deadline + OwnerGrace, issued + RequestBound)`. Then `result.json`, which must pass `ValidExport(d.ID, d.Attempt)`; a done result also needs `Size(key) == Export.Bytes`, and then becomes `ready` with `ready_at = min(res.Ended, now)`, `expires_at = ready_at + downloadHold`, bytes, txid and `copy_at`. A failed or refused result becomes `failed` with `downloadReasonFor(code)`. With no result: `queued` past `issued + ConsoleWaitsPicked` → `failed`/`not_picked`, and `preparing` past `owner_deadline` → `failed`/`timeout`, each writing the cancel. `ready` past `expires_at` → `expired`. A result that doesn't validate is logged and ignored. Every move is `MoveDBDownload`'s compare-and-set.
- `func downloadReasonFor(code string) string`: `too-large` → `too_large`; `record-changed`, `moving` → `changed`; `nothing-replicated` → `nothing`; `timeout` → `timeout`; anything else → `generic`.
- `func (s *Server) SweepDBDownloads(ctx context.Context)`: reconcile every open job once (and prune), at start.
- [ ] **Step 1: Failing tests:**
- `TestLifecycleCoversDownloads` (table: the Task 1 rules pass; each value at 2 days fails; each value absent fails; a 1-day noncurrent rule with `NewerNoncurrentVersions: 1` fails, and so does an extra covering rule that retains versions; a date-based expiry fails; a disabled rule, a tag-narrowed rule and a `downloads/x/` prefix don't count; a whole-bucket rule counts; a compatible store without abort fails).
- - `TestVerifyDownloadsWithFakeObjects` (a fake `downloadObjects` whose rules retain versions, lack expiry fields, or lack multipart cleanup: `VerifyDownloads` refuses each; an unsafe hibernate prefix refuses; nil objects refuse). The adapter-through-verifier test is Task 9's, where the adapter is built.
+ - `TestVerifyDownloadsWithFakeObjects` (a fake `downloadObjects` whose rules retain versions, lack expiry fields, or lack multipart cleanup: `VerifyDownloads` refuses each; every `no` row of `replica-prefixes.txt` as `HibernatePrefixRaw` refuses; nil objects refuse).
+ - `TestDownloadCapsWhy` (two open → busy; ten today → daily; neither → `""`).
+ - `TestDispatchFailureWritesFreshBound` (a store that blocks past the dispatch bound on the request create: the job still ends `failed` and the cancel is written). The adapter-through-verifier test is Task 9's, where the adapter is built.
- `TestCheckDownloadsEndpoint` (AWS default passes; `http://`, an IP literal, a name resolving to `10.0.0.1`, `127.0.0.1` or `169.254.169.254`, and userinfo are refused; a public name passes).
- `TestDownloadsUnavailable` (each `Why`: not verified, host claims, scoped key, complete evidence with no `db-export-1` box, a moving record; incomplete evidence admits).
- `TestCapabilityEvidenceKeepsForwarding` (`dbForwardEvidence`'s existing cases unchanged).
@@ -259,7 +266,7 @@ Decisions this plan takes (reviewers may overturn them):
- `TestReconcileClampsFutureEnded` (Review Focus 4).
- `TestReconcileConcurrentOneTransition` (Review Focus 5: a status reconcile and `SweepDBDownloads` on one job at once → one move, the other sees false).
- `TestSweepAfterRestart` (a job queued before a "restart", that is a new `Server` over the same `console.db` and store, ends `ready` when its result is there and `failed` when its deadline passed).
-- [ ] **Step 2:** `go test ./internal/console -run 'LifecycleCovers|DownloadsEndpoint|DownloadsUnavailable|CapabilityEvidence|DBForwardEvidence|StartDBDownload|ReconcileDBDownload|ReconcileClamps|ReconcileConcurrent|SweepAfterRestart|FreesAbandoned|AuditFirst|VerifyDownloadsWithFakeObjects|BackupsFor' -count=1` → FAIL.
+- [ ] **Step 2:** `go test ./internal/console -run 'LifecycleCovers|DownloadsEndpoint|DownloadsUnavailable|CapabilityEvidence|DBForwardEvidence|StartDBDownload|ReconcileDBDownload|ReconcileClamps|ReconcileConcurrent|SweepAfterRestart|FreesAbandoned|AuditFirst|VerifyDownloadsWithFakeObjects|DownloadCapsWhy|DispatchFailureWrites|BackupsFor' -count=1` → FAIL.
- [ ] **Step 3:** Implement.
- [ ] **Step 4:** PASS.
- [ ] **Step 5:** Commit.
@@ -283,7 +290,7 @@ Decisions this plan takes (reviewers may overturn them):
- [ ] **Step 1: Failing tests** (`newConsoleFixture`, `signInAs`, a fake `downloadObjects`):
- `TestDBDownloadStartTwoTabs` (Review Focus 1: two concurrent POSTs → one job, one request object).
- `TestDBDownloadGateUniform` (Astra P1-5: for each of the three doors, no session, a service token, an ambiguous account segment, another account's member, a linked-app refusal, a missing or wrong CSRF on the POSTs, a bad host and an unknown host all give the same status, the same body bytes and no `Location` header).
- - `TestDBDownloadStartRefusals` (other region, pooled, fleet, demo, no-sleep, host claims, not verified → no job and the page's why).
+ - `TestDBDownloadStartRefusals` (other region, pooled, fleet, demo, no-sleep, host claims, not verified, busy, daily → `startDBDownload` returns the expected why, no job row is written, and the door answers its 303; the page line is Task 10's test, Fable R3 P2-4).
- `TestDBDownloadLinkSignsExactObject` (the presigner gets exactly `DownloadKey(job)`, the filename, and a ttl of 15 minutes, or what's left when that is less; headers `no-store` and `no-referrer`; `Location` is the URL).
- `TestDBDownloadRecreated` (Review Focus 2: with a ready and with a preparing job, recreate the instance; status and link → 404, presigner never called; the instance page shows no old job; a start retires the old job, writes its cancel and admits a fresh one) and `TestDBDownloadLinkRemovedMember` (Review Focus 3: status and link → 404, presigner never called).
- `TestDBDownloadLinkExpiredAndMissing` (past `expires_at` → 404, no presign; object gone → `expired`, 404).
@@ -304,11 +311,11 @@ Decisions this plan takes (reviewers may overturn them):
- Consumes: Tasks 7-9.
- Produces:
- `type downloadSection struct { State string; Button, Note, Why string; Enabled, Poll bool; StartURL, LinkURL, StatusURL string }`.
- - `func downloadSectionFor(d *dbDownload /*nil: no job*/, avail downloadAvail, v backupsView, host string, now time.Time) *downloadSection` (pure). A failed job's reason line comes from its stored `downloadReason*` (`too_large` uses `backups.toolarge`). It gives nil for classes other than `replicated` and `not_shown`/`too_large_to_plan`, whose existing Why lines and commands stand. Too large gives `backups.toolarge` and no button. Not available gives its why and no button. None, failed and expired give "Download a copy" (failed adds its reason line). Queued or preparing give "Preparing your copy", disabled, with the note and `Poll`. Ready gives "Download {file} ({size})" (`humanBytes`) and "Ready until {time} tomorrow." (`expires_at` as `15:04 UTC`).
+ - `func downloadSectionFor(d *dbDownload /*nil: no job*/, avail downloadAvail, capsWhy string, v backupsView, host string, now time.Time) *downloadSection` (pure). `instanceBackups` passes `downloadCapsWhy`'s answer; with no open job for the instance and a non-empty `capsWhy`, the section shows that why and no enabled button, before any press (Fable R3 P2-4). A failed job's reason line comes from its stored `downloadReason*` (`too_large` uses `backups.toolarge`). It gives nil for classes other than `replicated` and `not_shown`/`too_large_to_plan`, whose existing Why lines and commands stand. Too large gives `backups.toolarge` and no button. Not available gives its why and no button. None, failed and expired give "Download a copy" (failed adds its reason line). Queued or preparing give "Preparing your copy", disabled, with the note and `Poll`. Ready gives "Download {file} ({size})" (`humanBytes`) and "Ready until {time} tomorrow." (`expires_at` as `15:04 UTC`).
- The template puts the action in `.sectionhead` beside the heading, as two forms with the CSRF field (start, link), never a link carrying a URL. An inline script polls `StatusURL` every 5 s while `Poll`, stops after 25 minutes, and reloads the page when the state leaves `queued`/`preparing`. Without script, a reload shows the state.
-- [ ] **Step 1: Failing tests:** `TestInstancePageReconciles` (Astra R2 P2-4: a preparing job whose `result.json` and object are published shows ready on a plain page GET, with no status call and no script; a ready job past `expires_at` shows the button back on a plain GET; a job whose binding fails is neither shown nor reconciled); `TestDownloadSectionFor` (table over every state and why, exact strings from the records); `TestInstancePageDownloadStates` (rendered page: one primary button in the section head; preparing disabled with the note and the poll script; ready shows file, size and time; refused shows the why, the CLI disclosure and no enabled button); `TestInstancePageBackupsNoForbiddenWords` extended to every download state ("backed up", "up to date", "current", "✓", "downloaded"); `TestApprovedMemberBackupsCopy`, `TestApprovedMemberBackups1bCopy`.
-- [ ] **Step 2:** `go test ./internal/console . -run 'InstancePageReconciles|DownloadSectionFor|InstancePageDownload|InstancePageBackups|ApprovedMemberBackups|TestConsoleStyleguideClassesExist' -count=1` → FAIL.
+- [ ] **Step 1: Failing tests:** `TestInstancePageReconciles` (Astra R2 P2-4: a preparing job whose `result.json` and object are published shows ready on a plain page GET, with no status call and no script; a ready job past `expires_at` shows the button back on a plain GET; a job whose binding fails is neither shown nor reconciled); `TestDownloadSectionFor` (table over every state and why, `busy` and `daily` included, exact strings from the records); `TestInstancePageCapsWhy` (an account with two open jobs and an instance with ten starts today each show their line and no enabled button on a plain GET); `TestInstancePageDownloadStates` (rendered page: one primary button in the section head; preparing disabled with the note and the poll script; ready shows file, size and time; refused shows the why, the CLI disclosure and no enabled button); `TestInstancePageBackupsNoForbiddenWords` extended to every download state ("backed up", "up to date", "current", "✓", "downloaded"); `TestApprovedMemberBackupsCopy`, `TestApprovedMemberBackups1bCopy`.
+- [ ] **Step 2:** `go test ./internal/console . -run 'InstancePageReconciles|InstancePageCapsWhy|DownloadSectionFor|InstancePageDownload|InstancePageBackups|ApprovedMemberBackups|TestConsoleStyleguideClassesExist' -count=1` → FAIL.
- [ ] **Step 3:** Implement with styleguide classes only (`docs/console-styleguide.md`), as the UX pass mocked it; no left-border accents.
- [ ] **Step 4:** PASS. Screenshot the section at 390 px and desktop against Task 0's mock and attach both to the task report.
- [ ] **Step 5:** Commit.
@@ -320,14 +327,14 @@ Decisions this plan takes (reviewers may overturn them):
**Interfaces:**
- Consumes: everything above, through production wiring: the real console handlers and `NewS3DownloadObjects`, a real `dbreads.Agent` with `lease.NewDownloadStore`, and `ServeWorker` reached through a test socket (labelled non-acceptance, as `TestDBForwardMinio` is).
-- [ ] **Step 1: The fixture.** In the dbf section: a versioned data bucket for the region, `scripts/downloads-ilm.sh` run on it with the fixture's replica prefix (the same gate operators use), importing the AWS-shaped `downloads/` rules with the Task 1 values (abort included); if MinIO refuses the abort element or drops it on read-back, stop and bring it to the controller rather than waive it in code, a box user allowed `s3:PutObject` and `s3:GetObject` on `downloads/*` there, and the console user allowed `s3:GetLifecycleConfiguration` and `s3:GetObject` on it. Run `TestDBDownloadMinio` with `CARLOS_MINIO_TEST=1`, and fail the step unless `--- PASS: TestDBDownloadMinio (` appears.
+- [ ] **Step 1: The fixture.** In the dbf section, first run `sh scripts/downloads-ilm_test.sh` and fail the step on a non-zero exit, before any lifecycle installation (Astra R3 P2-2); its stub assertion that refused inputs never call `mc` stays. Then run the real `scripts/downloads-ilm.sh` with `downloads` against the fixture bucket and require exit 2 and an empty `mc ilm export` (Fable R3 P2-2). Then: a versioned data bucket for the region, `scripts/downloads-ilm.sh` run on it with the fixture's replica prefix (the same gate operators use), importing the AWS-shaped `downloads/` rules with the Task 1 values (abort included); if MinIO refuses the abort element or drops it on read-back, stop and bring it to the controller rather than waive it in code, a box user allowed `s3:PutObject` and `s3:GetObject` on `downloads/*` there, and the console user allowed `s3:GetLifecycleConfiguration` and `s3:GetObject` on it. Run `TestDBDownloadMinio` with `CARLOS_MINIO_TEST=1`, and fail the step unless `--- PASS: TestDBDownloadMinio (` appears.
- [ ] **Step 2: The witness.** Replicate a database into the region's prefix. Then `VerifyDownloads` (with the endpoint check seamed, since CI's MinIO is plain HTTP on loopback; Task 8's unit test owns that check), POST start as a member, run the home agent's (`ExportOnly`, region `""`) `Pass` once, as its nudge would, poll status until `ready`, and POST link. GET the URL with a plain `http.Client`: the zip opens, `db.sqlite3` passes `PRAGMA integrity_check` and holds the replicated rows, and the manifest's SHA-256 matches. Then remove the rule and restart: `VerifyDownloads` refuses and start answers the off why.
- [ ] **Step 3:** Push the branch and read `amadan ci status carlos/platform -branch <branch>`; the MinIO step must show the PASS line.
- [ ] **Step 4:** Commit.
### Task 12: Census and branch close
-- [ ] **Step 1: Root-read census.** `make census-card`; write `docs/superpowers/notes/census-claims-member-backups-1b.txt`, one claim per changed root-binary unit: the `dbreads` wire (export op, job ids, result, home scope), the worker's export, the agent's export and upload, `lease.NewDownloadStore`, the host's arming (every home box with hibernation configured, pool and demo boxes included; refused with `CARLOS_FLEET` set), nudge and capabilities, and the infra files (lifecycle rules, the lifecycle read grant). Run `make census-propose NAME=member-backups-1b CLAIMS=<file>`, brief Astra from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, record the verdict on #280, and commit the overlay, the chain line and the proposal.
+- [ ] **Step 1: Root-read census.** `make census-card`; write `docs/superpowers/notes/census-claims-member-backups-1b.txt`, one claim per changed root-binary unit: the `dbreads` wire (export op, job ids, result, home scope), the worker's export, the agent's export and upload, `lease.NewDownloadStore`, the host's arming (every home box with hibernation configured, pool and demo boxes included; refused with `CARLOS_FLEET` set), nudge and capabilities, the infra files (lifecycle rules, the prefix variable and its validation, the lifecycle read grant), `scripts/downloads-ilm.sh` and its test, `go.mod`, `internal/dbdoor/plan_from.go` (`MaxPlanFiles`) and `internal/dbreads/prefix.go` (Fable R3 P3-3). Tofu tests don't run in CI: paste the local `tofu test` output for the three modules into the task report. Run `make census-propose NAME=member-backups-1b CLAIMS=<file>`, brief Astra from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, record the verdict on #280, and commit the overlay, the chain line and the proposal.
- [ ] **Step 2: Record-write census.** `go test ./internal/provision -run TestPlan9B8RecordWriteCensus -count=1`; for every new write site it names (the console's request and queue creates, the agent's result and upload), add an inventory in `internal/provision/db_downloads_census_test.go` following `db_region_forward_census_test.go`.
- [ ] **Step 3:** Changed packages only, with `-run` for every test named in Tasks 1-11; `gofmt -l .` clean; push; `amadan ci status` green.
- [ ] **Step 4:** Whole-branch review by Astra, three rounds at most, with Task 3 called out for a security read; Fable reads Task 3 again in the whole-branch review.
@@ -340,15 +347,15 @@ Each task's new symbols and the first later task that uses them. No task uses a
| Task | New symbols | First used by |
|---|---|---|
-| 0 | 1b copy record, `TestApprovedMemberBackups1bCopy` (skipped), re-approved `backups.preparing.note` | Task 8 (audit details), Task 10 (page strings, un-skip) |
-| 1 | `downloads_replica_prefix`, `downloads-expire`/`downloads-delete-markers` rules, `downloads_lifecycle` output, `scripts/downloads-ilm.sh`, the lifecycle read grant | Task 8 (verifier expects these values), Task 11 (fixture runs the script) |
-| 2 | `OpExport`, `ExportCapability`, `DownloadsPrefix`, `NewJobID`/`MintJobID`/`ValidJobID`/`DownloadKey`, `Request.Job`, `ExportOutcome`, `Result.Export`, `ValidExport`, `HelloReply.Ops`, `readyMsg.Bytes`, `Manifest` | Task 3 (`OpExport`, `ExportCapability`, `HelloReply.Ops`), Task 4 (`readyMsg.Bytes`), Task 5 (`Manifest`, `ExportOutcome`, `DownloadKey`), Task 6 (`DownloadsPrefix`), Task 8 (`MintJobID`, `ValidExport`, `Request.Job`) |
-| 3 | `HomeScope`, `QueueScope`, `DownloadStore`, `AgentConfig.ExportOnly`/`Downloads`, `NewAgent` → `(*Agent, error)`, `ExportCapable`, `listTick`, `passAgain`, `dbExportNudge`/`nudgeDBExports`, `withDBReadCapabilities`, `dbReadsEnv.exportOnly` | Task 5 (`DownloadStore`, `Downloads`, `ExportCapable`, `passAgain`), Task 6 (`DownloadStore`, `exportOnly`, `armDBReads`), Task 8 (`QueueKey` via `QueueScope`, `ExportCapability`) |
-| 4 | worker `OpExport` path, hello `Ops` | Task 5 |
+| 0 | 1b copy record, `TestApprovedMemberBackups1bCopy` (skipped), re-approved `backups.preparing.note` | Task 8 (copies the two audit details into `downloadcopy.go`), Task 10 (page strings there, un-skip, which then pins all of them) |
+| 1 | `replica-prefixes.txt`, `downloads_replica_prefix`, `downloads-expire`/`downloads-delete-markers` rules, `downloads_lifecycle` output, `scripts/downloads-ilm.sh`, the lifecycle read grant | Task 2 (prefix table and tofu cross-check), Task 8 (verifier expects these values), Task 11 (fixture runs the script and its test) |
+| 2 | `OpExport`, `ExportCapability`, `DownloadsPrefix`, `NewJobID`/`MintJobID`/`ValidJobID`/`DownloadKey`, `Request.Job`, `ExportOutcome`, `Result.Export`, `ValidExport`, `HelloReply.Ops` (field), `readyMsg.Bytes`, `Manifest`, `ValidReplicaPrefix` | Task 3 (`OpExport`, `ExportCapability`, `HelloReply.Ops` via a stubbed hello), Task 4 (`readyMsg.Bytes`, fills `Ops`), Task 5 (`Manifest`, `ExportOutcome`, `DownloadKey`), Task 6 (`DownloadsPrefix`, `ValidReplicaPrefix`), Task 8 (`MintJobID`, `ValidExport`, `Request.Job`, `ValidReplicaPrefix`) |
+| 3 | `HomeScope`, `QueueScope`, `DownloadStore`, `AgentConfig.ExportOnly`/`Downloads`, `NewAgent` → `(*Agent, error)`, `ExportCapable`, `listTick`, `passAgain`, `passWhenReady`, `dbExportNudge`/`nudgeDBExports`, `withDBReadCapabilities`, `dbReadsEnv.exportOnly` | Task 5 (`DownloadStore`, `Downloads`, `ExportCapable`, `passAgain`), Task 6 (`DownloadStore`, `exportOnly`, `armDBReads`), Task 8 (`QueueKey` via `QueueScope`, `ExportCapability`) |
+| 4 | worker `OpExport` path, the hello's `Ops` values | Task 5 |
| 5 | `Agent.export`, `dbdoor.MaxPlanFiles` | Task 5 itself (`backups.go`), Task 11 |
-| 6 | `lease.NewDownloadStore`, host `downloadsPrefixSafe`, `armDBReads` wiring of `Downloads` | Task 11 |
-| 7 | `db_downloads` table, `dbDownload`, `StartDBDownload`, `DBDownloadFor`, `OpenDBDownloads`/`OpenDBDownloadsFor`, `MoveDBDownload`, caps, `errDownloadsBusy`/`errDownloadsDaily` | Task 8 |
-| 8 | `lifecycleRule`, `downloadObjects`, `lifecycleCoversDownloads`, `checkDownloadsEndpoint`, `VerifyDownloads`, console `downloadsPrefixSafe`, `capabilityEvidence`, `downloadAvail`, whys and reasons, `startDBDownload`, `dispatchDBDownload`, `reconcileDBDownload`, `downloadReasonFor`, `SweepDBDownloads`, `Config.Downloads`/`DownloadsEndpoint` | Task 9 (doors, adapter test), Task 10 (`downloadAvail`, reasons, `reconcileDBDownload`) |
+| 6 | `lease.NewDownloadStore`, `armDBReads` wiring of `Downloads` (raw-prefix check) | Task 11 |
+| 7 | `db_downloads` table, `dbDownload`, `StartDBDownload`, `DBDownloadFor`, `OpenDBDownloads`/`OpenDBDownloadsFor`, `MoveDBDownload`, `DBDownloadCounts`, caps, `errDownloadsBusy`/`errDownloadsDaily` | Task 8 |
+| 8 | `lifecycleRule`, `downloadObjects`, `lifecycleCoversDownloads`, `checkDownloadsEndpoint`, `VerifyDownloads`, `Config.HibernatePrefixRaw`, `downloadcopy.go` (audit details), `capabilityEvidence`, `downloadAvail`, `downloadCapsWhy`, whys and reasons, `startDBDownload`, `dispatchDBDownload`, `reconcileDBDownload`, `downloadReasonFor`, `SweepDBDownloads`, `Config.Downloads`/`DownloadsEndpoint` | Task 9 (doors, adapter test), Task 10 (`downloadAvail`, `downloadCapsWhy`, reasons, `reconcileDBDownload`) |
| 9 | three routes, parity row, `downloadGate`, `downloadJob`, `downloadFilename`, `NewS3DownloadObjects` (and its wiring in `cmd/console`) | Task 10 (`downloadJob`, `downloadFilename`, URLs), Task 11 (adapter) |
| 10 | `downloadSection`, `downloadSectionFor`, template and script, `cli.md` paragraph | none |
| 11 | `TestDBDownloadMinio`, its fixture | Task 12 (CI green) |
@@ -371,7 +378,7 @@ Each task's new symbols and the first later task that uses them. No task uses a
| P2-2 recreated instance stuck behind the old job | Fable | Accepted | Fixed with Astra P2-6 |
| P2-3 export can run with no audit row | Fable | Accepted | The `db-download` row is written after the job row and before publication; a failed write fails the job unpublished; `TestStartDBDownloadAuditFirst`. Not in the same SQL transaction: activity writes go through `withAutoAppSQL` (`store.go:3314`), and ordering gives the same guarantee |
| P2-4 Task 3 not self-contained | Fable | Accepted (controller ruling) | Fixed with Astra P1-3 |
-| P2-5 `downloads/` rule can reach replicas under an unusual prefix | Fable | Accepted | `downloadsPrefixSafe` on the box (Task 6) and in `VerifyDownloads` (Task 8); operator docs line (Task 0) |
+| P2-5 `downloads/` rule can reach replicas under an unusual prefix | Fable | Accepted | (rev 5: superseded by `dbreads.ValidReplicaPrefix`) `downloadsPrefixSafe` on the box (Task 6) and in `VerifyDownloads` (Task 8); operator docs line (Task 0) |
| P3-6 regional boxes gain an unused op | Fable | Accepted (controller ruling) | `Downloads` only on export-only agents; `NewAgent` refuses the mix; regional boxes never publish `db-export-1` |
| P3-7 gate not uniformly 404 | Fable | Accepted | Fixed with Astra P1-5 |
| P3-8 capability evidence ignores the data bucket | Fable | Accepted | `capabilityEvidence` matches the published `DataBucket` for downloads; test in Task 8 |
@@ -397,3 +404,21 @@ Each task's new symbols and the first later task that uses them. No task uses a
| R2 P1-2 caller migrations and adapter test order | Astra | Accepted (controller choice: one complete dependency pass) | Verified the callers by grep; every `NewAgent` and capability-helper caller is migrated in Task 3, with a grep check; `TestVerifyDownloadsThroughAdapter` moved to Task 9, Task 8 tests with a fake; "Dependency check" table added |
| R2 P1-3 disconnect after insert can stop dispatch | Astra | Accepted | Verified `withAutoAppSQL` → `demoClaimMutationRefusal` uses the caller's context; `dispatchDBDownload` runs audit, publication and failure writes on one bounded detached context; the disconnect witness goes through the real activity helper (Task 8) |
| R2 P2-4 a plain reload doesn't reconcile | Astra | Accepted | The instance page reconciles after the binding check under the existing throttle; `TestInstancePageReconciles` (Task 10); no background polling |
+
+## Plan review round 3: dispositions (final; Paul 2026-11-12: no fourth round)
+
+| Finding | Reviewer | Disposition | How |
+|---|---|---|---|
+| R3 P1 the gate accepts prefixes that resolve into `downloads/` | Astra | Accepted (Paul's ruling: the strict contract) | Verified `activator.go:141` (trim) and `:166` (`path.Join`); one replica-prefix contract (`dbreads.ValidReplicaPrefix`, the same expression in tofu and the script, one shared case table with `instances/../downloads`, `.`, `instances/..`, ` instances`, `instances//x` and more), enforced at plan time, before any `mc` call, and at run time on the raw environment value (Tasks 1, 2, 6, 8) |
+| R3 P2-2 CI never runs the refusal test | Astra | Accepted | `30-minio-contract` runs `sh scripts/downloads-ilm_test.sh` before installation and fails on non-zero; the stub assertion stays (Task 11) |
+| R3 P2-3 the completion pass can run before admission is ready | Astra | Accepted (controller's choice under stopping rule 2: the single readiness invariant) | Verified `read.go:25` and `admission.go:46`; `passWhenReady` waits for the slot release and `settle`, bounded by the pickup window, then sends the one pass; `TestExportSharesReadSlots` forces the race with `inProcWorkers.linger` |
+| R3 P2-1 the refusal checks a different string from the box | Fable | Accepted | Fixed with Astra R3 P1; the operator docs state the variable is a declaration tofu can't check against `host.env` |
+| R3 P2-2 refusal tests run nowhere in CI | Fable | Accepted | Fixed with Astra R3 P2-2, plus a real-script run with `downloads` that must exit 2 and leave `mc ilm export` empty; tofu output pasted into Task 12's report |
+| R3 P2-3 after-export pass before admission | Fable | Accepted | Fixed with Astra R3 P2-3 |
+| R3 P2-4 `busy`/`daily` never reach the page | Fable | Accepted | `DBDownloadCounts` (Task 7), `downloadCapsWhy` (Task 8), the page shows them before a press (Task 10); Task 9 asserts the returned why and no row, Task 10 the page line |
+| R3 P3-1 hello advertises export two tasks early | Fable | Accepted | Task 2 adds the field only; Task 4 fills `Ops`; Task 3 stubs the hello |
+| R3 P3-2 the prefix pin test can't be written | Fable | Accepted | One exported `dbreads.ValidReplicaPrefix`; the host and console copies are gone |
+| R3 P3-3 census scope is short | Fable | Accepted | Verified `plan14_root_reads_test.go:252` (`.sh`, `go.mod`); Global Constraints and Task 12's claims list them |
+| R3 P3-4 failure writes share the spent context | Fable | Accepted | Each failure write gets a fresh 10 s detached bound; `TestDispatchFailureWritesFreshBound` |
+| R3 P3-5 Step 0 reads a partial log | Fable | Accepted | Verified `agent.go:3191` (`slowLegAfter`); Step 0 sums the legs per tick and treats no lines as under about 10 s |
+| R3 dependency-table rows | Fable | Accepted | Task 6's row no longer claims a prefix helper; Task 0's audit strings live in `downloadcopy.go` from Task 8; Task 9's page assertion moved to Task 10 |