| 1 | # Contributor protocol |
| 2 | |
| 3 | What a contributor (human or agent) does to push a change and request its integration into a |
| 4 | protected ref. |
| 5 | |
| 6 | ## Four properties |
| 7 | |
| 8 | A push that is: |
| 9 | |
| 10 | 1. **Cryptographically attributable** to the contributor. |
| 11 | 2. **Accompanied by a signed promise** that the repo's canonical check set passed locally in a |
| 12 | 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 | All four are produced by one atomic `git push` — native git verbs plus one helper for attestation |
| 17 | composition, no `git` wrapper command. |
| 18 | |
| 19 | ## The steps |
| 20 | |
| 21 | 1. **Commit, signed natively** — SSH commit signing, no GPG. |
| 22 | 2. **Run the canonical check set** — the repo's `flake.nix` check derivations, locally and |
| 23 | hermetically, via one helper (e.g. `nix run .#attest`); if any fails, nothing is published. |
| 24 | 3. **Compose the statements** — one per check, each a typed, versioned record of what ran, over |
| 25 | what, with what result, plus the provenance of the run that produced the change. The subject is a |
| 26 | digest set whose primary member is a content-addressed digest of the resulting tree; a commit |
| 27 | hash may accompany it as an advisory member, never relied on for identity |
| 28 | ([dcr-0de694f](../.the-valley/decisions/dcr-0de694f-phase2-attestation-shape.md)). |
| 29 | 4. **Sign as a note** — the host signs the statement text; the signature covers that text and |
| 30 | nothing else, and further signers add sibling lines under the same text |
| 31 | ([dcr-de9d996](../.the-valley/decisions/dcr-de9d996-statement-text-and-signed-note.md)). |
| 32 | 5. **Store the attestation in the repo** — at a git ref keyed by the subject digest and the signer, |
| 33 | `refs/the-valley/attestations/<tree digest>/<signer key hash>`. |
| 34 | 6. **Publish to the transparency log** — the inclusion proof is appended as a sidecar; lands with |
| 35 | [roadmap Phase 6](./roadmap.md#phase-6--trust-backstop). |
| 36 | 7. **Signal integration intent** — push one ref, |
| 37 | `refs/the-valley/integration-requests/<target>/<change>`, pointing at the change's head. The |
| 38 | target segment names the protected branch and the last segment names the change; the delta is the |
| 39 | merge base with that branch's tip up to the head. Writing it takes the request grant. Nothing |
| 40 | else is encoded, because a change is a diff targeting a stream and every part of that is already |
| 41 | in git ([ida-93e4f91](../.the-valley/ideas/ida-93e4f91-changes-not-branches.md), |
| 42 | [integration.md](./integration.md)). |
| 43 | 8. **Push atomically** — `git push --atomic` of the topic branch plus its attestation refs; all land |
| 44 | or none do. |
| 45 | 9. **Server-side projection** — the bare repo's `post-receive` hook emits one bus event per updated |
| 46 | ref; it is a pure projection, no policy and no verification. |
| 47 | |
| 48 | ## Submitting and checking a request |
| 49 | |
| 50 | Run `valley review <branch>` to review a topic branch already pushed to origin. Choosing `[a]sk` |
| 51 | runs the checks required by the composed policy, signs their results, and publishes the evidence and |
| 52 | request together. Its success message confirms submission. The integrator decides separately whether |
| 53 | the change can land on `origin/main`. Review does not wait for that decision or update the local |
| 54 | checkout. |
| 55 | |
| 56 | Run `valley status <branch>` to read the request and recorded result from origin. It reports whether |
| 57 | the change has integrated, awaits a decision, needs attention, or has a newer commit that has not |
| 58 | been submitted. It reads once; run it again for a later result. It does not submit a request, rerun |
| 59 | checks, or update the local checkout. A changed target or new evidence can make an earlier decision |
| 60 | obsolete. Status reports that a new decision is needed when those inputs have changed. |
| 61 | |
| 62 | The stored outcome contains no detailed failure reason. For stale or rejected evidence, or an |
| 63 | integrator failure, ask the instance operator for the integrator report. A processing failure can |
| 64 | happen after the change lands, so that result alone does not prove the change is absent from main. |
| 65 | |
| 66 | After integration, status shows how to update the local checkout. For a local main branch that can |
| 67 | advance without a merge, the command is `git pull --ff-only origin main`. If another branch is |
| 68 | checked out, switch to main first. If local main has diverged, inspect its commits before updating. |
| 69 | |
| 70 | ## The one invariant |
| 71 | |
| 72 | The bare repo's `pre-receive` hook enforces exactly one structural invariant: what a push may write. |
| 73 | It runs on every project a host serves. Topic branches are open to anyone with push access. |
| 74 | Attestation refs are create-only, and the hook reads each new one: its name must be |
| 75 | `<tree digest>/<signer key hash>`, and every note in it must be about that tree and signed under |
| 76 | that key hash. Each note must open the way a verifier opens it, under the keys the host accepts |
| 77 | evidence from, so a host that names no such keys accepts no attestation. The pusher need not be the |
| 78 | signer, because evidence is relayed. Only a principal holding the request grant may write an |
| 79 | integration request. Every other ref, tags included, takes a named grant of the project. A protected |
| 80 | ref also takes a declared writer. Replacement refs, notes and the rest of the valley's own namespace |
| 81 | take no push. All complex policy lives in the integrator ([architecture.md](./architecture.md), _The |
| 82 | one structural git invariant_). |