| 1 | # Verification |
| 2 | |
| 3 | The reframe — attestation-with-revocation instead of CI-as-gate, and the failure-mode trade it makes |
| 4 | — is an architecture bet; see [architecture.md](./architecture.md). This document holds what the |
| 5 | attestation phase actually needs: the two kinds of checks, what an attestation is about, and what |
| 6 | makes one hard to forge. |
| 7 | |
| 8 | The shape of an attestation — its statement, its signer, its envelope, where it is stored, and how |
| 9 | several of them compose — is fixed by |
| 10 | [dcr-0de694f](../.the-valley/decisions/dcr-0de694f-phase2-attestation-shape.md), and the statement's |
| 11 | fields are [schema/attestation.cue](../schema/attestation.cue). |
| 12 | |
| 13 | ## Two kinds of checks, two kinds of attestation |
| 14 | |
| 15 | The system must distinguish what an attestation is claiming. A single "checks passed" signature is |
| 16 | the SLSA mistake worth avoiding. |
| 17 | |
| 18 | - **Pure checks** — `nix build`, `nix flake check`, lint/type-check as derivations, |
| 19 | `nixosTest`-style integration tests (effectful inside, pure outside). Inputs content-addressed, |
| 20 | outputs deterministic; the attestation carries input, derivation, and output hashes, so **any |
| 21 | verifier can re-derive and confirm**. These are the strong attestations. |
| 22 | - **Effectful checks** — real-network tests, external APIs, benchmarks, anything not |
| 23 | bit-reproducible. The attestation is a notarization: "sealed environment $E ran $T at time $t and |
| 24 | observed $result." Trust here is closer to "I trust the signer." |
| 25 | |
| 26 | Wherever a check can be moved from effectful to pure (via `nixosTest` or microVM sandboxing), it |
| 27 | should be. |
| 28 | |
| 29 | ## The subject is a tree digest |
| 30 | |
| 31 | An attestation is about a tree, not about a commit. The digest that names that tree is |
| 32 | `valley-tree-v1`, and it is defined so that anyone holding the tree can recompute it from the tree |
| 33 | alone. |
| 34 | |
| 35 | Take every entry of the tree: every blob and every symlink, at its path relative to the root. Render |
| 36 | each one as a line |
| 37 | |
| 38 | <mode> <sha256 of the content, in hex> <byte length of the path> <path> |
| 39 | |
| 40 | where the mode is git's — `100644`, `100755`, or `120000` for a symlink, whose content is its target |
| 41 | — and the byte length is written out in decimal. Sort the lines by path, ascending, comparing bytes. |
| 42 | Put `valley-tree-v1` and a newline in front of them. The digest is the SHA-256 of the result, in |
| 43 | lowercase hex. |
| 44 | |
| 45 | The path's byte length is written out because a path can contain a newline, and an entry boundary a |
| 46 | path could forge is a digest an attacker could steer. Directories are not entries: a directory is |
| 47 | implied by the paths beneath it, and git holds no empty ones. A submodule is rejected rather than |
| 48 | digested, because a tree that reaches outside itself is not a thing this digest can be a function |
| 49 | of. |
| 50 | |
| 51 | Nothing else enters the manifest. Not the commit, not the author, not the time, not a store path. |
| 52 | That is what makes an attestation survive the integrator's rebase: the same tree under a rewritten |
| 53 | commit has the same digest, so the attestation still names it. It is also what binds an attestation |
| 54 | to a base, since a tree is the base and the change together |
| 55 | ([ida-cbcbb3c](../.the-valley/ideas/ida-cbcbb3c-attestations-bind-to-a-base.md)). |
| 56 | |
| 57 | The same manifest digests a pure check's output, so the digest a statement records for what a check |
| 58 | produced and the digest it records for what the check ran over are the same kind of thing. |
| 59 | |
| 60 | ## The helper |
| 61 | |
| 62 | `nix run .#attest` is the Phase 2 helper. `attest run` digests the tree, runs the checks over an |
| 63 | export of that tree rather than over the working directory, composes one statement per check, vets |
| 64 | each against [schema/attestation.cue](../schema/attestation.cue), signs each with a detached SSHSIG |
| 65 | signature under the namespace `the-valley.attestation.v1`, and stores them at |
| 66 | `refs/the-valley/attestations/<tree digest>/<signer fingerprint>`. With `--push` it publishes the |
| 67 | topic branch and that ref in one atomic native-git push. A failing check publishes nothing, and |
| 68 | neither does a statement the schema rejects. |
| 69 | |
| 70 | The signing key is a parameter (`--key`). There is no unsigned mode: a run with no key available |
| 71 | fails rather than emitting a statement nobody signed. |
| 72 | |
| 73 | `attest verify` takes a statement, its signature and an allowed-signers file, and checks four |
| 74 | things: that the statement satisfies the schema, that its bytes are the canonical rendering of what |
| 75 | it says, that a signer the file allows signed exactly those bytes, and — given `--repo` — that the |
| 76 | tree in front of the verifier is the tree the statement names. Re-running a pure check and |
| 77 | confirming its output digest is witness re-verification, and belongs to |
| 78 | [Phase 6](./roadmap.md#phase-6--trust-backstop) rather than here. |
| 79 | |
| 80 | The run provenance a statement carries — the harness, the model, digests of the prompt and the |
| 81 | context, and the delegation chain — is supplied by the caller (`--provenance`) or absent. Nothing |
| 82 | collects those values today. |
| 83 | |
| 84 | ## The mechanism stack |
| 85 | |
| 86 | Without a TEE, attestations are exactly as trustworthy as the signing key — the same trust model as |
| 87 | code signing, plenty for non-adversarial settings. But the mechanisms stack: |
| 88 | |
| 89 | | Mechanism | What it gets you | Residual attack | |
| 90 | | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | |
| 91 | | Signing key | "The signer says these checks passed" | Anyone with the key can lie | |
| 92 | | 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 | |
| 93 | | Hermetic sandbox | `nix build` sandbox; `nixosTest` VMs; microVMs for non-Nix checks | Local root can still bypass — but bypass leaves evidence | |
| 94 | | 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 | |
| 95 | | Witness sampling | Random fraction of attestations re-run on another node; trust score per attester | None — this is the backstop | |
| 96 | | Transparency log (Tessera-backed) | Every attestation appended to an external append-only log with an inclusion proof; anyone can audit existence and content over time | Orthogonal to the others — gives non-repudiation and tamper evidence, not correctness of the computation. Independent and complementary. | |
| 97 | |
| 98 | Stacked, a determined local-root actor can still forge an attestation — but only visibly (tool hash |
| 99 | mismatch), temporarily (re-derivation eventually detects), and within a bounded window (before their |
| 100 | trust score is recalculated). For pure-derivation checks this lands roughly at SLSA Level 3; for |
| 101 | effectful checks, lower — but the system knows which kind each attestation is. |