| 1 | # Verification & trust |
| 2 | |
| 3 | How the system decides a change is safe to integrate, without a central CI gate. |
| 4 | |
| 5 | ## The reframe |
| 6 | |
| 7 | CI-as-gate ("the change is blocked until our infra confirms the checks pass") is replaced by **attestation-with-revocation**: |
| 8 | |
| 9 | 1. The developer's local environment runs the checks in a hermetic sandbox. |
| 10 | 2. It produces a signed attestation describing what ran, against what inputs, and what the result was. |
| 11 | 3. The commit and its attestations land in the event log together. |
| 12 | 4. Subscribers act immediately on the attestation. Re-verifiers cross-check asynchronously. |
| 13 | 5. Trust is *measured* per attester, based on re-verification confirm rates. Divergence revokes trust. |
| 14 | |
| 15 | This trades two failure modes: |
| 16 | |
| 17 | | Model | Failure mode | |
| 18 | | --- | --- | |
| 19 | | CI-as-gate | False negatives — slow feedback, flakes, infra outages block correct changes | |
| 20 | | Attestation | False positives — a bad attestation can land before the re-verifier catches it | |
| 21 | |
| 22 | For most environments — personal projects, small teams, trusted contributor sets — false positives that are *detected and revocable* are a much better trade than a slow, brittle gate. |
| 23 | |
| 24 | ## What "unforgeable" actually means |
| 25 | |
| 26 | Without a TEE, attestations are exactly as trustworthy as the signing key. That's the same trust model as code signing, and it's plenty for non-adversarial settings. But you can stack mechanisms to raise the bar significantly above "trust the human": |
| 27 | |
| 28 | | Mechanism | What it gets you | Residual attack | |
| 29 | | --- | --- | --- | |
| 30 | | Signing key | "Patrick says these checks passed" | Anyone with the key can lie | |
| 31 | | Content-addressed attestation tool | The tool itself is a known Nix derivation; the attestation names its hash | Malicious dev can ship a patched tool, but it will not match the canonical hash | |
| 32 | | Hermetic sandbox | `nix build` sandbox; `nixosTest` VMs; microVMs for non-Nix checks | Local root can still bypass — but bypass leaves evidence | |
| 33 | | Re-derivation audit | Pure attestations encode every input hash; verifier re-runs and confirms bit-identical | None for pure checks; effectful checks not re-verifiable | |
| 34 | | Witness sampling | Random fraction of attestations re-run on another node; trust score per attester | None — this is the backstop | |
| 35 | |
| 36 | Stack 2–5 and a determined local-root actor *can* still forge an attestation, but only by: |
| 37 | |
| 38 | - Shipping a tool whose hash doesn't match the canonical (visible). |
| 39 | - Producing a derivation hash that won't match on re-derivation (eventually detected). |
| 40 | - Doing so before their trust score is recalculated (bounded window). |
| 41 | |
| 42 | For pure-derivation checks this lands roughly at SLSA Level 3. For effectful checks, lower — but the system knows which kind each attestation is. |
| 43 | |
| 44 | ## Two kinds of checks, two kinds of attestation |
| 45 | |
| 46 | The system must distinguish what an attestation is claiming. A single "checks passed" signature is the SLSA mistake worth avoiding. |
| 47 | |
| 48 | ### Pure checks |
| 49 | |
| 50 | - `nix build` of the project |
| 51 | - `nix flake check` |
| 52 | - Type-checking, linting, formatting (when wrapped as derivations) |
| 53 | - `nixosTest`-style integration tests (effectful from inside, pure from outside) |
| 54 | |
| 55 | Inputs are content-addressed, outputs are deterministic. The attestation includes input hashes, derivation hashes, output hashes. **Any verifier can re-derive and confirm.** These are the strong attestations. |
| 56 | |
| 57 | ### Effectful checks |
| 58 | |
| 59 | - Real-network integration tests |
| 60 | - Tests against external APIs or stateful services |
| 61 | - Performance benchmarks |
| 62 | - Anything not bit-reproducible |
| 63 | |
| 64 | The attestation is a notarization: "sealed environment $E ran $T at time $t and observed $result." Verifiable only inasmuch as $E is a derivation. Trust here is closer to "I trust the signer." |
| 65 | |
| 66 | Wherever a check can be moved from effectful to pure (via `nixosTest` or microVM sandboxing), it should be. |
| 67 | |
| 68 | ## Attestation shape |
| 69 | |
| 70 | Sketch, not a spec: |
| 71 | |
| 72 | ``` |
| 73 | { |
| 74 | "subject": { |
| 75 | "repo": "...", |
| 76 | "commit": "sha256:..." |
| 77 | }, |
| 78 | "checks": [ |
| 79 | { |
| 80 | "kind": "pure", |
| 81 | "tool": "sha256:...", // attestation tool derivation hash |
| 82 | "inputs": ["sha256:..."], // input derivation hashes |
| 83 | "derivation": "sha256:...", |
| 84 | "output": "sha256:...", |
| 85 | "result": "success" |
| 86 | }, |
| 87 | { |
| 88 | "kind": "effectful", |
| 89 | "tool": "sha256:...", |
| 90 | "env": "sha256:...", // sealed-environment derivation hash |
| 91 | "test": "sha256:...", |
| 92 | "result": "success", |
| 93 | "observed_at": "..." |
| 94 | } |
| 95 | ], |
| 96 | "signatures": [ |
| 97 | {"key_id": "...", "sig": "..."} |
| 98 | ] |
| 99 | } |
| 100 | ``` |
| 101 | |
| 102 | The attestation is itself an event published into the log. |
| 103 | |
| 104 | ## Reactions on the event |
| 105 | |
| 106 | A few subscribers worth naming: |
| 107 | |
| 108 | - **Deploy controller** — `attestation valid + signer trusted + ref matches main → deploy`. |
| 109 | - **Re-verifier (pure)** — re-derive any pure attestation; emit confirm/deny event. |
| 110 | - **Re-verifier (effectful sample)** — re-run a sampled fraction of effectful attestations on a witness node. |
| 111 | - **Trust controller** — track per-attester confirm rate. Below threshold → revoke trust → future attestations from that signer require gating before reactions. |
| 112 | - **Review controller** — open a human review request regardless. Attestations replace the *correctness gate*, not the *human review*. |
| 113 | |
| 114 | ## What this is not |
| 115 | |
| 116 | - Not a replacement for review. Attestations say "the checks ran and passed." They say nothing about whether the change is *correct* or *desirable*. That's a separate problem with a separate document. |
| 117 | - Not a guarantee against compromised developer machines. A compromised machine signing real attestations of malicious code is the unsolved problem; hardware attestation is the only fix and is out of scope. |
| 118 | - Not a security-only mechanism. The primary win is *latency* — closing the feedback loop from minutes to seconds. The security properties are a side effect of doing it well. |
| 119 | |
| 120 | ## Open questions |
| 121 | |
| 122 | - **Bootstrapping trust.** A new contributor has no trust score. Do they get one by default, or do they require gating until $N attestations land cleanly? Probably the latter. |
| 123 | - **Effectful test catalogue.** Which classes of effectful test can be lifted to `nixosTest` or microVM-sealed environments? Worth maintaining a list — moving a test from effectful to pure is a meaningful security improvement. |
| 124 | - **Tool distribution.** The attestation tool is a Nix derivation. How is its canonical hash published and pinned? Probably as part of armstrong's own flake, but the bootstrapping is worth thinking through. |
| 125 | - **Replay timeline.** How long are attestations re-verifiable for? Tied to how long inputs stay resolvable in caches. Affects how long-tail audits work. |