guest-trust rotation: restart on trust-file change, and a post-converge rotation story (ADR 0126 follow-up) #274

Closed
opened 2026-08-05 06:21:30 +00:00 by ben · 4 comments
Owner

The ADR 0126 arc landed guest-trust delivery as a one-shot: sshkey.Ensure mints once, the VM manager writes the trust file and hands it to the guest via fw_cfg, and the guest's mint service installs it at boot. The final whole-branch review traced a rotation dead end across three pieces:

  1. sshkey.Ensure's mismatch error says "delete both to re-mint" — but if an operator does that, the new trust file is written while upgradeUnit (internal/vm/manager.go) compares only the UNIT rendering: identical unit → no restart → the running guest keeps the OLD fw_cfg blob. Every subsequent verify fails auth as a resumable block whose remedy text cannot fix it.
  2. Post-converge, the baked VM baseline (internal/clan/vmguest.go) deliberately drops the mint service AND boot.kernelModules = ["qemu_fw_cfg"], so fw_cfg delivery is one-shot per guest lifecycle — after the first machines update, a re-minted key can never land via fw_cfg at all.
  3. Test gaps noted in review: no test for a keyless Create rendering (fw_cfg line absent, hostfwd present) and none for repeat-Create-with-key as a true no-op.

Wanted: a rotation story. Cheap partial fix: upgradeUnit also diffs the trust file and restarts when it changed (covers pre-converge rotation). The post-converge path needs a design ruling (keep the mint service in the baked baseline? rotate over SSH while the old key still works?).

Found by the ADR 0126 final review (branch adr-0126-vm-standup); not on the fresh-founding happy path — founding mints once and reuses.

The ADR 0126 arc landed guest-trust delivery as a one-shot: sshkey.Ensure mints once, the VM manager writes the trust file and hands it to the guest via fw_cfg, and the guest's mint service installs it at boot. The final whole-branch review traced a rotation dead end across three pieces: 1. `sshkey.Ensure`'s mismatch error says "delete both to re-mint" — but if an operator does that, the new trust file is written while `upgradeUnit` (internal/vm/manager.go) compares only the UNIT rendering: identical unit → no restart → the running guest keeps the OLD fw_cfg blob. Every subsequent verify fails auth as a resumable block whose remedy text cannot fix it. 2. Post-converge, the baked VM baseline (internal/clan/vmguest.go) deliberately drops the mint service AND `boot.kernelModules = ["qemu_fw_cfg"]`, so fw_cfg delivery is one-shot per guest lifecycle — after the first `machines update`, a re-minted key can never land via fw_cfg at all. 3. Test gaps noted in review: no test for a keyless Create rendering (fw_cfg line absent, hostfwd present) and none for repeat-Create-with-key as a true no-op. Wanted: a rotation story. Cheap partial fix: `upgradeUnit` also diffs the trust file and restarts when it changed (covers pre-converge rotation). The post-converge path needs a design ruling (keep the mint service in the baked baseline? rotate over SSH while the old key still works?). Found by the ADR 0126 final review (branch adr-0126-vm-standup); not on the fresh-founding happy path — founding mints once and reuses.
Author
Owner

This was generated by AI during triage.

Triage Notes

What we've established so far:

  • The report references ADR 0126 ("guest-trust delivery"), a branch adr-0126-vm-standup, and three code sites: sshkey.Ensure's mismatch error, an upgradeUnit function in internal/vm/manager.go, and a baked-VM baseline in internal/clan/vmguest.go that drops the mint service + boot.kernelModules = ["qemu_fw_cfg"].
  • None of these exist in this repository. Checked: docs/adr/ tops out at 0125-private-path-host-toolchain-is-app-managed.md (no 0126, anywhere in git history on any branch). No sshkey package exists anywhere (closest analog is internal/devicekey/devicekey.go, a different concern with a different message). internal/vm/manager.go exists but has no upgradeUnit — its only methods are Create/Remove/Exists/Health, and Create is already idempotent and no-ops on a second call (pinned by TestCreateIdempotent, manager_test.go:146). internal/clan/vmguest.go does not exist. No fw_cfg/trust-file/mint-service delivery pipeline exists anywhere under internal/. boot.kernelModules = ["qemu_fw_cfg"] does exist, but in nix/guest/configuration.nix:66 (unconditional guest config), not conditionally dropped by anything in internal/clan.
  • Fetched all remote branches (git fetch --all --prune) — no adr-0126-vm-standup branch exists locally or on origin, and no commit in this repo's full history mentions "0126" or "guest-trust".
  • This isn't an "already implemented" wontfix (the opposite problem — the described machinery doesn't exist at all here), and it doesn't match anything in this repo's rejected-request history.

What we still need from you (@ben):

  • Where does the ADR 0126 branch / the landed guest-trust delivery code actually live? Was adr-0126-vm-standup pushed to a different remote, merged and then reverted, or is this describing work from a different checkout/repo that hasn't reached Matou/ourcloud yet?
  • If the branch exists somewhere reachable, a pointer (URL, remote name, or a git fetch recipe) would let us re-run the verification and turn this into a proper agent brief for the "cheap partial fix" (diff the trust file in the restart-decision path, not just the rendered unit).
  • The post-converge design question (keep the mint service in the baked baseline vs. rotate over SSH) is a real judgement call either way and will need a ruling once the underlying code is locatable — flagging it now so it isn't lost.

