gunk-dev/the-valley
the-valley:oc-40e3520outcomeabandoned

M1-C: signed releases and touch-gated approvals

State
abandoned
Created
2026-10-17 by contributor
Source
2026-10-04, m1c-signed-releases-design.md and plan.md M1-C
Progress
2 of 2 done
Children

Body

Landing on `main` and deploying to a host become separate acts, each signed by the operator with a hardware touch. Hosts deploy only signed, sequenced releases. Approvals become signed statements the integrator checks. Agents can then hold `request` for low-risk paths while infrastructure changes still need a touch.

The children split the work: releases on the deployment's hosts, approval statements in the-valley, and a release stage for checks. Approval carry across a rebase is beside this knot, under M1.

## Releases: what still holds of the 2026-10-04 design

From `m1c-signed-releases-design.md`, with Astra's review folded in and the later plan entries applied.

- **Release identity.** An annotated tag `release/<project>/<seq>`, SSH-signed, naming a commit on `main`. `<seq>` is a positive decimal with no leading zeros and is the only release identity. Hosts trust nothing but the tag name and its target commit.
- **Trust roots.** The two enrolled release keys (`ssh:<project>-release`, `verify-required`) are rendered into the system closure as the allowed-signers file. A candidate never supplies its own roots, and changing them takes a release signed under the current roots. Verification requires UV.
- **`release-gate`, a Go program in the deployment project.** Under converge's lock it fetches the release tags into converge's root-owned mirror (sanitized environment, replace refs off), takes the highest `<seq>` by the strict grammar, runs `sigverify git-tag`, and parses its full report strictly. It accepts only `seq` greater than the accepted one (or the same commit, as a retry), refuses rather than falling back when the newest tag fails, and persists `{seq, commit}` crash-safely before converge activates it.
- **Converge modes:** `main` (today), `report` (deploy `main`, report the newest valid release) and `enforce` (deploy only what `release-gate` returns, by rev, from the protected mirror). Quarantine is keyed by `<seq>`.
- **The promotion tool, a Go program** run by the operator in the release environment: it shows the range since the last release, signs the next tag with a touch and PIN, verifies it with the hosts' signers file, and pushes it. Checking that builds exist first is M2's D2.
- **Rollout:** ship in `report` mode, sign `release/<project>/1`, then a small change sets `enforce` and the floor. Break-glass is a signed release from any remote, or a manual rebuild at the console.

**Required by Astra's review** (`review-m1c-design-astra.md`), still current:
- Missing state fails closed. Initial state is provisioned per host, never recreated by `resolve`. Define the floor, raised floors and same-release retries. Converge's automatic rollback stays at or above the floor.
- Bootstrap: the first admissible release contains enforcing config; old-mode processes, rollbacks to pre-enforcement systems and offline hosts must not reopen unsigned deploys; keep an inventory of enrolled hosts.
- Build the verified commit from the protected mirror with `--no-update-lock-file`, pure evaluation, no overrides, absolute paths and no user or system git config.
- Allocate sequences from verified releases only, so a huge unsigned tag is no denial of service.
- Webhook: tag pushes miss the `branches = ["main"]` filter. Wire them or rely on the timer, and say which.
- Gate or narrow the `update` alias and container `:latest` tags, or state the guarantee narrowly.
- Record how the release keys' public halves were obtained from the hardware, re-derived with `ssh-keygen -K` where agents can't reach.

**Overtaken since 2026-10-04:**
- The prerequisite "M3 first" is met: agents run in the agent guest, not the operator's account.
- A retired worker's update path needs nothing.
- The two autoUpgrade hosts still disable unsigned `system.autoUpgrade` or come under releases; the work profiles wait on the question this knot owns.

**Tests:** a NixOS VM test on the deployment's test harness with a stand-in signer (sk-dummy), covering ignored unsigned pushes, a signed release that deploys, older, replayed and same-seq-different-commit releases refused, touchless and no-UV signatures refused, wrong principal or namespace refused, corrupt and missing state failing closed, crash between persist and activation, bootstrap and offline sequences, rollback across enforcement and floor raises.

## Approvals

From `change-identity-design.md` §2 and the roadmap: the operator's hardware key signs an SSHSIG approval statement over a prepared result. The integrator verifies it as part of one landing decision. See the approvals child.

Source: 2026-10-04, `m1c-signed-releases-design.md` and `review-m1c-design-astra.md`; `plan.md` M1-C and Status through 2026-10-14; the-valley `docs/roadmap.md` step 4.

