| 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). How a statement is written down |
| 12 | and signed is [dcr-de9d996](../.the-valley/decisions/dcr-de9d996-statement-text-and-signed-note.md), |
| 13 | and the sections below are that decision's detail. |
| 14 | |
| 15 | ## Two kinds of checks, two kinds of attestation |
| 16 | |
| 17 | The system must distinguish what an attestation is claiming. A single "checks passed" signature is |
| 18 | the SLSA mistake worth avoiding. |
| 19 | |
| 20 | - **Pure checks** — `nix build`, `nix flake check`, lint/type-check as derivations, |
| 21 | `nixosTest`-style integration tests (effectful inside, pure outside). Inputs content-addressed, |
| 22 | outputs deterministic; the attestation carries input, derivation, and output hashes, so **any |
| 23 | verifier can re-derive and confirm**. These are the strong attestations. |
| 24 | - **Effectful checks** — real-network tests, external APIs, benchmarks, anything not |
| 25 | bit-reproducible. The attestation is a notarization: "sealed environment $E ran $T at time $t and |
| 26 | observed $result." Trust here is closer to "I trust the signer." |
| 27 | |
| 28 | Wherever a check can be moved from effectful to pure (via `nixosTest` or microVM sandboxing), it |
| 29 | should be. |
| 30 | |
| 31 | ## The subject is a tree digest |
| 32 | |
| 33 | An attestation is about a tree, not about a commit. The digest that names that tree is |
| 34 | `valley-tree-v1`, and it is defined so that anyone holding the tree can recompute it from the tree |
| 35 | alone. |
| 36 | |
| 37 | Take every entry of the tree: every blob and every symlink, at its path relative to the root. Render |
| 38 | each one as a line |
| 39 | |
| 40 | <mode> <sha256 of the content, in hex> <byte length of the path> <path> |
| 41 | |
| 42 | where the mode is git's — `100644`, `100755`, or `120000` for a symlink, whose content is its target |
| 43 | — and the byte length is written out in decimal. Sort the lines by path, ascending, comparing bytes. |
| 44 | Put `valley-tree-v1` and a newline in front of them. The digest is the SHA-256 of the result, in |
| 45 | lowercase hex. |
| 46 | |
| 47 | The path's byte length is written out because a path can contain a newline, and an entry boundary a |
| 48 | path could forge is a digest an attacker could steer. Directories are not entries: a directory is |
| 49 | implied by the paths beneath it, and git holds no empty ones. A submodule is rejected rather than |
| 50 | digested, because a tree that reaches outside itself is not a thing this digest can be a function |
| 51 | of. |
| 52 | |
| 53 | Nothing else enters the manifest. Not the commit, not the author, not the time, not a store path. |
| 54 | That is what makes an attestation survive the integrator's rebase: the same tree under a rewritten |
| 55 | commit has the same digest, so the attestation still names it. It is also what binds an attestation |
| 56 | to a base, since a tree is the base and the change together |
| 57 | ([ida-cbcbb3c](../.the-valley/ideas/ida-cbcbb3c-attestations-bind-to-a-base.md)). |
| 58 | |
| 59 | The same manifest digests a pure check's output, so the digest a statement records for what a check |
| 60 | produced and the digest it records for what the check ran over are the same kind of thing. |
| 61 | |
| 62 | ## A statement is written down as lines |
| 63 | |
| 64 | A signature covers bytes, so a statement has one written form and every implementation must produce |
| 65 | it exactly. That form is lines. |
| 66 | |
| 67 | The first line is the statement type, which says what the document is and which revision of it this |
| 68 | is. Every line after it is a key, one space, and a value. The text ends with a newline. |
| 69 | |
| 70 | the-valley/attestation/v1 |
| 71 | subject.primary valley-tree-v1 |
| 72 | subject.digest.git-sha1 99b5f2f7… |
| 73 | subject.digest.valley-tree-v1 73847e0b… |
| 74 | predicateType the-valley/check/pure/v1 |
| 75 | predicate.check.name prose-format |
| 76 | predicate.check.runner nix |
| 77 | predicate.check.attribute prose-format |
| 78 | predicate.result passed |
| 79 | predicate.inputs.valley-inputs-v1 8df8c199… |
| 80 | predicate.derivation.sha256 ef69ed0c… |
| 81 | predicate.output.valley-tree-v1 cf1f5a9c… |
| 82 | provenance.harness a harness |
| 83 | provenance.model a model |
| 84 | provenance.delegation.0.principal human:integrator |
| 85 | provenance.delegation.0.grant land changes |
| 86 | |
| 87 | The statement type is on the first line and nowhere else. It is the one thing a reader needs before |
| 88 | anything else — what this document is, and which revision of it — and a signature covers the text |
| 89 | and nothing else, so the first line is also what separates an attestation from any other note a key |
| 90 | signs. One line answers both. |
| 91 | |
| 92 | A key is the path from the document's root to the value, with a dot between segments. A segment that |
| 93 | is a decimal number is an index into an array, so `provenance.delegation.0.principal` is the |
| 94 | principal of the first recorded delegation. |
| 95 | |
| 96 | ### Line order |
| 97 | |
| 98 | A statement is a document a reader reads in order to decide something, so the reader's first |
| 99 | question is answered first. Lines are written in the order below, and that order is fixed. |
| 100 | |
| 101 | 1. The statement type, as the first line. |
| 102 | 2. `subject` — what the statement is about: `primary`, then the digest set. |
| 103 | 3. `predicateType` — what kind of claim this is, which says how to read what follows. |
| 104 | 4. `predicate` — the claim, in the order the claim reads. Per predicate type: |
| 105 | |
| 106 | | `the-valley/check/pure/v1` | `the-valley/check/effectful/v1` | |
| 107 | | --------------------------- | ------------------------------- | |
| 108 | | `predicate.check.name` | `predicate.check.name` | |
| 109 | | `predicate.check.runner` | `predicate.check.runner` | |
| 110 | | `predicate.check.attribute` | `predicate.check.attribute` | |
| 111 | | `predicate.check.command` | `predicate.check.command` | |
| 112 | | `predicate.result` | `predicate.environment` | |
| 113 | | `predicate.inputs` | `predicate.observedAt` | |
| 114 | | `predicate.derivation` | `predicate.result` | |
| 115 | | `predicate.output` | | |
| 116 | |
| 117 | A pure claim reads as the check, its result, and then the three digests a verifier re-derives |
| 118 | against. A notarization reads as the check, the environment it ran in, when that was, and what |
| 119 | was observed. |
| 120 | |
| 121 | The integrator's commit-point claim is the third predicate type, and it is not about a check at |
| 122 | all: it says that evidence produced over one tree stands for another |
| 123 | ([integration.md](./integration.md)). It reads as which change, onto what, from which base, under |
| 124 | which policy, and then the per-check verdicts. |
| 125 | |
| 126 | | `the-valley/integration/transfer/v1` | |
| 127 | | ------------------------------------------------------------ | |
| 128 | | `predicate.change` | |
| 129 | | `predicate.target` | |
| 130 | | `predicate.base` | |
| 131 | | `predicate.policy` | |
| 132 | | `predicate.required` | |
| 133 | | `predicate.checks.<i>.name`, `.rule`, `.evidence`, `.inputs` | |
| 134 | |
| 135 | A transfer statement writes the last of those two lines exactly one way. When the policy required |
| 136 | checks, `predicate.checks` carries one entry per check and `predicate.required` is absent. When |
| 137 | it required none, `predicate.required none` is the line and `predicate.checks` is absent. There |
| 138 | is no third way, and in particular no empty list: an array with no elements has no lines, so it |
| 139 | has no written form, and a landing may not depend on a container the form cannot write down. A |
| 140 | policy that asks nothing of a diff is an ordinary outcome, so the zero case is said in a line |
| 141 | rather than left to be inferred from a missing one. |
| 142 | |
| 143 | 5. `provenance` — what produced the change, last, because it is context for the claim rather than |
| 144 | part of it: `harness`, `model`, `prompt`, `context`, then `delegation`. |
| 145 | |
| 146 | **Within a set keyed by caller-varying names — a digest set, and any map added later — entries sort |
| 147 | by key.** Fixed order where position carries meaning, sorted order where it does not. An array is |
| 148 | positional, so its elements are written in index order: `provenance.delegation.10` follows |
| 149 | `provenance.delegation.9`. |
| 150 | |
| 151 | A field with no position in that order has no written form and is refused. So a new field's position |
| 152 | arrives with the field, and the predicate type is versioned, which is what lets a claim shape grow |
| 153 | without moving what came before it. It also means only a whole statement has a written form: order |
| 154 | is defined per predicate type, so a fragment has no order at all. |
| 155 | |
| 156 | ### What a line can carry |
| 157 | |
| 158 | The form has no escapes, and that is why it was chosen. A value is written as its own bytes, so |
| 159 | there is exactly one way to write it and nothing for two implementations to disagree about. What |
| 160 | follows from that is a short list of things a statement may not carry, each refused rather than |
| 161 | escaped or dropped: |
| 162 | |
| 163 | - **Only strings at the leaves.** A number, a boolean and a null have no written form, because |
| 164 | nobody has decided one and a guess would be a guess about signed bytes. |
| 165 | - **No empty value.** A line's value is what follows its first space, so an empty one would be an |
| 166 | invisible trailing space. A field a statement does not carry is left out. |
| 167 | - **No control character in a value.** A newline is where a line ends, so there is no way to write |
| 168 | one inside a value. |
| 169 | - **No empty object and no empty array.** They have no lines, so they cannot be written down. They |
| 170 | are refused rather than dropped, which is what keeps what was validated and what was signed the |
| 171 | same document. |
| 172 | - **Field names are a letter, then letters, digits and dashes.** That keeps a name clear of the dot |
| 173 | that separates segments, the space that separates key from value, and the digits that mark an |
| 174 | index. |
| 175 | |
| 176 | Arrays are dense: indices run from 0 with no gaps, in decimal without leading zeros. |
| 177 | |
| 178 | Text is accepted only if writing the document it says back out reproduces it byte for byte. That is |
| 179 | the whole acceptance rule, and it makes "these bytes are the written form of what they say" |
| 180 | something a verifier settles by reading rather than a claim it has to take on trust. Line order, a |
| 181 | duplicated key, a set out of order and a value no line can carry all fail the same way, because none |
| 182 | of them is what a renderer would have produced. |
| 183 | |
| 184 | [schema/attestation.cue](../../schema/attestation.cue) is the gate, and it holds every value and |
| 185 | every field name to what a line can carry. So a statement with no written form fails validation |
| 186 | before a run has built anything, rather than in a renderer after a check has already passed. |
| 187 | |
| 188 | ## The envelope is a signed note |
| 189 | |
| 190 | A statement is signed as a **note**: the statement text, a blank line, and one or more signature |
| 191 | lines. Each signature line is an em-dash (U+2014), a space, the signer's name, a space, and base64 |
| 192 | of a four-byte key hash followed by the raw Ed25519 signature over the text. |
| 193 | |
| 194 | the-valley/attestation/v1 |
| 195 | subject.primary valley-tree-v1 |
| 196 | … |
| 197 | |
| 198 | — laddie.gunk.dev/attestations sEDvC7HO4DfL5ZxbZPFvoVWq2Wt5eGTqZx2h… |
| 199 | — witness.gunk.dev/attestations lDb9C3YrmxnO0/YWsmWjiu2kteNvGqfQstCy… |
| 200 | |
| 201 | This is the format `golang.org/x/mod/sumdb/note` defines and transparency log checkpoints are |
| 202 | published in. It is the envelope for what it does to composition: several parties attesting to one |
| 203 | subject are sibling signature lines under one text, so a signature cannot be lifted onto a different |
| 204 | statement — it sits under the text it covers, and moving it means moving that text with it. It is |
| 205 | also the envelope a [Phase 6](./roadmap.md#phase-6--trust-backstop) checkpoint arrives in, so the |
| 206 | same envelope carries an attestation now and a checkpoint later rather than changing at the |
| 207 | boundary. |
| 208 | |
| 209 | A signature covers the text and nothing else: not the signer's name, not a namespace, and no git |
| 210 | object ([ida-51605e8](../.the-valley/ideas/ida-51605e8-authenticity-not-git-coupled.md)). So what |
| 211 | separates an attestation from any other note a key signs is the text's own first line, which is the |
| 212 | statement type. |
| 213 | |
| 214 | **The signer's name** is the host's fully qualified name, a slash, and what it is signing: |
| 215 | `laddie.gunk.dev/attestations`. The host part says which machine to go and ask about a key. The |
| 216 | suffix keeps a key signing attestations distinct, as a verifier key, from the same key signing |
| 217 | anything else — the name is inside the key hash, so the same public key published under two names is |
| 218 | two verifier keys and cannot be confused. |
| 219 | |
| 220 | **What a verifier is given** is a set of known keys, one per line: the name, the key hash its name |
| 221 | and public key produce, and the public key itself. |
| 222 | |
| 223 | laddie.gunk.dev/attestations+1f9c40b2+AbUmzL2tCH0nR9… |
| 224 | |
| 225 | That is the whole of it. There is no allowed-signers file, no certificate and no directory lookup. A |
| 226 | signature by a key not among them is a signature by nobody the verifier accepts, and a signature by |
| 227 | one of them that does not check out refuses the whole note — one good signature standing beside a |
| 228 | forgery is not a note to read past. |
| 229 | |
| 230 | The host signs with a raw Ed25519 key. `/etc/ssh/ssh_host_ed25519_key` is the natural production |
| 231 | identity, because the host already has it and it already says which host this is, but the key is a |
| 232 | parameter and provisioning one is deployment. |
| 233 | |
| 234 | ## The helper |
| 235 | |
| 236 | `nix run .#attest` is the Phase 2 helper. `attest run` digests the tree, runs the checks over an |
| 237 | export of that tree rather than over the working directory, composes one statement per check, vets |
| 238 | each against [schema/attestation.cue](../../schema/attestation.cue), writes each out as statement |
| 239 | text, signs each as a note, and stores them at |
| 240 | `refs/the-valley/attestations/<tree digest>/<signer key hash>`. With `--push` it publishes the topic |
| 241 | branch and that ref in one atomic native-git push. A failing check publishes nothing, and neither |
| 242 | does a statement the schema rejects or a statement with no written form. |
| 243 | |
| 244 | The signing key is a parameter (`--key`), as is the name it signs under (`--name`, defaulting to |
| 245 | this host's). There is no unsigned mode: a run with no key available fails rather than emitting a |
| 246 | statement nobody signed. |
| 247 | |
| 248 | `attest verify` takes a note and a known-keys file, and checks four things: that the note's text is |
| 249 | the written form of what it says, that the statement satisfies the schema, that every signature by a |
| 250 | key the verifier holds checks out over exactly those bytes, and — given `--repo` — that the tree in |
| 251 | front of the verifier is the tree the statement names. `--signer` names a signer whose signature |
| 252 | must be present. Re-running a pure check and confirming its output digest is witness |
| 253 | re-verification, and belongs to [Phase 6](./roadmap.md#phase-6--trust-backstop) rather than here. |
| 254 | |
| 255 | `attest inputs` prints a pure check's input-closure digest and its derivation digest, evaluating the |
| 256 | check over an export of the revision's tree and building nothing. It exists for the integrator: the |
| 257 | pure transfer rule is closure-digest equality ([integration.md](./integration.md)), and check |
| 258 | latency has no business on the commit point's path. |
| 259 | |
| 260 | `attest render` writes a JSON document as statement text, `attest sign` turns statement text into a |
| 261 | note or adds a signature line to one, and `attest key` prints the verifier key for a signing key. |
| 262 | Those bytes are an interop contract rather than an internal step: a second implementation that |
| 263 | writes them differently signs different bytes over the same statement, and every signature already |
| 264 | made stops verifying against it. So [attest/conformance/](../../attest/conformance/) holds fixed |
| 265 | documents paired with their exact text and notes, along with the documents and texts that must be |
| 266 | refused, and the flake's `attest-conformance` check runs the whole set. |
| 267 | |
| 268 | The run provenance a statement carries — the harness, the model, digests of the prompt and the |
| 269 | context, and the delegation chain — is supplied by the caller (`--provenance`) or absent. Nothing |
| 270 | collects those values today. |
| 271 | |
| 272 | ## The mechanism stack |
| 273 | |
| 274 | Without a TEE, attestations are exactly as trustworthy as the signing key — the same trust model as |
| 275 | code signing, plenty for non-adversarial settings. But the mechanisms stack: |
| 276 | |
| 277 | | Mechanism | What it gets you | Residual attack | |
| 278 | | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | |
| 279 | | Signing key | "The signer says these checks passed" | Anyone with the key can lie | |
| 280 | | 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 | |
| 281 | | Hermetic sandbox | `nix build` sandbox; `nixosTest` VMs; microVMs for non-Nix checks | Local root can still bypass — but bypass leaves evidence | |
| 282 | | 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 | |
| 283 | | Witness sampling | Random fraction of attestations re-run on another node; trust score per attester | None — this is the backstop | |
| 284 | | 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. | |
| 285 | |
| 286 | Stacked, a determined local-root actor can still forge an attestation — but only visibly (tool hash |
| 287 | mismatch), temporarily (re-derivation eventually detects), and within a bounded window (before their |
| 288 | trust score is recalculated). For pure-derivation checks this lands roughly at SLSA Level 3; for |
| 289 | effectful checks, lower — but the system knows which kind each attestation is. |