| 1 | # Contributor protocol |
| 2 | |
| 3 | Defines exactly what a contributor (human or agent) does to push a change and request its integration into a protected ref. |
| 4 | |
| 5 | This is the *protocol* that the trust model ([verification](./verification.md)) and the integrator ([integration](./integration.md)) both consume. It is intentionally tight; mechanisms for the integrator's queue, conflict resolution, and issue tracking are out of scope and have their own placeholder documents. |
| 6 | |
| 7 | ## Goal |
| 8 | |
| 9 | A push that is: |
| 10 | |
| 11 | 1. **Cryptographically attributable** to the contributor. |
| 12 | 2. **Accompanied by a signed promise** that the repo's canonical check set passed locally in a hermetic environment. |
| 13 | 3. **Externally tamper-evident** via inclusion in a transparency log. |
| 14 | 4. **Explicitly marked** as ready for integration into a target branch. |
| 15 | |
| 16 | These four properties are produced by one atomic `git push`, with no `git` wrapper command. The contributor uses native git verbs and one helper for attestation composition. |
| 17 | |
| 18 | ## Steps |
| 19 | |
| 20 | ### 1. Commit, signed natively |
| 21 | |
| 22 | The contributor commits as normal. The commit is SSH-signed using modern git's native commit signing — `git config gpg.format ssh` and a `commit.gpgsign = true` setting. No GPG. The signature establishes *who made this commit*. |
| 23 | |
| 24 | ### 2. Run the canonical check set, locally and hermetically |
| 25 | |
| 26 | The repo's `flake.nix` declares a set of derivations as the canonical checks — `checks.<system>.unit`, `.lint`, `.integration`, whatever the repo wants. Each runs in the Nix sandbox; effectful checks are wrapped as `nixosTest` VMs so they are pure derivations from the outside. |
| 27 | |
| 28 | The contributor runs them via a single helper (e.g. `nix run .#attest`). All must succeed. If any fails, the helper exits non-zero and nothing is published. |
| 29 | |
| 30 | ### 3. Compose the attestation |
| 31 | |
| 32 | The helper assembles a structured claim about what ran: |
| 33 | |
| 34 | ```json |
| 35 | { |
| 36 | "subject_commit": "<commit-sha>", |
| 37 | "issued_at": "<rfc3339>", |
| 38 | "checks": [ |
| 39 | { |
| 40 | "kind": "pure", |
| 41 | "tool": "sha256:<attestation-tool-derivation>", |
| 42 | "inputs": ["sha256:..."], |
| 43 | "derivation": "sha256:...", |
| 44 | "output": "sha256:...", |
| 45 | "result": "success" |
| 46 | }, |
| 47 | ... |
| 48 | ] |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | The attestation makes no claim about *intent to integrate*. That is signaled by the ref namespace in step 6. |
| 53 | |
| 54 | ### 4. Sign and publish to a transparency log |
| 55 | |
| 56 | The helper signs the attestation with the contributor's SSH key (same key as the commit signature). The signed attestation is submitted to a Tessera-backed transparency log; the log returns an inclusion proof. The proof is appended to the signed attestation as a sidecar field. |
| 57 | |
| 58 | The tlog gives the system *non-repudiation and external auditability*: anyone can verify the attestation was logged, when, with what content, and that the log itself is internally consistent. This is independent of and complementary to re-derivation witnessing (see [verification](./verification.md)) — the tlog proves *the attestation exists and is unchanged*; re-derivation proves *the computation it describes actually produces the claimed result*. |
| 59 | |
| 60 | ### 5. Store the attestation in the repo's object store |
| 61 | |
| 62 | The signed attestation (with inclusion proof) is added as a git blob, and a ref is created: |
| 63 | |
| 64 | ``` |
| 65 | refs/the-valley/attestations/<commit-sha> → attestation blob |
| 66 | ``` |
| 67 | |
| 68 | This makes the attestation distributable by standard `git fetch` and trivially lookupable by commit SHA. The naming pattern mirrors gittuf's convention without adopting gittuf as a dependency. |
| 69 | |
| 70 | ### 6. Signal integration intent |
| 71 | |
| 72 | A second ref is set, pointing at the topic commit: |
| 73 | |
| 74 | ``` |
| 75 | refs/the-valley/integration-requests/<request-name> → topic-commit-sha |
| 76 | ``` |
| 77 | |
| 78 | Pushing to this namespace is the contributor's signal: *please integrate this commit into the target branch declared by repository policy*. Without this ref push, the topic branch is just a backup; no integrator reacts. |
| 79 | |
| 80 | ### 7. Atomic push |
| 81 | |
| 82 | ``` |
| 83 | git push --atomic origin \ |
| 84 | refs/heads/topic/<name> \ |
| 85 | refs/the-valley/attestations/<commit-sha> \ |
| 86 | refs/the-valley/integration-requests/<request-name> |
| 87 | ``` |
| 88 | |
| 89 | Either all three refs land or none do. No wrapper command — this is native git. |
| 90 | |
| 91 | ### 8. Server-side projection |
| 92 | |
| 93 | The bare repo's `post-receive` hook fires once. For each updated ref, it emits a corresponding event onto the bus: |
| 94 | |
| 95 | - `refs/heads/*` → `ref-updated` |
| 96 | - `refs/the-valley/attestations/*` → `attestation-published`, carrying the attestation blob |
| 97 | - `refs/the-valley/integration-requests/*` → `integration-requested` |
| 98 | |
| 99 | The hook is a pure projection from git to bus. It performs no policy and no verification — those are the integrator's job. |
| 100 | |
| 101 | ## What protects the canonical refs |
| 102 | |
| 103 | The bare repo enforces *one* structural invariant via a `pre-receive` hook: |
| 104 | |
| 105 | - Only the integrator's SSH key may write `refs/heads/<protected>`. |
| 106 | - Attestation refs are create-only (no updates) to keep attestations append-only-per-commit. |
| 107 | - All other namespaces — topic branches, integration requests — are wide open to anyone with push access. |
| 108 | |
| 109 | The complex policy lives in the integrator. The git boundary enforces only the minimum needed for the controller pattern to work. |
| 110 | |
| 111 | ## What ties this together |
| 112 | |
| 113 | | Property | Source | |
| 114 | | --- | --- | |
| 115 | | Who made the commit | SSH commit signature | |
| 116 | | Who made the attestation | SSH signature on the attestation blob (same key) | |
| 117 | | What checks ran and what they produced | Attestation content (derivation hashes) | |
| 118 | | External tamper evidence | Tessera tlog inclusion proof | |
| 119 | | Lookup by commit | `refs/the-valley/attestations/<commit-sha>` ref | |
| 120 | | Intent to integrate | `refs/the-valley/integration-requests/*` ref namespace | |
| 121 | | Atomicity | `git push --atomic` | |
| 122 | |
| 123 | ## Out of scope |
| 124 | |
| 125 | - **Integrator internals** — how the merge queue works, conflict resolution, agentic fallback. See [integrator-internals.md](./integrator-internals.md). |
| 126 | - **Issue tracking** — how bugs, feature ideas, and tasks are recorded and worked. See [issues.md](./issues.md). |
| 127 | - **Per-repo policy file** — where the trusted-signer list and the canonical-checks declaration live, and how they are themselves authenticated and updated. To be designed; likely a `refs/the-valley/policy` ref carrying a signed configuration. |
| 128 | - **Multi-signature attestations** — for higher-trust paths, requiring N signers on a single attestation. Gittuf demonstrates this is tractable; not in v1. |
| 129 | - **Tlog deployment** — self-hosted Tessera on the same Tailscale box vs. a shared instance. An operational choice that doesn't affect the protocol. |
| 130 | |
| 131 | ## Open questions |
| 132 | |
| 133 | See [openquestions.md](./openquestions.md) — items raised here live under *Identity & trust bootstrapping*, *Storage, retention, and evolution*, and *Verification specifics*. |