Labelled needs-info pending the above; re-triage once the branch/commit is identified.

> *This was generated by AI during triage.* ## Triage Notes **What we've established so far:** - The report references ADR 0126 ("guest-trust delivery"), a branch `adr-0126-vm-standup`, and three code sites: `sshkey.Ensure`'s mismatch error, an `upgradeUnit` function in `internal/vm/manager.go`, and a baked-VM baseline in `internal/clan/vmguest.go` that drops the mint service + `boot.kernelModules = ["qemu_fw_cfg"]`. - None of these exist in this repository. Checked: `docs/adr/` tops out at `0125-private-path-host-toolchain-is-app-managed.md` (no 0126, anywhere in git history on any branch). No `sshkey` package exists anywhere (closest analog is `internal/devicekey/devicekey.go`, a different concern with a different message). `internal/vm/manager.go` exists but has no `upgradeUnit` — its only methods are `Create`/`Remove`/`Exists`/`Health`, and `Create` is already idempotent and no-ops on a second call (pinned by `TestCreateIdempotent`, `manager_test.go:146`). `internal/clan/vmguest.go` does not exist. No fw_cfg/trust-file/mint-service delivery pipeline exists anywhere under `internal/`. `boot.kernelModules = ["qemu_fw_cfg"]` does exist, but in `nix/guest/configuration.nix:66` (unconditional guest config), not conditionally dropped by anything in `internal/clan`. - Fetched all remote branches (`git fetch --all --prune`) — no `adr-0126-vm-standup` branch exists locally or on `origin`, and no commit in this repo's full history mentions "0126" or "guest-trust". - This isn't an "already implemented" wontfix (the opposite problem — the described machinery doesn't exist at all here), and it doesn't match anything in this repo's rejected-request history. **What we still need from you (@ben):** - Where does the ADR 0126 branch / the landed guest-trust delivery code actually live? Was `adr-0126-vm-standup` pushed to a different remote, merged and then reverted, or is this describing work from a different checkout/repo that hasn't reached `Matou/ourcloud` yet? - If the branch exists somewhere reachable, a pointer (URL, remote name, or a `git fetch` recipe) would let us re-run the verification and turn this into a proper agent brief for the "cheap partial fix" (diff the trust file in the restart-decision path, not just the rendered unit). - The post-converge design question (keep the mint service in the baked baseline vs. rotate over SSH) is a real judgement call either way and will need a ruling once the underlying code is locatable — flagging it now so it isn't lost. Labelled `needs-info` pending the above; re-triage once the branch/commit is identified.
Author
Owner

This was generated by AI during triage.

Triage Notes (correction)

