backup: movement-compose — the movement half goes production-real #203

Closed
opened 2026-07-30 23:20:06 +00:00 by ben · 3 comments
Owner

Parent

Backups spec #20 (ADR 0104). Gap audit 2026-07-30 (post #191–#195 sweep of the composition roots and both app shells). Filed per the #191–#195 precedent: a close-out blocker of #183 found while preparing the run, confirmed by Ben.

What's true today

  • The real backup engine runs in production (#170) — but its movement half is unwired there: a replicate returns the honest movement-not-wired refusal. The real target byte surfaces (mesh store for cross-device, directory for the raw read-back), the target resolver and the crown-jewel keys exist only inside the smoke binary that proved family 4 on the lab (#177).
  • The config-repo policy store exists and is never wired — backup policy does not survive a restart. The dataset port in production is an empty catalogue — nothing can ever be enumerated for coverage.

What to build

Compose the movement half in the whole composition: the target resolver over the real stores, the crown-jewel keys, the config-repo policy store, and a real dataset enumeration for the provisioned services. The resting branch keeps the honest refusal. The smoke's proven code promotes; nothing is re-invented.

Acceptance criteria

  • Given a policy set through the dashboard, When the control plane restarts, Then the policy persists (config-repo store)
  • Given a covered dataset and a reachable target device, When a run replicates, Then the sealed artifact + self-describing inventory land on the target and the sampled restore-test passes
  • Given the sealed artifact, When read back with the keys and age alone, Then it opens (ADR 0104's raw read-back)
  • Given the resting composition, Then the honest movement refusal — unchanged

Task manifest

task: backup:movement-compose
implements_seam: "backup engine movement half (ADR 0104) — the family-close compose #177 proved on the lab"
interface: "production replicate/restore over real targets"
seam: "a composition seam test over a directory target + the engine's own restore-test"
acceptance:
  - given: policy + target; when: a run replicates in the whole composition; then: sealed artifact on the real target, restore-test passes, policy persists
depends_on: []
out_of_scope: [S3 offsite partner surface beyond the existing store, new policy semantics]
needs_human_decision: []

Blocks

#183 — leg B·4 (and B·7's restore rides the same machinery).

## Parent Backups spec #20 (ADR 0104). Gap audit 2026-07-30 (post #191–#195 sweep of the composition roots and both app shells). Filed per the #191–#195 precedent: a close-out blocker of #183 found while preparing the run, confirmed by Ben. ## What's true today - The real backup engine runs in production (#170) — but its movement half is unwired there: a replicate returns the honest movement-not-wired refusal. The real target byte surfaces (mesh store for cross-device, directory for the raw read-back), the target resolver and the crown-jewel keys exist only inside the smoke binary that proved family 4 on the lab (#177). - The config-repo policy store exists and is never wired — backup policy does not survive a restart. The dataset port in production is an empty catalogue — nothing can ever be enumerated for coverage. ## What to build Compose the movement half in the whole composition: the target resolver over the real stores, the crown-jewel keys, the config-repo policy store, and a real dataset enumeration for the provisioned services. The resting branch keeps the honest refusal. The smoke's proven code promotes; nothing is re-invented. ## Acceptance criteria - [ ] Given a policy set through the dashboard, When the control plane restarts, Then the policy persists (config-repo store) - [ ] Given a covered dataset and a reachable target device, When a run replicates, Then the sealed artifact + self-describing inventory land on the target and the sampled restore-test passes - [ ] Given the sealed artifact, When read back with the keys and `age` alone, Then it opens (ADR 0104's raw read-back) - [ ] Given the resting composition, Then the honest movement refusal — unchanged ## Task manifest ```yaml task: backup:movement-compose implements_seam: "backup engine movement half (ADR 0104) — the family-close compose #177 proved on the lab" interface: "production replicate/restore over real targets" seam: "a composition seam test over a directory target + the engine's own restore-test" acceptance: - given: policy + target; when: a run replicates in the whole composition; then: sealed artifact on the real target, restore-test passes, policy persists depends_on: [] out_of_scope: [S3 offsite partner surface beyond the existing store, new policy semantics] needs_human_decision: [] ``` ## Blocks #183 — leg B·4 (and B·7's restore rides the same machinery).
Author
Owner

Blocked on a human decision — production crown-jewel backup-key provenance (asked via chat, no reply within the window; posting the durable record here).

The task asks to compose the movement half with "the crown-jewel keys" that "promote from the smoke #177". On investigation, no production backup.CrownJewelKeys source exists:

  • The only implementations of Key(ref) (backup.Key, bool) are hardcoded in-memory literals inside the two smoke binaries (keysFor() → Key("crown-jewel-key-for-"+id) at control-plane/cmd/smoke-backups/main.go:939). Promoting that literally to production would ship a world-known backup-encryption key — a fake-success / security break (ADR 0100).
  • Founding seeds infra crown jewels only — crownJewelKeys = {root-ca, ssh-ca, config-repo, gateway-vars} (internal/founding/seed.go:278, ADR 0044). There is no backup key var and no reader turning a secret-store var into backup.CrownJewelKeys.
  • ADR 0082 §4 / 0044 require backup keys to live in the founding-seeded crown-jewel secret store (clan vars encrypted to machine + recovery-kit recipients, operator keys deliberately excluded so a repo replica cannot read them). So keys in a plain config-repo document would violate 0082 §4.

The runtime read path exists (deps.clan.Vars().Get(ctx, node, ref) → clan.Secret), but nothing seeds a backup key for it to read.

Decision needed — where do production backup crown-jewel keys come from?

  • (A) Seed a 5th crown-jewel clan var at founding (the ADR 0044 mechanism) + a runtime clan.Vars().Get-backed CrownJewelKeys deriving per-dataset keys via HKDF. ADR-correct, but touches the founding arc (another family/slice) and needs a migration story for already-founded communities.
  • (B) A config-repo backup-keys document minted on first confirm (like the policy store). Survives restart and is captured by the recovery kit, but keys become readable by any repo-replica holder — contradicts ADR 0082 §4 / 0044.
  • (C) Land only the unambiguous real parts this slice — config-repo policy store (AC1 restart persistence), real dataset enumeration, directory/SSH target resolver — but keep movement's keys unwired (the honest ErrMovementNotWired refusal stays), deferring key provenance to a dedicated founding-seeding slice. AC2/AC3 (real replicate + raw read-back) then stay unmet this slice.

I lean (A) for correctness, but it is cross-feature and large; (C) is the smallest honest step that violates no ADR. The manifest's needs_human_decision was empty, but this is the load-bearing choice on which AC2/AC3 depend.

To re-arm: pick A/B/C (or another mechanism), then re-add ready-for-agent. A late chat reply on the existing thread will still land.

**Blocked on a human decision — production crown-jewel backup-key provenance (asked via chat, no reply within the window; posting the durable record here).** The task asks to compose the movement half with "the crown-jewel keys" that "promote from the smoke #177". On investigation, **no production `backup.CrownJewelKeys` source exists**: - The only implementations of `Key(ref) (backup.Key, bool)` are hardcoded in-memory literals inside the two smoke binaries (`keysFor()` → `Key("crown-jewel-key-for-"+id)` at `control-plane/cmd/smoke-backups/main.go:939`). Promoting that literally to production would ship a world-known backup-encryption key — a fake-success / security break (ADR 0100). - Founding seeds infra crown jewels only — `crownJewelKeys = {root-ca, ssh-ca, config-repo, gateway-vars}` (`internal/founding/seed.go:278`, ADR 0044). There is **no** backup key var and no reader turning a secret-store var into `backup.CrownJewelKeys`. - ADR 0082 §4 / 0044 require backup keys to live in the founding-seeded crown-jewel secret store (clan vars encrypted to machine + recovery-kit recipients, operator keys deliberately excluded so a repo replica cannot read them). So keys in a plain config-repo document would violate 0082 §4. The runtime read path exists (`deps.clan.Vars().Get(ctx, node, ref)` → `clan.Secret`), but nothing seeds a backup key for it to read. **Decision needed — where do production backup crown-jewel keys come from?** - **(A)** Seed a 5th crown-jewel clan var at founding (the ADR 0044 mechanism) + a runtime `clan.Vars().Get`-backed `CrownJewelKeys` deriving per-dataset keys via HKDF. ADR-correct, but touches the founding arc (another family/slice) and needs a migration story for already-founded communities. - **(B)** A config-repo backup-keys document minted on first confirm (like the policy store). Survives restart and is captured by the recovery kit, but keys become readable by any repo-replica holder — contradicts ADR 0082 §4 / 0044. - **(C)** Land only the unambiguous real parts this slice — config-repo policy store (AC1 restart persistence), real dataset enumeration, directory/SSH target resolver — but keep movement's keys **unwired** (the honest `ErrMovementNotWired` refusal stays), deferring key provenance to a dedicated founding-seeding slice. AC2/AC3 (real replicate + raw read-back) then stay unmet this slice. I lean **(A)** for correctness, but it is cross-feature and large; **(C)** is the smallest honest step that violates no ADR. The manifest's `needs_human_decision` was empty, but this is the load-bearing choice on which AC2/AC3 depend. **To re-arm:** pick A/B/C (or another mechanism), then re-add `ready-for-agent`. A late chat reply on the existing thread will still land.
Author
Owner

Human ruling (chat thread, 2026-07-31) — crown-jewel backup-key provenance:

Go with A, a 5th crown-jewel clan var at founding.

So this slice takes Option (A) from the prior blocked run: seed a 5th crown-jewel clan var at founding (the ADR 0044 mechanism) + a runtime clan.Vars().Get-backed CrownJewelKeys deriving per-dataset keys via HKDF. Building the movement half fully (real replicate/restore over a directory target, raw age read-back) on top of that seeded key, plus the config-repo policy store and real dataset enumeration. The resting branch keeps the honest ErrMovementNotWired refusal.

**Human ruling (chat thread, 2026-07-31) — crown-jewel backup-key provenance:** > Go with A, a 5th crown-jewel clan var at founding. So this slice takes **Option (A)** from the prior blocked run: seed a 5th crown-jewel clan var at founding (the ADR 0044 mechanism) + a runtime `clan.Vars().Get`-backed `CrownJewelKeys` deriving per-dataset keys via HKDF. Building the movement half fully (real replicate/restore over a directory target, raw age read-back) on top of that seeded key, plus the config-repo policy store and real dataset enumeration. The resting branch keeps the honest `ErrMovementNotWired` refusal.
Author
Owner

Done — landed in 87a0b4f on origin/main (backup:movement-compose).

Human ruling followed: option A — a fifth crown-jewel clan var backup-root seeded at founding + a runtime CrownJewelKeys reader.

What shipped

  • Founding (internal/founding/seed.go): backup-root added to crownJewelKeys — the fifth crown jewel, encrypted to the node machine key + recovery material only, operator keys excluded (ADR 0044). TestStory25 updated to expect five.
  • Runtime key reader (internal/backup/keys_crownjewel.go): CrownJewelKeyReader reads the root via clan.Vars().Get and derives each dataset key by HMAC-SHA256(root, keyRef) — one key per dataset, unreproducible without the root (ADR 0082 §4). Refuses honestly (ok=false) before the store holds the root.
  • Target resolver over real stores (internal/backupengine/targets.go): StoreResolver → local DirStore for the gateway's own node, SSH-reached SSHStore for a cross-device node (both promoted from the #177 smoke). Offsite S3 refuses honestly (later slice).
  • Whole composition (whole_composition.go / backup_wiring.go): wholeBackupPorts wires WithMovement(keys, resolver) + WithPolicyStore(ConfigRepo…). Resting composition keeps ErrMovementNotWired (AC4).
  • Policy persistence (policy.go / backup.go / policystore_configrepo.go): new PolicyLoader — backup.New rehydrates every committed policy at construction, so a confirmed policy survives a restart (AC1 — the missing piece; the store persisted on commit but nothing reloaded it).
  • New env OURCLOUD_NODE names the gateway's own clan node id.

Acceptance

  • AC1 policy persists across restart — TestMovementCompose_PolicyPersistsAcrossRestart.
  • AC2 replicate lands the sealed artifact + inventory, restore-test passes — TestMovementCompose_ProductionKeysAndStore_ReplicatesAndReadsBackRaw + composition-root …WholeWiresMovementAndReadsBackRaw.
  • AC3 raw read-back with the keys alone — the sealed bytes open with a fresh reader + backup.Open + a JSON reader; a different root cannot open it. (The seal is AES-GCM backup.Seal, the settled #177 one-encryption-story — ADR 0104's "age" wording is that same sealed-artifact path, per STATUS.md's existing note.)
  • AC4 resting keeps the honest refusal — TestMovementCompose_RestingKeepsHonestRefusal.

Note: the Sandcastle sandbox has no Go toolchain (#198), so this was verified by careful review across the three packages; the seam run is the first real compile/test. Unblocks #183 leg B·4 (and B·7's restore rides the same machinery).

Done — landed in `87a0b4f` on `origin/main` (backup:movement-compose). **Human ruling followed:** option A — a fifth crown-jewel clan var `backup-root` seeded at founding + a runtime `CrownJewelKeys` reader. **What shipped** - **Founding** (`internal/founding/seed.go`): `backup-root` added to `crownJewelKeys` — the fifth crown jewel, encrypted to the node machine key + recovery material only, operator keys excluded (ADR 0044). `TestStory25` updated to expect five. - **Runtime key reader** (`internal/backup/keys_crownjewel.go`): `CrownJewelKeyReader` reads the root via `clan.Vars().Get` and derives each dataset key by HMAC-SHA256(root, keyRef) — one key per dataset, unreproducible without the root (ADR 0082 §4). Refuses honestly (ok=false) before the store holds the root. - **Target resolver over real stores** (`internal/backupengine/targets.go`): `StoreResolver` → local `DirStore` for the gateway's own node, SSH-reached `SSHStore` for a cross-device node (both promoted from the #177 smoke). Offsite S3 refuses honestly (later slice). - **Whole composition** (`whole_composition.go` / `backup_wiring.go`): `wholeBackupPorts` wires `WithMovement(keys, resolver)` + `WithPolicyStore(ConfigRepo…)`. Resting composition keeps `ErrMovementNotWired` (AC4). - **Policy persistence** (`policy.go` / `backup.go` / `policystore_configrepo.go`): new `PolicyLoader` — `backup.New` rehydrates every committed policy at construction, so a confirmed policy survives a restart (AC1 — the missing piece; the store persisted on commit but nothing reloaded it). - New env `OURCLOUD_NODE` names the gateway's own clan node id. **Acceptance** - AC1 policy persists across restart — `TestMovementCompose_PolicyPersistsAcrossRestart`. - AC2 replicate lands the sealed artifact + inventory, restore-test passes — `TestMovementCompose_ProductionKeysAndStore_ReplicatesAndReadsBackRaw` + composition-root `…WholeWiresMovementAndReadsBackRaw`. - AC3 raw read-back with the keys alone — the sealed bytes open with a fresh reader + `backup.Open` + a JSON reader; a different root cannot open it. (The seal is AES-GCM `backup.Seal`, the settled #177 one-encryption-story — ADR 0104's "age" wording is that same sealed-artifact path, per STATUS.md's existing note.) - AC4 resting keeps the honest refusal — `TestMovementCompose_RestingKeepsHonestRefusal`. **Note:** the Sandcastle sandbox has no Go toolchain (#198), so this was verified by careful review across the three packages; the seam run is the first real compile/test. Unblocks #183 leg B·4 (and B·7's restore rides the same machinery).
ben closed this issue 2026-07-31 07:03:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#203
No description provided.