| 1 | # Verification |
| 2 | |
| 3 | An attestation is a signed statement about a check and its result. It identifies the tree checked, |
| 4 | the computation or observation performed, and any supplied provenance. The integrator uses that |
| 5 | statement as evidence under the project's governing policy. |
| 6 | |
| 7 | This document defines the current formats and helper behavior. Independent re-verification and |
| 8 | transparency publication remain [Phase 6 work](./roadmap.md#phase-6--trust-backstop). The |
| 9 | [attestation decision](../.the-valley/decisions/dcr-0de694f-phase2-attestation-shape.md) defines the |
| 10 | overall shape; the |
| 11 | [text and signature decision](../.the-valley/decisions/dcr-de9d996-statement-text-and-signed-note.md) |
| 12 | fixes the signed representation. |
| 13 | |
| 14 | ## Pure and effectful checks |
| 15 | |
| 16 | A **pure check** claims a reproducible computation over identified inputs. Examples include builds, |
| 17 | lint, and tests packaged as Nix derivations. Its statement records the input digest, derivation |
| 18 | digest, output digest, and result. Another verifier can attempt the same computation and compare |
| 19 | those values. |
| 20 | |
| 21 | An **effectful check** records an observation of a changing environment. Examples include a test |
| 22 | against a live API or a measurement whose result is not reproducible from fixed inputs. Its |
| 23 | statement records the check, environment, time, and observed result. Repeating it later produces a |
| 24 | new observation, not necessarily confirmation of the old one. |
| 25 | |
| 26 | A test involving services may still be packaged as a pure check if the relevant environment is |
| 27 | controlled, for example in a `nixosTest` VM. Doing that reduces dependence on mutable external |
| 28 | state. Classifying a runner as pure is still a claim about its execution conditions and |
| 29 | reproducibility. |
| 30 | |
| 31 | The policy chooses the required runner. An attestation cannot select a weaker transfer rule for |
| 32 | itself by claiming a different check kind. [Integration](./integration.md#evaluating-a-request) |
| 33 | defines how the two kinds of evidence transfer to a new base. |
| 34 | |
| 35 | ## Tree identity |
| 36 | |
| 37 | The primary subject of an attestation is a digest of the checked tree. A Git commit ID may accompany |
| 38 | it as an advisory identifier, but does not define the subject. |
| 39 | |
| 40 | The `valley-tree-v1` digest is SHA-256 over a canonical manifest: |
| 41 | |
| 42 | 1. Begin with `valley-tree-v1` followed by a newline. |
| 43 | 2. Enumerate every regular file, executable file, and symlink at its path relative to the tree root. |
| 44 | 3. Sort entries by path bytes in ascending order. |
| 45 | 4. Append each entry in this form, followed by a newline: |
| 46 | |
| 47 | ```text |
| 48 | <mode> <SHA-256 of content in lowercase hex> <path byte length in decimal> <path> |
| 49 | ``` |
| 50 | |
| 51 | Modes are Git's `100644`, `100755`, and `120000`. A symlink's content is its target. Directories are |
| 52 | implied by the paths beneath them and have no entries of their own. Submodules are rejected because |
| 53 | their content is not contained in the tree being digested. |
| 54 | |
| 55 | The path length prevents an embedded newline in a path from being confused with an entry boundary. |
| 56 | The final digest is rendered as lowercase hexadecimal. |
| 57 | |
| 58 | Commit metadata, timestamps, and store locations do not enter the manifest. Two commits containing |
| 59 | the same tree therefore have the same subject digest. If rebasing changes the tree, the original |
| 60 | attestation still names the original tree; the integrator must establish whether its evidence |
| 61 | transfers. [Base binding](../.the-valley/ideas/ida-cbcbb3c-attestations-bind-to-a-base.md) explains |
| 62 | that distinction. |
| 63 | |
| 64 | The helper uses the same manifest for a pure check's output. A single-file output is represented as |
| 65 | an entry at the empty path. |
| 66 | |
| 67 | ### Input and derivation digests |
| 68 | |
| 69 | `valley-inputs-v1` identifies the set of input names reported by a runner. Its manifest begins with |
| 70 | `valley-inputs-v1` and a newline. Names are sorted by bytes and deduplicated. Each is written as its |
| 71 | byte length in decimal, a space, the name, and a newline. SHA-256 over that manifest, rendered in |
| 72 | lowercase hex, is the digest. |
| 73 | |
| 74 | The Nix runner obtains these names from the derivation's referenced store paths. It separately |
| 75 | hashes the derivation file's bytes with SHA-256. These are the two values recomputed for pure |
| 76 | evidence transfer. The definitions and reference implementation are in |
| 77 | [attest/digest.go](../attest/digest.go) and [attest/check.go](../attest/check.go). |
| 78 | |
| 79 | ## Statement text |
| 80 | |
| 81 | A signature covers bytes, so each statement has one canonical text representation. The first line is |
| 82 | the statement type. Each remaining line contains a field path, one space, and a value. The text ends |
| 83 | with a newline. |
| 84 | |
| 85 | This schematic example abbreviates digests and is not a valid statement to submit: |
| 86 | |
| 87 | ```text |
| 88 | the-valley/attestation/v1 |
| 89 | subject.primary valley-tree-v1 |
| 90 | subject.digest.git-sha1 99b5f2f7… |
| 91 | subject.digest.valley-tree-v1 73847e0b… |
| 92 | predicateType the-valley/check/pure/v1 |
| 93 | predicate.check.name prose-format |
| 94 | predicate.check.runner nix |
| 95 | predicate.check.attribute prose-format |
| 96 | predicate.result passed |
| 97 | predicate.inputs.valley-inputs-v1 8df8c199… |
| 98 | predicate.derivation.sha256 ef69ed0c… |
| 99 | predicate.output.valley-tree-v1 cf1f5a9c… |
| 100 | provenance.harness example-harness |
| 101 | provenance.model example-model |
| 102 | provenance.delegation.0.principal human:operator |
| 103 | provenance.delegation.0.grant authorized project work |
| 104 | ``` |
| 105 | |
| 106 | The first line identifies both the kind of document and its version. It also distinguishes these |
| 107 | signed bytes from other kinds of statement the same key might sign. |
| 108 | |
| 109 | Dots separate field-path segments. A decimal segment denotes an array index: |
| 110 | `provenance.delegation.0.principal` names the principal in the first recorded delegation. |
| 111 | |
| 112 | ### Line order |
| 113 | |
| 114 | Render fields in this order, omitting only fields the statement does not carry: |
| 115 | |
| 116 | 1. Statement type, as the first line. |
| 117 | 2. `subject.primary`, then `subject.digest` entries. |
| 118 | 3. `predicateType`. |
| 119 | 4. `predicate` fields in the order defined for that predicate type. |
| 120 | 5. `provenance`: `harness`, `model`, `prompt`, `context`, then `delegation`. |
| 121 | |
| 122 | The check predicate orders are: |
| 123 | |
| 124 | | `the-valley/check/pure/v1` | `the-valley/check/effectful/v1` | |
| 125 | | --------------------------- | ------------------------------- | |
| 126 | | `predicate.check.name` | `predicate.check.name` | |
| 127 | | `predicate.check.runner` | `predicate.check.runner` | |
| 128 | | `predicate.check.attribute` | `predicate.check.attribute` | |
| 129 | | `predicate.check.command` | `predicate.check.command` | |
| 130 | | `predicate.result` | `predicate.environment` | |
| 131 | | `predicate.inputs` | `predicate.observedAt` | |
| 132 | | `predicate.derivation` | `predicate.result` | |
| 133 | | `predicate.output` | | |
| 134 | |
| 135 | The third predicate, `the-valley/integration/transfer/v1`, records the integrator's decision that |
| 136 | evidence applies to the landed tree. Its field order is: |
| 137 | |
| 138 | | Field or group | Meaning | |
| 139 | | ------------------------------------------------------------ | --------------------------------------------------- | |
| 140 | | `predicate.change` | Change identifier | |
| 141 | | `predicate.target` | Target ref | |
| 142 | | `predicate.base` | Digest set identifying the originally attested tree | |
| 143 | | `predicate.policy` | Digest set identifying the governing policy | |
| 144 | | `predicate.required` | Explicit zero-check case, when applicable | |
| 145 | | `predicate.checks.<i>.name`, `.rule`, `.evidence`, `.inputs` | Per-check transfer verdicts | |
| 146 | |
| 147 | A transfer statement must use exactly one of two forms: |
| 148 | |
| 149 | - When checks were required, `predicate.checks` contains an entry for each, and `predicate.required` |
| 150 | is absent. |
| 151 | - When none were required, it contains `predicate.required none`, and `predicate.checks` is absent. |
| 152 | |
| 153 | An empty array cannot represent the zero-check case because it produces no lines. |
| 154 | |
| 155 | Digest sets and other maps whose keys vary by caller sort by key. Arrays use numeric index order, so |
| 156 | element 10 follows element 9. Each recorded delegation writes `principal` before `grant`. A field |
| 157 | without a defined position is rejected. New fields need a defined order and appropriate versioning; |
| 158 | arbitrary document fragments have no independent canonical form. |
| 159 | |
| 160 | ### Allowed values |
| 161 | |
| 162 | The text format has no escaping. Its constraints are part of the signing contract: |
| 163 | |
| 164 | - Leaves must be nonempty strings. Numbers, booleans, and null are rejected. |
| 165 | - Values cannot contain ASCII control characters, including newlines. |
| 166 | - Empty objects and arrays are rejected, rather than silently dropped. |
| 167 | - Field names begin with an ASCII letter and continue with letters, digits, or dashes. |
| 168 | - Array indices start at zero, have no gaps, and use decimal without leading zeros. |
| 169 | |
| 170 | A verifier accepts text only if parsing it and rendering the resulting document reproduces the same |
| 171 | bytes. Duplicate keys, incorrect ordering, unsupported fields, and values that cannot be represented |
| 172 | therefore fail verification. |
| 173 | |
| 174 | [schema/attestation.cue](../schema/attestation.cue) validates statement fields and values. Schema |
| 175 | validation and canonical rendering must agree on the document being signed. |
| 176 | |
| 177 | ## Signed notes |
| 178 | |
| 179 | A signed note contains the statement text, a blank line, and one or more signature lines. Each |
| 180 | signature line has this form and ends with a newline: |
| 181 | |
| 182 | ```text |
| 183 | — <signer name> <base64 of key hash followed by signature> |
| 184 | ``` |
| 185 | |
| 186 | The leading character is an em dash, U+2014. The base64 payload contains the four-byte key hash in |
| 187 | big-endian order followed by the raw Ed25519 signature over the statement text, including its final |
| 188 | newline. |
| 189 | |
| 190 | This is the signed-note format used by `golang.org/x/mod/sumdb/note`. Several signers add sibling |
| 191 | signature lines under the same statement text. Adding a signature does not change the claim or the |
| 192 | bytes earlier signers covered. |
| 193 | |
| 194 | The signature covers the statement text. It does not cover Git objects, envelope fields, or the |
| 195 | signer's displayed name. The statement type on the first line provides the distinction between kinds |
| 196 | of signed claim. |
| 197 | |
| 198 | ### Signing names and verifier keys |
| 199 | |
| 200 | The naming convention is a host's fully qualified name followed by the signing purpose, for example |
| 201 | `laddie.gunk.dev/attestations`. |
| 202 | |
| 203 | A verifier receives known keys as one line per key: |
| 204 | |
| 205 | ```text |
| 206 | <name>+<eight hexadecimal digits of key hash>+<base64 public-key encoding> |
| 207 | ``` |
| 208 | |
| 209 | The public-key encoding contains the algorithm byte followed by the public key. The hash is the |
| 210 | first four bytes of SHA-256 over the name, a newline, the algorithm byte, and the public key. |
| 211 | Publishing one raw key under two names therefore produces two verifier identities. |
| 212 | |
| 213 | Unknown signatures do not establish trust. At least one recognized signature must verify, and an |
| 214 | invalid signature claiming a recognized key causes the whole note to fail. A valid sibling signature |
| 215 | does not excuse that failure. |
| 216 | |
| 217 | The helper signs with a raw Ed25519 key supplied by the host. A host SSH key can serve this role; |
| 218 | provisioning and custody are deployment concerns. Native SSH commit signing and signed-note |
| 219 | verification are separate formats with separate verifier configuration. |
| 220 | |
| 221 | The planned physical human approval in the |
| 222 | [core decision](../.the-valley/decisions/dcr-9c75283-substrate-adoption-and-the-core.md) needs its |
| 223 | own usable signing mechanism. The current host-signed note does not establish that a person |
| 224 | physically approved the change. |
| 225 | |
| 226 | ## The helper |
| 227 | |
| 228 | `nix run .#attest -- <command>` runs the reference helper. Its commands are: |
| 229 | |
| 230 | | Command | Behavior | |
| 231 | | -------- | ----------------------------------------------------------------------------------------------------------------------- | |
| 232 | | `run` | Run checks over an export of a committed tree, compose and sign one statement per check, and store the evidence locally | |
| 233 | | `verify` | Validate the note, statement, and recognized signatures; optionally compare the subject with a repository tree | |
| 234 | | `digest` | Compute the tree digest for a revision | |
| 235 | | `inputs` | Evaluate pure checks and print input and derivation digests without building them | |
| 236 | | `render` | Render a statement supplied as JSON into canonical text | |
| 237 | | `sign` | Sign statement text or add a signature to an existing note | |
| 238 | | `key` | Print the verifier key corresponding to a signing key | |
| 239 | |
| 240 | `attest run` uses committed content rather than uncommitted files in the working directory. The key |
| 241 | is supplied with `--key`; `--name` selects the signing name, defaulting to the host's. There is no |
| 242 | unsigned mode. A failing check, invalid statement, or signing failure prevents publication. |
| 243 | |
| 244 | Evidence is stored beneath: |
| 245 | |
| 246 | ```text |
| 247 | refs/the-valley/attestations/<tree digest>/<signer key hash> |
| 248 | ``` |
| 249 | |
| 250 | With `--push`, the helper publishes the topic branch and its attestation ref in one atomic native |
| 251 | Git push. This does not submit an integration request. The |
| 252 | [contributor workflow](./contribute.md#publishing-and-requesting-integration) explains how |
| 253 | `valley review` publishes evidence and a request together. |
| 254 | |
| 255 | `attest verify` checks canonical text, schema validity, and signatures by recognized keys. With |
| 256 | `--repo`, it also checks the named tree; `--signer` requires a particular signer's signature. It |
| 257 | does not rerun the check. Witness re-verification is a separate planned operation. |
| 258 | |
| 259 | Run provenance is optional caller input through `--provenance`. It can record the harness, model, |
| 260 | prompt and context digests, and delegation chain. The helper does not collect those values |
| 261 | automatically or establish that a recorded delegation was authorized. |
| 262 | |
| 263 | The files in [attest/conformance/](../attest/conformance/) pair documents with exact text and signed |
| 264 | notes, and include inputs that must be rejected. The `attest-conformance` check tests this |
| 265 | interoperability contract. |
| 266 | |
| 267 | ## Trust and limits |
| 268 | |
| 269 | The mechanisms establish different things: |
| 270 | |
| 271 | | Mechanism | What it establishes | What it does not establish | |
| 272 | | --------------------------------- | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | |
| 273 | | Signature | A recognized key signed these bytes | That the stated check actually ran or the signer described it honestly | |
| 274 | | Tree and computation digests | Which content and computation the claim identifies | That the check itself enforces the intended requirement | |
| 275 | | Reproducible execution | A basis for independently checking a result | Proof from the author's report alone | |
| 276 | | Pinned tool and check definitions | Which implementations are intended to run | That a compromised host actually used them | |
| 277 | | Witness re-verification, planned | Independent comparison for the checks sampled | Immediate detection or coverage of every accepted claim | |
| 278 | | Transparency log, planned | Evidence of publication and later tampering under the log's verification model | Correctness of execution or automatic recovery from a bad change | |
| 279 | |
| 280 | A host with access to a signing key can make a false but correctly signed statement, including a |
| 281 | false claim about the tool it used. A sandbox helps control normal execution but cannot make the |
| 282 | host's own report independent of that host. |
| 283 | |
| 284 | There is also a current |
| 285 | [check-definition gap](../.the-valley/bugs/bd-eaefe82-check-definitions-come-from-the-branch.md): |
| 286 | the policy comes from governing state, but check derivations still come from the candidate tree. |
| 287 | Rerunning a weakened check can reproduce its result without detecting the weakened requirement. |
| 288 | |
| 289 | The proposed trust system still needs rules for sampling, new signers, revocation, retention, and |
| 290 | recovery after a false claim has already been accepted. These limits do not establish a supply-chain |
| 291 | assurance level or a guaranteed detection window. |