What we've established so far:

  • The original triage pass (2026-08-05) checked main and all remotes fetched at the time, found no sshkey package, no upgradeUnit in internal/vm/manager.go, and no internal/clan/vmguest.go, and concluded the report didn't match anything in this repository.
  • Re-investigating while triaging the related e2e-arc tickets (#333–#336) surfaced origin/private-standup-polish — not reconciled by the prior pass — which carries the ADR 0126 guest-trust delivery work this report describes.
  • On that branch, all three code sites the report names are real: internal/sshkey/sshkey.go's Ensure does return a "delete both to re-mint" error on a mismatch; (*Manager).upgradeUnit (internal/vm/manager.go) re-renders the guest unit but only diffs the rendered unit file, not the trust file carried via fw_cfg — so a re-minted key written after a manual delete-both won't trigger a restart; and internal/clan/vmguest.go bakes the post-converge guest baseline. The rotation dead-end described is real on that branch.

What needs deciding:

  • Same coordination question as #275: private-standup-polish has commits from another contributor as recently as today. Whether to land a fix on that in-flight branch now, or hold until it merges to main, needs a call.
  • The report also flags an open design question independent of the branch-timing issue: "the post-converge path needs a design ruling — keep the mint service in the baked baseline, or rotate over SSH while the old key still works?" That ruling needs a human either way.

Routing to ready-for-human (previously needs-info) — the underlying gap is now confirmed in code; both the branch-coordination question and the post-converge design ruling need a human call.

> *This was generated by AI during triage.* ## Triage Notes (correction) **What we've established so far:** - The original triage pass (2026-08-05) checked `main` and all remotes fetched at the time, found no `sshkey` package, no `upgradeUnit` in `internal/vm/manager.go`, and no `internal/clan/vmguest.go`, and concluded the report didn't match anything in this repository. - Re-investigating while triaging the related e2e-arc tickets (#333–#336) surfaced `origin/private-standup-polish` — not reconciled by the prior pass — which carries the ADR 0126 guest-trust delivery work this report describes. - On that branch, all three code sites the report names are real: `internal/sshkey/sshkey.go`'s `Ensure` does return a "delete both to re-mint" error on a mismatch; `(*Manager).upgradeUnit` (`internal/vm/manager.go`) re-renders the guest unit but only diffs the rendered unit file, not the trust file carried via fw_cfg — so a re-minted key written after a manual delete-both won't trigger a restart; and `internal/clan/vmguest.go` bakes the post-converge guest baseline. The rotation dead-end described is real on that branch. **What needs deciding:** - Same coordination question as #275: `private-standup-polish` has commits from another contributor as recently as today. Whether to land a fix on that in-flight branch now, or hold until it merges to `main`, needs a call. - The report also flags an open design question independent of the branch-timing issue: "the post-converge path needs a design ruling — keep the mint service in the baked baseline, or rotate over SSH while the old key still works?" That ruling needs a human either way. Routing to `ready-for-human` (previously `needs-info`) — the underlying gap is now confirmed in code; both the branch-coordination question and the post-converge design ruling need a human call.
Author
Owner

Ruled by Ben 2026-08-08 (decision sweep): the full rotation story. Pre-converge: upgradeUnit also diffs the trust file and restarts the guest when it changed. Post-converge: rotation happens over SSH while the old key still works (an authorized_keys swap) — the baked baseline keeps dropping the mint service and fw_cfg module. Fix the "delete both to re-mint" error text to describe the real procedure, and close the review's test gaps (keyless Create rendering; repeat-Create-with-key as a true no-op). → ready-for-agent.

Ruled by Ben 2026-08-08 (decision sweep): **the full rotation story.** Pre-converge: `upgradeUnit` also diffs the trust file and restarts the guest when it changed. Post-converge: rotation happens **over SSH while the old key still works** (an authorized_keys swap) — the baked baseline keeps dropping the mint service and fw_cfg module. Fix the "delete both to re-mint" error text to describe the real procedure, and close the review's test gaps (keyless Create rendering; repeat-Create-with-key as a true no-op). → `ready-for-agent`.
Author
Owner

Landed the full rotation story per Ben's 2026-08-08 ruling (commit c4b2ba9, on origin/main).

Pre-converge (the cheap partial fix): (*Manager).Create now reads the on-disk trust file before overwriting it and passes a trustChanged flag to upgradeUnit, which restarts the guest on a pure trust rotation (a restart re-execs qemu-system, re-reading the fw_cfg file — the only path a re-minted key reaches a pre-converge guest) as well as on a unit-rendering change. A re-mint after delete both now actually lands on the running guest instead of leaving it stuck on the OLD fw_cfg blob. internal/vm/manager.go.

Post-converge: per the ruling, rotation is over SSH (authorized_keys swap) while the old key still works, so the baked baseline keeps dropping the mint service + qemu_fw_cfg module BY DESIGN — recorded in internal/clan/vmguest.go's header; no baseline behaviour change.

Error text: both mismatch errors in internal/sshkey/sshkey.go now describe the real procedure (delete both + re-drive stand-up pre-converge; SSH rotation once converged), keeping the exists but … missing shape.

Test gaps closed (red-first, internal/vm/manager_test.go): keyless Create renders no fw_cfg + writes no trust file; repeat-Create-with-key is a true no-op; a rotated trust restarts the guest under a byte-identical unit with the SSH port preserved.

go test / go vet / gofmt green across vm, sshkey, clan; the whole-tree pre-push gate passed. STATUS.md updated (header + milestone log).

Landed the full rotation story per Ben's 2026-08-08 ruling (commit `c4b2ba9`, on `origin/main`). **Pre-converge (the cheap partial fix):** `(*Manager).Create` now reads the on-disk trust file *before* overwriting it and passes a `trustChanged` flag to `upgradeUnit`, which restarts the guest on a pure trust rotation (a restart re-execs qemu-system, re-reading the fw_cfg file — the only path a re-minted key reaches a pre-converge guest) as well as on a unit-rendering change. A re-mint after `delete both` now actually lands on the running guest instead of leaving it stuck on the OLD fw_cfg blob. `internal/vm/manager.go`. **Post-converge:** per the ruling, rotation is over SSH (authorized_keys swap) while the old key still works, so the baked baseline keeps dropping the mint service + `qemu_fw_cfg` module BY DESIGN — recorded in `internal/clan/vmguest.go`'s header; no baseline behaviour change. **Error text:** both mismatch errors in `internal/sshkey/sshkey.go` now describe the real procedure (delete both + re-drive stand-up pre-converge; SSH rotation once converged), keeping the `exists but … missing` shape. **Test gaps closed** (red-first, `internal/vm/manager_test.go`): keyless Create renders no fw_cfg + writes no trust file; repeat-Create-with-key is a true no-op; a rotated trust restarts the guest under a byte-identical unit with the SSH port preserved. `go test` / `go vet` / `gofmt` green across vm, sshkey, clan; the whole-tree pre-push gate passed. STATUS.md updated (header + milestone log).
ben closed this issue 2026-08-08 22:25:06 +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.

Dependencies

No dependencies set.

Reference
Matou/idss#274
No description provided.