gunk-dev/the-valley

approve.txt

source58e68be0d151main's published tip history
11.5 KiB
1usage: valley approve [-v] [--head <sha>] [--build-here]
2 [--approval-key <file> | --approval-piv] <change>
3
4 approve [-v] [--head <sha>] [--build-here]
5 [--approval-key <file> | --approval-piv] <change>
6 do what review's [a]pprove does for the change, without
7 paging it: the same checks, the same refusals, the same
8 leased request write and the same output. exits non-zero
9 when it refuses. a change with a record is approved at
10 exactly one head, and its request is filed as
11 refs/the-valley/integration-requests/main/c-<change id>,
12 at that head:
13 --head SHA approve exactly this head, which must be
14 one of the record's version heads,
15 active or not. a front end passes the
16 head it showed, so a record that moves
17 after review cannot change what lands.
18 without --head, approve shows the active version's head
19 and title and asks to confirm them, on a terminal; off
20 one it refuses. a branch no record is on is approved at
21 its tip on origin, which --head must name if it is
22 given (review's [a]pprove files the head it showed, and
23 refuses once the branch on origin has moved off it), under
24 the branch's request name: the branch with
25 each / replaced by -. a branch whose request name would
26 be c-<change id> is refused, since that name is the
27 change's.
28 approve first reads the evidence origin holds for that
29 head's tree, refs/the-valley/attestations/<tree>/*, byte
30 for byte. it judges each required nix check by the note
31 the integrator judges it by: the first, in ref order,
32 that attest verify accepts under the known-signers file
33 the host publishes. it reuses that note when it is pure
34 evidence for the check's name and flake attribute and
35 says it passed. VALLEY_KNOWN_SIGNERS, when set, must
36 accept it too: it can narrow what is reused, never widen
37 it. a required nix check whose judged note records a
38 failure refuses the approval, since the integrator
39 judges the check by that note. a command check is never
40 reused. a listing or a fetch of
41 origin's evidence that fails is refused, and nothing is
42 run.
43 a required nix check that origin holds no evidence for
44 does not stop the approval. approve files the request at
45 once, with the evidence origin holds, builds nothing,
46 and publishes no evidence for that check. required
47 command checks still run first, and a missing signing
48 key, a failed check, or a refused push still fails the
49 approval. approve says the approval is recorded and
50 how many checks it waits for. the integrator keeps the
51 request and considers it again when evidence is
52 published. landing still requires a clean apply and
53 acceptable evidence for every required check. an
54 enabled worker that serves the project attempts the nix
55 checks of a ready change's active version, but cannot
56 add checks to its own existing evidence ref for the
57 same tree, and a failed build publishes nothing. waiting
58 does not ensure the evidence will be published. no
59 worker builds a branch no record is on, or a version
60 that is not the active one, and approve says so and
61 offers --build-here. the
62 evidence of an approval that ran a command check
63 occupies this signer's ref for the tree, so use
64 --build-here on the initial approval.
65 --build-here build those nix checks on this
66 machine instead, and publish their
67 evidence with the request.
68 approve runs every command check, and every nix check
69 it builds, over a throwaway worktree of that head, signs
70 each result as an attestation, and publishes the new
71 evidence and the request ref to origin in ONE atomic
72 push. when every required check is reused, nothing
73 runs, no signing key is needed, and the push carries
74 the request alone.
75 this files the request; it does not wait for
76 integration or update your local checkout. use status to
77 read the result. the policy comes from the target's tip
78 and the owning valley's, as checks describes (valley help
79 checks), so your checkout can be on any branch. a change
80 the policy requires no check of is filed too, as a
81 request with no evidence, and says so. approving a
82 change already requested is how it is filed again: at a
83 head rebased onto a moved main it replaces the request
84 ref under a lease and names the head it replaced; at the
85 same head it leaves the ref alone and publishes only the
86 new evidence. origin already holding this signer's
87 evidence for that tree, without a check that still has
88 to run, is refused before anything runs: approve
89 publishes a signer's evidence for a tree once, as a
90 ref of the new notes alone, and origin keeps every
91 note the ref holds (bd-7b7d58f). every
92 write of the request ref
93 is leased, filing included, so an approval that lost a
94 race is refused rather than clobbering the one that won.
95 needs the attest helper whenever a check is required,
96 and VALLEY_ATTEST_KEY, the ed25519 key this host signs
97 with, whenever a check has to run here;
98 VALLEY_ATTEST_NAME is the name it signs under,
99 defaulting to this host's. approve never writes the
100 protected ref: the integrator does, having judged the
101 request.
102 approve refuses, before any check runs, a head that does
103 not fast-forward from main and would bring a version of
104 another change that has not landed: a layer above the
105 bottom of a stale stack. the refusal names the command
106 that rebases the stack, valley rebase <change>. this is
107 the project's choice, not a rule the integrator needs:
108 approved as it is, the stack would land as one commit
109 recorded against this request alone, so the changes
110 under it would have no landing record of their own, and
111 the checks would run over a head that has to be rebased
112 anyway. a stale head with no change under it, such as
113 the bottom layer of a stack or a change alone, is
114 approved as it is, and the integrator merges it onto
115 main.
116 with an approval key selected, approve also signs an
117 approval of the version it files, and publishes the
118 note at refs/the-valley/approvals/main/c-<change id>
119 in the same atomic push, leased like the request:
120 --approval-key FILE sign with this unencrypted
121 OpenSSH ed25519 key. VALLEY_APPROVAL_KEY
122 selects it too.
123 --approval-piv sign with the key in a YubiKey's PIV
124 slot, VALLEY_APPROVAL_PIV or 9c, on the
125 reader VALLEY_APPROVAL_PIV_READER names.
126 the device asks for its PIN and a touch
127 as the slot's policies say. setting
128 VALLEY_APPROVAL_PIV selects it too. on
129 any platform but linux it is refused:
130 hardware signing is not available.
131 a flag beats the environment, and selecting both kinds
132 at one level is refused. the note signs the instance,
133 the project origin's URL names, main, the change, the
134 version and head approved, the record commit that
135 version was read from, the principal and the time. the
136 key must be listed in approval-signers, which the host
137 publishes at refs/the-valley/signers, and in
138 approval-signers-hardware when the policy sets
139 approval.hardware. approve refuses and publishes
140 nothing when the key is not listed, the publication is
141 missing or changes before the push, the change has no
142 recorded version (ready it first), or the key does not
143 sign: no device, no PIN, no touch. it never falls back
144 to an unsigned approval or another key. with no key
145 selected, approve says no signed approval was written.
146 landing does not check the note.
147 approve ends in one verdict line: the change, whether
148 it was approved, and what happens next, with one
149 indented line under it only when you must act:
150 ✓ nqyw v3 approved · checks passed · landing on main
151 ✓ nqyw v3 signed and approved · checks passed · landing on main
152 ◐ nqyw v3 approved · lands when 3 checks pass (1/4 passed)
153 ◇ nqyw v3 approved · waiting for 2 checks (no worker building)
154 run: valley approve --build-here nqyw
155 ⊘ nqyw v3 not approved · change is a draft
156 run: valley ready --change <id> <branch>
157 a refusal goes to stderr. checks built here show one
158 line of progress, and a failed check's log. the glyphs
159 are in colour on a terminal unless NO_COLOR is set.
160 -v, --verbose also print what approve read and
161 published: the checks it reuses and who
162 signed them, the tree's digest, the
163 evidence and request refs, the approval
164 note's ref, principal and key, and the
165 checks' own output and timings.
166 approve times each required check it runs, and
167 appends one JSON line per check to the timing log,
168 $XDG_STATE_HOME/valley/timings.jsonl (default
169 ~/.local/state/valley/timings.jsonl). the log stays on
170 this machine and is not evidence; a log that cannot be
171 written is a warning, and approving goes on.