gunk-dev/the-valley

verification.md

source338bf6ca3fe9main's published tip history
6.2 KiB · Rendered
1# Verification & trust
2
3How the system decides a change is safe to integrate, without a central CI gate.
4
5## The reframe
6
7CI-as-gate ("the change is blocked until our infra confirms the checks pass") is replaced by **attestation-with-revocation**:
8
91. The developer's local environment runs the checks in a hermetic sandbox.
102. It produces a signed attestation describing what ran, against what inputs, and what the result was.
113. The commit and its attestations land in the event log together.
124. Subscribers act immediately on the attestation. Re-verifiers cross-check asynchronously.
135. Trust is *measured* per attester, based on re-verification confirm rates. Divergence revokes trust.
14
15This 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
22For 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
26Without 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| 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. |
36
37Stack 2–6 and a determined local-root actor *can* still forge an attestation, but only by:
38
39- Shipping a tool whose hash doesn't match the canonical (visible).
40- Producing a derivation hash that won't match on re-derivation (eventually detected).
41- Doing so before their trust score is recalculated (bounded window).
42
43For pure-derivation checks this lands roughly at SLSA Level 3. For effectful checks, lower — but the system knows which kind each attestation is.
44
45## Two kinds of checks, two kinds of attestation
46
47The system must distinguish what an attestation is claiming. A single "checks passed" signature is the SLSA mistake worth avoiding.
48
49### Pure checks
50
51- `nix build` of the project
52- `nix flake check`
53- Type-checking, linting, formatting (when wrapped as derivations)
54- `nixosTest`-style integration tests (effectful from inside, pure from outside)
55
56Inputs 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.
57
58### Effectful checks
59
60- Real-network integration tests
61- Tests against external APIs or stateful services
62- Performance benchmarks
63- Anything not bit-reproducible
64
65The 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."
66
67Wherever a check can be moved from effectful to pure (via `nixosTest` or microVM sandboxing), it should be.
68
69## Attestation shape
70
71Sketch, not a spec:
72
73```
74{
75 "subject": {
76 "repo": "...",
77 "commit": "sha256:..."
78 },
79 "checks": [
80 {
81 "kind": "pure",
82 "tool": "sha256:...", // attestation tool derivation hash
83 "inputs": ["sha256:..."], // input derivation hashes
84 "derivation": "sha256:...",
85 "output": "sha256:...",
86 "result": "success"
87 },
88 {
89 "kind": "effectful",
90 "tool": "sha256:...",
91 "env": "sha256:...", // sealed-environment derivation hash
92 "test": "sha256:...",
93 "result": "success",
94 "observed_at": "..."
95 }
96 ],
97 "signatures": [
98 {"key_id": "...", "sig": "..."}
99 ]
100}
101```
102
103The attestation is itself an event published into the log.
104
105## Reactions on the event
106
107A few subscribers worth naming:
108
109- **Deploy controller** — `attestation valid + signer trusted + ref matches main → deploy`.
110- **Re-verifier (pure)** — re-derive any pure attestation; emit confirm/deny event.
111- **Re-verifier (effectful sample)** — re-run a sampled fraction of effectful attestations on a witness node.
112- **Trust controller** — track per-attester confirm rate. Below threshold → revoke trust → future attestations from that signer require gating before reactions.
113- **Review controller** — open a human review request regardless. Attestations replace the *correctness gate*, not the *human review*.
114
115## What this is not
116
117- 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.
118- 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.
119- 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.
120
121## Open questions
122
123See [openquestions.md](./openquestions.md) — items raised here live under *Identity & trust bootstrapping*, *Storage, retention, and evolution*, and *Verification specifics*.