gunk-dev/the-valley

policy.cue

sourcec816f44c5851main's published tip history
17.8 KiB
1// the-valley's project layer: what this one project declares above the
2// floor. The floor is the owning valley's 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 "derive-unit",
36 "review-unit",
37 "attest-unit",
38 "attest-conformance",
39 "attest-e2e",
40 "identity-unit",
41 "identity-e2e",
42 "integrator-unit",
43 "integrator-e2e",
44 "restack-unit",
45 "restack-e2e",
46 "signers-e2e",
47 "sigverify-unit",
48 "sigverify-e2e",
49 "webui-unit",
50 "webui-server-unit",
51 "rebase-unit",
52 "valley-go-unit",
53 "valley-cli",
54 "review-notes",
55 "valley-request",
56 "valley-status",
57 "valley-ready",
58 "valley-changes",
59 "valley-knot",
60 "valley-plan",
61 "valley-darwin-eval",
62 "selfupdate-unit",
63 "valley-self-update",
64 "policy-deriver",
65 "own-policy",
66 "module-eval",
67 "cue-vet",
68 "attest-schema",
69 "identity-schema",
70 "knowledge-lint-consumer",
71 "knowledge-lint-rejects",
72 "init-e2e",
73 "mirror-e2e",
74 "bus-e2e",
75 "ssh-e2e",
76 "publish-e2e",
77 "worker-e2e",
78 ]
79 for n in ownChecks {
80 checks: (n): {
81 runner: "nix"
82 attribute: n
83 }
84 }
85
86 // The integrator's scenarios take about a minute, and ssh-e2e,
87 // publish-e2e and worker-e2e boot NixOS machines. Every other check here
88 // takes seconds once its packages are built.
89 checks: "integrator-e2e": cost: "slow"
90 checks: "ssh-e2e": cost: "slow"
91 checks: "publish-e2e": cost: "slow"
92 checks: "worker-e2e": cost: "slow"
93
94 // Each class below is one part of the tree and the checks that read it.
95 // A path in two classes requires both sets. A Go module's unit check is
96 // its package built again with its tests, which runs `go test`. The
97 // package itself runs no tests (nix/packages.nix).
98
99 // The pre-receive hook and the git user's login shell. protect-e2e
100 // pushes to bare repositories wired with the hook a host renders,
101 // valley-ready pushes change records through that hook, and knots-e2e
102 // pushes the plan graph through it.
103 classes: valleyhook: {
104 paths: "valleyhook/**": true
105 requires: "valleyhook-unit": true
106 requires: "protect-e2e": true
107 requires: "valley-ready": true
108 requires: "knots-e2e": true
109 }
110
111 // The change record, which the hook guards, the CLI's Go verbs and the
112 // rebase engine write, and the integrator and the review module read.
113 // Each reads a record through it, so a change to it requires their tests
114 // as well as its own.
115 classes: change: {
116 paths: "change/**": true
117 requires: "change-unit": true
118 requires: "review-unit": true
119 requires: "valleyhook-unit": true
120 requires: "protect-e2e": true
121 requires: "rebase-unit": true
122 requires: "valley-go-unit": true
123 requires: "valley-ready": true
124 requires: "valley-changes": true
125 requires: "integrator-unit": true
126 requires: "integrator-e2e": true
127 }
128
129 // The plan graph's module, which the CLI's Go verbs write the graph
130 // with and the hook validates it with. knot-agree holds its validator
131 // to the node schema and the knowledge lint, valley-knot and
132 // valley-plan drive the verbs that use it, and knots-e2e pushes
133 // through the hook. The web export reads names and knot IDs by its
134 // rules, and the web server reads a claim's age by them, so
135 // webui-unit and webui-server-unit are here too.
136 classes: knot: {
137 paths: "knot/**": true
138 requires: "knot-unit": true
139 requires: "knot-agree": true
140 requires: "valley-go-unit": true
141 requires: "valley-knot": true
142 requires: "valley-plan": true
143 requires: "valleyhook-unit": true
144 requires: "knots-e2e": true
145 requires: "webui-unit": true
146 requires: "webui-server-unit": true
147 }
148
149 // valley-delta-v1, which the CLI's Go verbs compare a version with its
150 // approved version through, and which the review module recomputes a
151 // review's binding with. delta-unit holds it to its conformance vectors,
152 // valley-go-unit builds the verbs with it, valley-ready and review-notes
153 // drive review over the comparison, and review-unit binds reviews with
154 // its bounded reading.
155 classes: delta: {
156 paths: "delta/**": true
157 requires: "delta-unit": true
158 requires: "valley-go-unit": true
159 requires: "valley-ready": true
160 requires: "review-notes": true
161 requires: "review-unit": true
162 }
163
164 // Review records: the record, its binding to the version it judged, and
165 // its append-only history. review-unit runs its tests against real git.
166 classes: review: {
167 paths: "review/**": true
168 requires: "review-unit": true
169 }
170
171 // The deriver of required checks, and the composed-policy reader it reads
172 // the whole policy through. derive-unit holds the deriver to bin/valley's,
173 // and valley-go-unit builds the verb that prints its answer with both.
174 classes: derive: {
175 paths: "derive/**": true
176 paths: "composed/**": true
177 requires: "derive-unit": true
178 requires: "valley-go-unit": true
179 }
180
181 // The note envelope. The hook and attest both read notes through it,
182 // the identity compiler reads its approval files back with it, and the
183 // web export's manifest is a note, which the web server builds with,
184 // so a change to it requires their tests as well as its own.
185 classes: note: {
186 paths: "note/**": true
187 requires: "note-unit": true
188 requires: "valleyhook-unit": true
189 requires: "protect-e2e": true
190 requires: "attest-unit": true
191 requires: "attest-e2e": true
192 requires: "identity-unit": true
193 requires: "webui-unit": true
194 requires: "webui-server-unit": true
195 }
196
197 // The attestation helper, and the conformance vectors under
198 // attest/conformance/ that hold its written form fixed.
199 classes: attest: {
200 paths: "attest/**": true
201 requires: "attest-unit": true
202 requires: "attest-conformance": true
203 requires: "attest-e2e": true
204 }
205
206 // The identity registry compiler, and the registries it is driven over.
207 classes: identity: {
208 paths: "identity/**": true
209 paths: "examples/identity/**": true
210 requires: "identity-unit": true
211 requires: "identity-e2e": true
212 }
213
214 // The integrator, the end-to-end scenarios under integrator/e2e/, and the
215 // verification schema, which the integrator composes every policy under
216 // and both checks read.
217 classes: integrator: {
218 paths: "integrator/**": true
219 paths: "composed/**": true
220 paths: "schema/verification.cue": true
221 requires: "integrator-unit": true
222 requires: "integrator-e2e": true
223 }
224
225 // The security-key signature verifier.
226 classes: sigverify: {
227 paths: "sigverify/**": true
228 requires: "sigverify-unit": true
229 requires: "sigverify-e2e": true
230 }
231
232 // The web UI's module: the export contract, its shared fixture, the
233 // server and valley-web. The server builds on the contract, so every
234 // change to the module requires both checks.
235 classes: webui: {
236 paths: "webui/**": true
237 requires: "webui-unit": true
238 requires: "webui-server-unit": true
239 }
240
241 // The valley CLI: the script, its Go verbs (status/), the rebase engine
242 // they rebase and read landings with (rebase/), and its completions.
243 // valley-ready drives ready, withdraw, rebase and the verbs that take a
244 // change's handle, valley-changes drives changes and pending,
245 // valley-plan drives plan against the golden files under
246 // status/testdata/plan/, and valley-self-update drives --version and
247 // self-update. derive-unit holds the script's deriver to the Go one.
248 classes: cli: {
249 paths: "bin/valley": true
250 paths: "status/**": true
251 paths: "rebase/**": true
252 paths: "completions/**": true
253 requires: "valley-go-unit": true
254 requires: "valley-cli": true
255 requires: "review-notes": true
256 requires: "valley-request": true
257 requires: "valley-status": true
258 requires: "valley-ready": true
259 requires: "valley-changes": true
260 requires: "valley-knot": true
261 requires: "valley-plan": true
262 requires: "valley-self-update": true
263 requires: "policy-deriver": true
264 requires: "derive-unit": true
265 }
266
267 // Self-update: its module (selfupdate/), the policy the package ships
268 // for its smoke test, and the home-manager module that runs it on a
269 // timer. valley-go-unit builds the verb with the module, and
270 // valley-self-update drives the verb through the package and holds the
271 // units the home-manager module renders.
272 classes: selfupdate: {
273 paths: "selfupdate/**": true
274 paths: "examples/policy/smoke/**": true
275 paths: "nix/home-module.nix": true
276 requires: "selfupdate-unit": true
277 requires: "valley-go-unit": true
278 requires: "valley-self-update": true
279 }
280
281 // The rebase engine, with its own tests over real repositories. The
282 // verbs that run it are the cli class's, so its paths are there too.
283 classes: rebase: {
284 paths: "rebase/**": true
285 requires: "rebase-unit": true
286 }
287
288 // The restacker, with its unit tests and its planner end to end. It
289 // reads origin through the rebase engine and the policy through the
290 // composed-policy reader it shares with the integrator, so a change to
291 // either requires its checks too.
292 classes: restack: {
293 paths: "restack/**": true
294 paths: "composed/**": true
295 paths: "rebase/**": true
296 requires: "restack-unit": true
297 requires: "restack-e2e": true
298 }
299
300 // What a client verifies an integrator's transfer statement with: the
301 // host's publisher and the default name it publishes, the unit that
302 // runs it, the client's reading of the signers, the instance discovery
303 // it reads them through, and the snapshot that asks for them.
304 // signers-e2e drives them together over the real integrator.
305 classes: signers: {
306 paths: "integrator/signers.go": true
307 paths: "integrator/main.go": true
308 paths: "nix/valley-host.nix": true
309 paths: "status/signers.go": true
310 paths: "status/list.go": true
311 paths: "rebase/snapshot.go": true
312 requires: "signers-e2e": true
313 }
314
315 // The verification policy: this layer, the pointer to the owning
316 // valley, the schema a policy is written in, and the example policies
317 // the derivers and cue-vet read.
318 classes: policy: {
319 paths: "policy/**": true
320 paths: "schema/verification.cue": true
321 paths: "examples/policy/**": true
322 requires: "policy-deriver": true
323 requires: "derive-unit": true
324 requires: "cue-vet": true
325 requires: "own-policy": true
326 }
327
328 // The flake, the NixOS module, the packages and the check definitions,
329 // and the host declarations the module checks are evaluated over.
330 // own-policy is here because renaming or removing a flake check would
331 // leave this layer naming a check that no longer exists. A change to
332 // flake.nix or flake.lock requires these alone, so a nixpkgs bump boots no
333 // machine.
334 classes: nix: {
335 paths: "nix/**": true
336 paths: "flake.nix": true
337 paths: "flake.lock": true
338 paths: "examples/host.cue": true
339 paths: "examples/hosts/**": true
340 requires: "module-eval": true
341 requires: "valley-darwin-eval": true
342 requires: "cue-vet": true
343 requires: "own-policy": true
344 }
345
346 // The schemas, and the example events, attestations and registries they
347 // are vetted against.
348 classes: schema: {
349 paths: "schema/**": true
350 paths: "examples/events/**": true
351 paths: "examples/attestations/**": true
352 paths: "examples/identity/**": true
353 requires: "cue-vet": true
354 requires: "attest-schema": true
355 requires: "identity-schema": true
356 }
357
358 // The knowledge lint itself: its program, the node schema it holds a
359 // graph to, and the example graphs it must accept and reject. The plan
360 // graph's validator is held to the same two by knot-agree.
361 classes: "knowledge-lint": {
362 paths: "nix/knowledge-lint.*": true
363 paths: "schema/node.cue": true
364 paths: "examples/graphs/**": true
365 requires: "knowledge-lint-consumer": true
366 requires: "knowledge-lint-rejects": true
367 requires: "knot-agree": true
368 }
369
370 // The NixOS module and what its end-to-end checks run. The hook checks
371 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
372 // are made of the three declarations named here; ssh-e2e, publish-e2e
373 // and worker-e2e run the module in NixOS machines.
374 classes: "host-module": {
375 paths: "nix/valley-host.nix": true
376 paths: "nix/checks/hosts.nix": true
377 paths: "examples/hosts/protected.cue": true
378 paths: "examples/hosts/bus.cue": true
379 paths: "examples/hosts/mirrors.cue": true
380 requires: "init-e2e": true
381 requires: "mirror-e2e": true
382 requires: "bus-e2e": true
383 requires: "protect-e2e": true
384 requires: "knots-e2e": true
385 requires: "identity-e2e": true
386 requires: "ssh-e2e": true
387 requires: "publish-e2e": true
388 requires: "worker-e2e": true
389 requires: "valley-changes": true
390 }
391
392 // A check's own files require that check: its script,
393 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
394 // where it has a file of its own. One class per check, named
395 // check-<name>. prose-format is the floor's check, but its script is
396 // here. own-policy fails if a script under nix/checks/ requires no
397 // check.
398 for n in list.Concat([ownChecks, ["prose-format"]]) {
399 classes: ("check-\(n)"): {
400 paths: ("nix/checks/\(n).sh"): true
401 paths: ("nix/checks/\(n).nix"): true
402 requires: (n): true
403 }
404 }
405
406 // The other files under nix/checks/, and the checks that read each: the
407 // definitions of a subject's checks, and the helpers and rejection lists
408 // a check is given. cli.nix, which defines every check of bin/valley,
409 // is left to the nix class, as is nix/checks.nix, which wires them all.
410 let checkFiles = {
411 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
412 "delta.nix": ["delta-unit"]
413 "derive.nix": ["derive-unit"]
414 "review.nix": ["review-unit"]
415 "identity.nix": ["identity-unit", "identity-e2e"]
416 "integrator.nix": ["integrator-unit", "integrator-e2e"]
417 "signers.nix": ["signers-e2e"]
418 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
419 "webui.nix": ["webui-unit", "webui-server-unit"]
420 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
421 "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
422 "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
423 "host-module.nix": ["module-eval"]
424 "fail-nth.sh": ["policy-deriver", "valley-request"]
425 "review-notes-editor.sh": ["review-notes"]
426 "cue-vet-rejected.txt": ["cue-vet"]
427 "identity-rejected.txt": ["identity-schema"]
428 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
429 }
430 for f, ns in checkFiles {
431 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
432 paths: ("nix/checks/\(f)"): true
433 requires: {for n in ns {(n): true}}
434 }
435 }
436
437 // How far an approval carries across a rebase (#Carry in
438 // schema/verification.cue). Every path not named here is same-paths.
439 //
440 // The hook, the integrator, the signature verifier and the identity
441 // compiler enforce who may do what. An approval of a change to one of
442 // them carries only while no landing has touched the same classes:
443 // same-class. The identity compiler's class is its code and the schema
444 // it holds a registry to. It requires nothing, because the identity and
445 // schema classes already require the checks of its paths.
446 classes: valleyhook: carry: "same-class": true
447 classes: integrator: carry: "same-class": true
448 classes: sigverify: carry: "same-class": true
449 classes: "identity-compiler": {
450 paths: "identity/**": true
451 paths: "schema/identity.cue": true
452 carry: "same-class": true
453 }
454
455 // The policy decides what every change requires, so an approval of a
456 // change to it carries across no landing at all: exact. That is this
457 // layer, the pointer to the owning valley, and the schema a policy is
458 // written in. The example policies are fixtures and stay same-paths. Like
459 // identity-compiler, this class requires nothing: the policy class
460 // requires the checks of its paths.
461 //
462 // This tree holds no registry, grant or secret data of its own. The
463 // registries, grants and keys under examples/ and attest/conformance/
464 // are test fixtures, and the instance's registry is in its instance
465 // repository. So nothing else here is exact.
466 classes: "policy-authority": {
467 paths: "policy/**": true
468 paths: "schema/verification.cue": true
469 carry: exact: true
470 }
471
472 // The restacker's cap is the schema's default of 64 automatic versions
473 // per change.
474}
475
476// What no class above covers falls to the floor's `unclassified` rule and
477// requires prose-format alone. That is the research artefacts under research/,
478// the GitHub mirror's workflow under .github/, and editor settings: files
479// no program here reads.