gunk-dev/the-valley

policy.cue

sourced5649addb600main's published tip history
11.8 KiB
1// the-valley's project layer: what this one project declares above the
2// floor. The floor is the owning valley's (qinling policy/instance); this
3// layer binds the-valley alone, and a project can only add to its own
4// layer (dcr-f41f718).
5package verification
6
7import (
8 "list"
9 "strings"
10)
11
12project: {
13 // the-valley takes no knowledge lint of its own tree. The docs
14 // template's lint checks a knowledge graph kept in the source, and
15 // the-valley's source holds none: its plan graph is project storage, at
16 // refs/the-valley/knots, and the push hook holds it to the knot
17 // module's rules. The nodes under archive/.the-valley/ are history that
18 // never changes, so linting them against today's schema protects
19 // nothing. The lint itself stays covered: the knowledge-lint class
20 // below requires its consumer and rejection checks.
21
22 // Every check below is the flake check of the same name in
23 // nix/checks.nix, built for the runner's own system. own-policy holds
24 // this list to that: a name here that the flake does not define fails
25 // it.
26 let ownChecks = [
27 "valleyhook-unit",
28 "protect-e2e",
29 "knots-e2e",
30 "note-unit",
31 "change-unit",
32 "knot-unit",
33 "knot-agree",
34 "delta-unit",
35 "attest-unit",
36 "attest-conformance",
37 "attest-e2e",
38 "identity-unit",
39 "identity-e2e",
40 "integrator-unit",
41 "integrator-e2e",
42 "sigverify-unit",
43 "sigverify-e2e",
44 "rebase-unit",
45 "valley-go-unit",
46 "valley-cli",
47 "review-notes",
48 "valley-request",
49 "valley-status",
50 "valley-ready",
51 "valley-changes",
52 "valley-knot",
53 "valley-plan",
54 "valley-darwin-eval",
55 "policy-deriver",
56 "own-policy",
57 "module-eval",
58 "cue-vet",
59 "attest-schema",
60 "identity-schema",
61 "knowledge-lint-consumer",
62 "knowledge-lint-rejects",
63 "init-e2e",
64 "mirror-e2e",
65 "bus-e2e",
66 "ssh-e2e",
67 "publish-e2e",
68 ]
69 for n in ownChecks {
70 checks: (n): {
71 runner: "nix"
72 attribute: n
73 }
74 }
75
76 // The integrator's scenarios take about a minute, and ssh-e2e and
77 // publish-e2e boot NixOS machines. Every other check here takes seconds
78 // once its packages are built.
79 checks: "integrator-e2e": cost: "slow"
80 checks: "ssh-e2e": cost: "slow"
81 checks: "publish-e2e": cost: "slow"
82
83 // Each class below is one part of the tree and the checks that read it.
84 // A path in two classes requires both sets. A Go module's unit check is its
85 // package, whose checkPhase runs `go test`.
86
87 // The pre-receive hook and the git user's login shell. protect-e2e
88 // pushes to bare repositories wired with the hook a host renders,
89 // valley-ready pushes change records through that hook, and knots-e2e
90 // pushes the plan graph through it.
91 classes: valleyhook: {
92 paths: "valleyhook/**": true
93 requires: "valleyhook-unit": true
94 requires: "protect-e2e": true
95 requires: "valley-ready": true
96 requires: "knots-e2e": true
97 }
98
99 // The change record, which the hook guards, the CLI's Go verbs and the
100 // rebase engine write, and the integrator reads. Each reads a record
101 // through it, so a change to it requires their tests as well as its own.
102 classes: change: {
103 paths: "change/**": true
104 requires: "change-unit": true
105 requires: "valleyhook-unit": true
106 requires: "protect-e2e": true
107 requires: "rebase-unit": true
108 requires: "valley-go-unit": true
109 requires: "valley-ready": true
110 requires: "valley-changes": true
111 requires: "integrator-unit": true
112 requires: "integrator-e2e": true
113 }
114
115 // The plan graph's module, which the CLI's Go verbs write the graph
116 // with and the hook validates it with. knot-agree holds its validator
117 // to the node schema and the knowledge lint, valley-knot and
118 // valley-plan drive the verbs that use it, and knots-e2e pushes
119 // through the hook.
120 classes: knot: {
121 paths: "knot/**": true
122 requires: "knot-unit": true
123 requires: "knot-agree": true
124 requires: "valley-go-unit": true
125 requires: "valley-knot": true
126 requires: "valley-plan": true
127 requires: "valleyhook-unit": true
128 requires: "knots-e2e": true
129 }
130
131 // valley-delta-v1, which the CLI's Go verbs compare a version with its
132 // approved version through. delta-unit holds it to its conformance
133 // vectors, valley-go-unit builds the verbs with it, and valley-ready and
134 // review-notes drive review over the comparison.
135 classes: delta: {
136 paths: "delta/**": true
137 requires: "delta-unit": true
138 requires: "valley-go-unit": true
139 requires: "valley-ready": true
140 requires: "review-notes": true
141 }
142
143 // The note envelope. The hook and attest both read notes through it, so
144 // a change to it requires their tests as well as its own.
145 classes: note: {
146 paths: "note/**": true
147 requires: "note-unit": true
148 requires: "valleyhook-unit": true
149 requires: "protect-e2e": true
150 requires: "attest-unit": true
151 requires: "attest-e2e": true
152 }
153
154 // The attestation helper, and the conformance vectors under
155 // attest/conformance/ that hold its written form fixed.
156 classes: attest: {
157 paths: "attest/**": true
158 requires: "attest-unit": true
159 requires: "attest-conformance": true
160 requires: "attest-e2e": true
161 }
162
163 // The identity registry compiler, and the registries it is driven over.
164 classes: identity: {
165 paths: "identity/**": true
166 paths: "examples/identity/**": true
167 requires: "identity-unit": true
168 requires: "identity-e2e": true
169 }
170
171 // The integrator, and the end-to-end scenarios under integrator/e2e/.
172 classes: integrator: {
173 paths: "integrator/**": true
174 requires: "integrator-unit": true
175 requires: "integrator-e2e": true
176 }
177
178 // The security-key signature verifier.
179 classes: sigverify: {
180 paths: "sigverify/**": true
181 requires: "sigverify-unit": true
182 requires: "sigverify-e2e": true
183 }
184
185 // The valley CLI: the script, its Go verbs (status/), the rebase engine
186 // they rebase and read landings with (rebase/), and its completions.
187 // valley-ready drives ready, withdraw, rebase and the verbs that take a
188 // change's handle, valley-changes drives changes and pending, and
189 // valley-plan drives plan against the golden files under
190 // status/testdata/plan/.
191 classes: cli: {
192 paths: "bin/valley": true
193 paths: "status/**": true
194 paths: "rebase/**": true
195 paths: "completions/**": true
196 requires: "valley-go-unit": true
197 requires: "valley-cli": true
198 requires: "review-notes": true
199 requires: "valley-request": true
200 requires: "valley-status": true
201 requires: "valley-ready": true
202 requires: "valley-changes": true
203 requires: "valley-knot": true
204 requires: "valley-plan": true
205 requires: "policy-deriver": true
206 }
207
208 // The rebase engine, with its own tests over real repositories. The
209 // verbs that run it are the cli class's, so its paths are there too.
210 classes: rebase: {
211 paths: "rebase/**": true
212 requires: "rebase-unit": true
213 }
214
215 // The verification policy: this layer, the pointer to the owning
216 // valley, the schema a policy is written in, and the example policies
217 // the deriver and cue-vet read.
218 classes: policy: {
219 paths: "policy/**": true
220 paths: "schema/verification.cue": true
221 paths: "examples/policy/**": true
222 requires: "policy-deriver": true
223 requires: "cue-vet": true
224 requires: "own-policy": true
225 }
226
227 // The flake, the NixOS module, the packages and the check definitions,
228 // and the host declarations the module checks are evaluated over.
229 // own-policy is here because renaming or removing a flake check would
230 // leave this layer naming a check that no longer exists. A change to
231 // flake.nix or flake.lock requires these alone, so a nixpkgs bump boots no
232 // machine.
233 classes: nix: {
234 paths: "nix/**": true
235 paths: "flake.nix": true
236 paths: "flake.lock": true
237 paths: "examples/host.cue": true
238 paths: "examples/hosts/**": true
239 requires: "module-eval": true
240 requires: "valley-darwin-eval": true
241 requires: "cue-vet": true
242 requires: "own-policy": true
243 }
244
245 // The schemas, and the example events, attestations and registries they
246 // are vetted against.
247 classes: schema: {
248 paths: "schema/**": true
249 paths: "examples/events/**": true
250 paths: "examples/attestations/**": true
251 paths: "examples/identity/**": true
252 requires: "cue-vet": true
253 requires: "attest-schema": true
254 requires: "identity-schema": true
255 }
256
257 // The knowledge lint itself: its program, the node schema it holds a
258 // graph to, and the example graphs it must accept and reject. The plan
259 // graph's validator is held to the same two by knot-agree.
260 classes: "knowledge-lint": {
261 paths: "nix/knowledge-lint.*": true
262 paths: "schema/node.cue": true
263 paths: "examples/graphs/**": true
264 requires: "knowledge-lint-consumer": true
265 requires: "knowledge-lint-rejects": true
266 requires: "knot-agree": true
267 }
268
269 // The NixOS module and what its end-to-end checks run. The hook checks
270 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
271 // are made of the three declarations named here; ssh-e2e and
272 // publish-e2e run the module in NixOS machines.
273 classes: "host-module": {
274 paths: "nix/valley-host.nix": true
275 paths: "nix/checks/hosts.nix": true
276 paths: "examples/hosts/protected.cue": true
277 paths: "examples/hosts/bus.cue": true
278 paths: "examples/hosts/mirrors.cue": true
279 requires: "init-e2e": true
280 requires: "mirror-e2e": true
281 requires: "bus-e2e": true
282 requires: "protect-e2e": true
283 requires: "knots-e2e": true
284 requires: "identity-e2e": true
285 requires: "ssh-e2e": true
286 requires: "publish-e2e": true
287 requires: "valley-changes": true
288 }
289
290 // A check's own files require that check: its script,
291 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
292 // where it has a file of its own. One class per check, named
293 // check-<name>. prose-format is the floor's check, but its script is
294 // here. own-policy fails if a script under nix/checks/ requires no
295 // check.
296 for n in list.Concat([ownChecks, ["prose-format"]]) {
297 classes: ("check-\(n)"): {
298 paths: ("nix/checks/\(n).sh"): true
299 paths: ("nix/checks/\(n).nix"): true
300 requires: (n): true
301 }
302 }
303
304 // The other files under nix/checks/, and the checks that read each: the
305 // definitions of a subject's checks, and the helpers and rejection lists
306 // a check is given. cli.nix, which defines every check of bin/valley,
307 // is left to the nix class, as is nix/checks.nix, which wires them all.
308 let checkFiles = {
309 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
310 "delta.nix": ["delta-unit"]
311 "identity.nix": ["identity-unit", "identity-e2e"]
312 "integrator.nix": ["integrator-unit", "integrator-e2e"]
313 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
314 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
315 "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
316 "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
317 "host-module.nix": ["module-eval"]
318 "fail-nth.sh": ["policy-deriver", "valley-request"]
319 "review-notes-editor.sh": ["review-notes"]
320 "cue-vet-rejected.txt": ["cue-vet"]
321 "identity-rejected.txt": ["identity-schema"]
322 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
323 }
324 for f, ns in checkFiles {
325 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
326 paths: ("nix/checks/\(f)"): true
327 requires: {for n in ns {(n): true}}
328 }
329 }
330}
331
332// What no class above covers falls to the floor's `unclassified` rule and
333// requires prose-format alone. That is the research artefacts under research/,
334// the GitHub mirror's workflow under .github/, and editor settings: files
335// no program here reads.