Comments

  1. contributor2026-10-18 14:45 UTCedited2026-10-29 01:09 UTC by contributor
    From the coordinator's working file `m1c-signed-releases-design.md` (moved here 2026-10-18), part 1 of 1:
    
    # M1-C: signed releases for the deployment's hosts (design draft for review)
    
    Draft, 2026-10-04. To be reviewed by another model family before dispatch.
    
    ## Goal
    Hosts deploy only a release that the operator signed with a hardware key (PIN plus touch). An agent running as the operator can push, merge or tag anything, but can't get a host to activate a release the operator didn't sign.
    
    ## Today
    `converge` (the deployment project's module, after a deployment change) is Bash. The webhook triggers it, with an hourly timer as fallback. It runs on the valley host, the operator's workstation and two other hosts, and does `git ls-remote <repo> refs/heads/main`, then builds `git+ssh://…?rev=<rev>#nixosConfigurations.<host>` and activates it, with health checks and rollback. Two other hosts use unsigned `system.autoUpgrade` from the mirror.
    
    `sigverify` (the-valley `main`, `sigverify/`, flake package `sigverify`) verifies an SSHSIG git tag against an OpenSSH allowed-signers file. It enforces FIDO user presence, plus user verification with `--require-uv`, and prints a complete success report ending in `commit <oid>`. Its README's "caller's contract" (requirements 1–9) binds this design.
    
    ## Design
    
    ### Release identity
    - Tag `release/<project>/<seq>`: annotated, SSH-signed (`gpg.format=ssh`, namespace `git`), pointing at a commit on `main`.
    - `<seq>` is a positive decimal integer with no leading zeros, and the sole release identity. The signature bytes never identify a release (requirement 9).
    - The tag message is human-readable (a summary). Hosts don't trust any metadata beyond the name and the target commit.
    
    ### Trust roots (requirements 1, 3, 4)
    - The deployment's key list gains `releaseSigners`: the operator's two enrolled `sk-ssh-ed25519` release keys (application `ssh:<project>-release`), under principal `<project>-release`, `namespaces="git"`, with `verify-required` on each line.
    - They're rendered into the system closure as `environment.etc."<project>/release-signers"`: a `/nix/store` path, root-owned and immutable. A candidate release never supplies trust roots. Changing them requires a release signed under the current roots, because the config only deploys through releases once enforcing.
    - Verification passes `--principal <project>-release --require-uv` with only the default `fido-sk` class.
    
    ### `release-gate`: a new Go program (in the deployment project, beside `converge-status`)
    All release policy lives here, not in Bash.
    - `release-gate resolve`:
      1. Under converge's lock, fetch `refs/tags/release/<project>/*` into converge's root-owned mirror (in the rebuild tool's state directory). Run git with a sanitized environment and `GIT_NO_REPLACE_OBJECTS=1`.
      2. Pick the highest `<seq>` by the strict grammar, run `sigverify git-tag`, and require the complete success report (exit 0, exactly one `tag` and one `commit`, `commit` last, tag name equal to the requested one).
      3. Compare with durable state in the release state directory (root `0700`): accept only `seq > accepted`; on `seq == accepted`, accept only the same commit (a retry).
      4. If the newest tag fails verification, refuse with that reason; don't fall back silently to an older tag. Report it, and stay on the current system.
      5. Persist `{seq, commit}` crash-safely (write, fsync, rename, fsync the directory) **before** printing `<seq> <commit>` for converge to activate (requirement 8).
    - **Missing state:** use the trusted floor from config (`modules.converge.release.floor`, baked into the system). **Corrupt state:** refuse (fail closed), and document operator recovery.
    - **Clock:** the host's system clock, which the operator account can't set (requirement 5).
    
    ### Converge integration (thin Bash glue)
    - New `modules.converge.release.mode`:
      - `main`: today's behaviour.
      - `report`: deploy `main`, but run `release-gate resolve --dry-run` and log/report the newest valid release.
      - `enforce`: deploy only what `release-gate resolve` returns.
    - In `enforce` mode converge builds exactly the verified commit, by rev, from the protected mirror (requirement 7). Its quarantine is keyed by release `<seq>` instead of git rev.
    - Status (`converge-status`, Waybar) shows the deployed release seq, and "release refused: <reason>".
    - **Tag push to converge:** check that the github-relay/webhook path triggers converge on a tag push. If it doesn't, wire it, or rely on the hourly timer for now and say so.
    
    ### The promotion tool: a new Go program (in the deployment project), run by the operator on their workstation (the release environment for now)
    1. Take a commit (default `origin/main`), compute the next `<seq>` from the existing tags, and show a summary: the commit range since the last release, changed `flake.lock` inputs, and the touched hosts and paths.
    2. Ask for confirmation, then `git tag -s release/<project>/<seq> <commit>`, signing with the primary release key (PIN plus touch).
    3. Verify the new tag locally with `sigverify` against the same signers file the hosts use, then push the tag.
    4. Real CI builds and a binary cache (D2/D3) are follow-ups: promote doesn't yet check that the builds exist.
    
    ### Hosts outside converge
    - **The two autoUpgrade hosts:** disable unsigned `system.autoUpgrade`; they update by hand with `update`. A later item can bring them under signed releases.
    - **A retired worker:** describe how it's updated today, and whether it needs anything.
    
    ## Rollout
    1. **Change (this work).** Code, plus every converging host set to `mode = "report"`. Deploying it changes nothing about what runs.
    2. **The operator runs the promotion tool** for the current `main` → `release/<project>/1`. Every host reports it as valid.
    3. **A small change sets `mode = "enforce"` and `floor = 1`.** It deploys from `main` one last time, and every deploy after that needs a signed release. Each host flips as it converges.
    4. **Break-glass:** a signed release can arrive from any remote, such as the GitHub mirror or a laptop. Signers and floor live in the closure. If `release-gate` or `sigverify` itself breaks, recovery is a manual `nixos-rebuild` by the operator at the console or over SSH. Document it.
    
    ## Tests (real behaviour)
    - A NixOS VM test, reusing the deployment's test harness, with a software stand-in signer. The allowed-signers line is test-only: `--require-uv` can't be met by software keys, so the test uses sigverify's sk-dummy provider, the same way the sigverify tests do. It checks that:
      - an unsigned push to `main` is ignored in enforce mode
      - a signed `release/<project>/2` deploys
      - an older or replayed release is refused
      - the same seq naming a different commit is refused
      - a touchless signature (UP clear) is refused
      - a signature without UV is refused
      - a wrong principal or namespace is refused
      - corrupt state fails closed
      - a crash between persisting state and activation leaves state ahead of the system, without ever re-accepting a lower seq
    - Go tests for the grammar, state transitions and report parsing.
    
    ## Out of scope
    D2/D3 (builds and a cache before promotion), canaries (D4), a release manifest with NAR hashes (Phase 2, untrusted cache), and the TKey trust-root ceremony.
    
    ---
    
    ## Review outcome (Codex Astra, 2026-10-04): do not dispatch as written
    The full review is `review-m1c-design-astra.md`. What it requires:
    
    1. **Prerequisite: agents must not hold root-equivalent access (M3 first).** The operator account (which agents share) can reach root without a touch:
       - the `podman` group gives the rootful podman socket
       - the `libvirtd` group gives a root QEMU with host storage
       - `wheel` plus `input` allow keylogging the sudo password
       - shared tmux allows typing into cached-sudo or root terminals
    
       Any of these defeats every signature. The promotion tool and enrollment must also run where agents can't reach: today they share the operator's identity and tmux.
    2. **Bootstrap:**
       - The first admissible release must itself contain enforcing config.
       - Provision trusted state per host, with unsigned automation stopped.
       - Running old-mode processes, rollbacks to pre-enforcement systems, and offline hosts must not reopen unsigned deploys.
       - Keep an inventory of enrolled hosts.
    3. **State:**
       - **Missing state fails closed.** Initial state is provisioned separately and never recreated by `resolve`.
       - Define the floor (inclusive or not), its commit binding, how raised floors work, and explicit same-release retries.
       - Gate converge's automatic rollback: it must stay forward-only, or be limited to systems at or above the floor.
    4. **Inputs:**
       - Build the verified OID from the protected mirror. Specify parents, objects, alternates, config, hooks and caches.
       - Use `--no-update-lock-file`, pure evaluation, and no overrides.
       - Use absolute executable paths, no user or system git config, and replace refs disabled throughout.
       - Strict report parsing: initial `verified`, the full report, a full hex OID, extra output rejected, all stdout discarded on a nonzero exit.
    5. **Scope:**
       - Gate or narrow the `update` alias, a retired worker's root SSH with operator keys and container `:latest` tags. Otherwise state the guarantee narrowly.
       - Webhook: tags miss the `branches = ["main"]` filter.
       - Allocate sequences from verified releases only, since an unsigned huge `release/<project>/99999999` tag is a DoS.
    6. **Enrollment record:** document how the release keys' public halves were obtained from the hardware through a trusted environment. They're resident keys, so re-derive them with `ssh-keygen -K` on a machine agents can't touch and compare fingerprints.
    7. **Tests:** bootstrap and offline sequences, old-process continuation, rollback across enforcement, deleted state, floor raises, concurrency, crash and fsync failures, malformed reports, a malicious operator environment, and cold-cache real builds with tampered inputs.
  2. contributor2026-11-08 22:29 UTC
    Duplicate of oc-3bc80df for touch-signed approvals. Its release section is copied to oc-005e06d, and its release-stage child moves there.