gunk-dev/the-valley

policy.cue

source88a5a486b52fmain's published tip history
33.7 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 "exactjson-unit",
32 "pushpolicy-unit",
33 "change-unit",
34 "knot-unit",
35 "knot-agree",
36 "delta-unit",
37 "derive-unit",
38 "composed-unit",
39 "review-unit",
40 "attest-unit",
41 "attest-conformance",
42 "attest-e2e",
43 "identity-unit",
44 "identity-e2e",
45 "approval-unit",
46 "integrator-unit",
47 "integrator-e2e",
48 "restack-unit",
49 "restack-e2e",
50 "signers-e2e",
51 "sigverify-unit",
52 "sigverify-e2e",
53 "web-unit",
54 "web-server-unit",
55 "web-reader-state-crash",
56 "web-reader-browser-e2e",
57 "web-receiver-unit",
58 "readaccess-unit",
59 "rebase-unit",
60 "valley-go-unit",
61 "valley-cli",
62 "review-notes",
63 "valley-request",
64 "valley-status",
65 "valley-ready",
66 "valley-changes",
67 "valley-walk",
68 "valley-knot",
69 "valley-plan",
70 "valley-darwin-eval",
71 "selfupdate-unit",
72 "valley-self-update",
73 "policy-deriver",
74 "own-policy",
75 "go-dependencies",
76 "module-eval",
77 "cue-vet",
78 "attest-schema",
79 "identity-schema",
80 "knowledge-lint-consumer",
81 "knowledge-lint-rejects",
82 "init-e2e",
83 "mirror-e2e",
84 "bus-e2e",
85 "ssh-e2e",
86 "publish-e2e",
87 "worker-e2e",
88 "telemetry-unit",
89 "telemetry-e2e",
90 "restack-host-e2e",
91 "web-publisher-e2e",
92 "web-image",
93 "web-push-e2e",
94 "flow-build",
95 "flow-unit",
96 "flow-vet",
97 "flow-e2e",
98 "flow-policy",
99 ]
100 for n in ownChecks {
101 checks: (n): {
102 runner: "nix"
103 attribute: n
104 }
105 }
106
107 // The integrator's scenarios take about a minute, and ssh-e2e,
108 // publish-e2e, worker-e2e, telemetry-e2e, restack-host-e2e and
109 // web-publisher-e2e boot
110 // NixOS machines. web-reader-browser-e2e boots no machine, but its
111 // closure holds Chromium, and it runs a browser in about 2 GiB.
112 // flow-e2e runs over a hundred scenarios, each on its own tmux server,
113 // in about a minute.
114 // Every other check here takes seconds once its packages are built.
115 checks: "integrator-e2e": cost: "slow"
116 checks: "ssh-e2e": cost: "slow"
117 checks: "publish-e2e": cost: "slow"
118 checks: "worker-e2e": cost: "slow"
119 checks: "telemetry-e2e": cost: "slow"
120 checks: "restack-host-e2e": cost: "slow"
121 checks: "web-publisher-e2e": cost: "slow"
122 checks: "web-reader-browser-e2e": cost: "slow"
123 checks: "flow-e2e": cost: "slow"
124
125 // Each class below is one part of the tree and the checks that read it.
126 // A path in two classes requires both sets. A Go module's unit check is
127 // its package built again with its tests, which runs `go test`. The
128 // package itself runs no tests (nix/packages.nix).
129
130 // The pre-receive hook and the git user's login shell, and the push
131 // policy reader the hook decides every push with (pushpolicy/), which
132 // is the hook's code wherever it lives. protect-e2e pushes to bare
133 // repositories wired with the hook a host renders, valley-ready pushes
134 // change records through that hook, and knots-e2e pushes the plan graph
135 // through it.
136 classes: valleyhook: {
137 paths: "valleyhook/**": true
138 paths: "pushpolicy/**": true
139 requires: "valleyhook-unit": true
140 requires: "pushpolicy-unit": true
141 requires: "protect-e2e": true
142 requires: "valley-ready": true
143 requires: "knots-e2e": true
144 }
145
146 // The change record, which the hook guards, the CLI's Go verbs and the
147 // rebase engine write, and the integrator and the review module read.
148 // Each reads a record through it, so a change to it requires their tests
149 // as well as its own.
150 classes: change: {
151 paths: "change/**": true
152 requires: "change-unit": true
153 requires: "review-unit": true
154 requires: "valleyhook-unit": true
155 requires: "protect-e2e": true
156 requires: "rebase-unit": true
157 requires: "valley-go-unit": true
158 requires: "valley-ready": true
159 requires: "valley-changes": true
160 requires: "integrator-unit": true
161 requires: "integrator-e2e": true
162 requires: "approval-unit": true
163 }
164
165 // The plan graph's module, which the CLI's Go verbs write the graph
166 // with and the hook validates it with. knot-agree holds its validator
167 // to the node schema and the knowledge lint, valley-knot and
168 // valley-plan drive the verbs that use it, and knots-e2e pushes
169 // through the hook. The web export reads names and knot IDs by its
170 // rules, and the web server reads a claim's age by them, so
171 // web-unit and web-server-unit are here too.
172 classes: knot: {
173 paths: "knot/**": true
174 requires: "knot-unit": true
175 requires: "knot-agree": true
176 requires: "valley-go-unit": true
177 requires: "valley-knot": true
178 requires: "valley-plan": true
179 requires: "valleyhook-unit": true
180 requires: "knots-e2e": true
181 requires: "web-unit": true
182 requires: "web-server-unit": true
183 }
184
185 // valley-delta-v1, which the CLI's Go verbs compare a version with its
186 // approved version through, and which the review module recomputes a
187 // review's binding with. delta-unit holds it to its conformance vectors,
188 // valley-go-unit builds the verbs with it, valley-ready and review-notes
189 // drive review over the comparison, and review-unit binds reviews with
190 // its bounded reading.
191 classes: delta: {
192 paths: "delta/**": true
193 requires: "delta-unit": true
194 requires: "valley-go-unit": true
195 requires: "valley-ready": true
196 requires: "review-notes": true
197 requires: "review-unit": true
198 }
199
200 // Review records: the record, its binding to the version it judged, and
201 // its append-only history. review-unit runs its tests against real git.
202 classes: review: {
203 paths: "review/**": true
204 requires: "review-unit": true
205 }
206
207 // The deriver of required checks, and the composed-policy reader it reads
208 // the whole policy through. derive-unit holds the deriver's answers,
209 // composed-unit holds the reader's layer reads, and valley-go-unit builds
210 // the verb that prints its answer with both.
211 classes: derive: {
212 paths: "derive/**": true
213 paths: "composed/**": true
214 requires: "derive-unit": true
215 requires: "composed-unit": true
216 requires: "valley-go-unit": true
217 }
218
219 // The note envelope, and the written form and tree digest of the
220 // statement inside it (note/statement/), which the attest class covers
221 // too. The hook and attest both read notes through it, the identity
222 // compiler reads its approval files back with it, the web export's
223 // manifest is a note, which the web server builds with, the vectors
224 // attest-conformance holds are signed notes, and the rebase engine
225 // verifies transfer statements with all of it, as signers-e2e drives
226 // end to end. So a change to it requires their tests as well as its
227 // own.
228 classes: note: {
229 paths: "note/**": true
230 requires: "note-unit": true
231 requires: "valleyhook-unit": true
232 requires: "protect-e2e": true
233 requires: "attest-unit": true
234 requires: "attest-conformance": true
235 requires: "attest-e2e": true
236 requires: "identity-unit": true
237 requires: "approval-unit": true
238 requires: "web-unit": true
239 requires: "web-server-unit": true
240 requires: "rebase-unit": true
241 requires: "signers-e2e": true
242 }
243
244 // The attestation helper, the written form and tree digest it writes
245 // and verifies statements with (note/statement/), and the conformance
246 // vectors under attest/conformance/ that hold the written form fixed.
247 // restack-e2e signs the changes' evidence with attest run.
248 classes: attest: {
249 paths: "attest/**": true
250 paths: "note/statement/**": true
251 requires: "attest-unit": true
252 requires: "attest-conformance": true
253 requires: "attest-e2e": true
254 requires: "restack-e2e": true
255 }
256
257 // The strict JSON reader. The push policy reader reads with it, the
258 // identity compiler its registry, read access a policy/read, and the
259 // web export, publisher, server and receiver what they are sent, so a
260 // change to it requires their unit tests as well as its own.
261 classes: exactjson: {
262 paths: "exactjson/**": true
263 requires: "exactjson-unit": true
264 requires: "pushpolicy-unit": true
265 requires: "valleyhook-unit": true
266 requires: "identity-unit": true
267 requires: "readaccess-unit": true
268 requires: "web-unit": true
269 requires: "web-server-unit": true
270 requires: "web-receiver-unit": true
271 }
272
273 // Approval statements, their signing and verifying, the PIV session
274 // signer, and the authority stamp, which the identity compiler writes
275 // and the signers publisher leaves out.
276 classes: approval: {
277 paths: "approval/**": true
278 requires: "approval-unit": true
279 requires: "identity-unit": true
280 requires: "integrator-unit": true
281 }
282
283 // The identity registry compiler, and the registries it is driven over.
284 classes: identity: {
285 paths: "identity/**": true
286 paths: "examples/identity/**": true
287 requires: "identity-unit": true
288 requires: "identity-e2e": true
289 }
290
291 // Telemetry: the records, streams and command grammar of telemetry/, the
292 // collector built from it, and the host module's half in
293 // nix/telemetry.nix. The git user's shell parses the command with it,
294 // attest, the worker and the integrator write its streams, and the CLI
295 // reads and reports with it, so a change to it requires their unit
296 // tests as well as its own. telemetry-e2e drives all of it on a NixOS
297 // machine; it follows main after a landing, as slow end-to-end checks
298 // do, and gates nothing. module-eval evaluates the module in nix/telemetry.nix, so the
299 // module-eval class requires it for that file. It runs none of the
300 // collector's code, so a change under telemetry/ does not require it.
301 classes: telemetry: {
302 paths: "telemetry/**": true
303 paths: "nix/telemetry.nix": true
304 requires: "telemetry-unit": true
305 follows: "telemetry-e2e": true
306 requires: "valleyhook-unit": true
307 requires: "attest-unit": true
308 requires: "valley-go-unit": true
309 requires: "integrator-unit": true
310 }
311
312 // The producers and the CLI that record and send telemetry: attest's
313 // progress, the worker's and the workstation's records, and approve,
314 // which runs them. telemetry-e2e observes each over ssh, and follows main
315 // after a landing.
316 classes: "telemetry-producers": {
317 paths: "attest/progress.go": true
318 paths: "status/telemetry.go": true
319 paths: "status/workertelemetry.go": true
320 paths: "status/command.go": true
321 follows: "telemetry-e2e": true
322 }
323
324 // The check worker's own code: its pass and its records in status/, the
325 // wake directory it claims, and attest's run, which runs each check a
326 // pass builds, signs and stores the evidence, and reports its progress.
327 // worker-e2e runs those passes on a NixOS machine; it follows main after
328 // a landing, as slow end-to-end checks do, and gates nothing. The rest of status/
329 // and attest/ serves other commands too, and their classes require
330 // their own checks.
331 classes: worker: {
332 paths: "status/worker.go": true
333 paths: "status/workertelemetry.go": true
334 paths: "status/wake.go": true
335 paths: "attest/run.go": true
336 paths: "attest/check.go": true
337 paths: "attest/progress.go": true
338 follows: "worker-e2e": true
339 }
340
341 // The integrator, the end-to-end scenarios under integrator/e2e/, and the
342 // verification schema, which the integrator composes every policy under
343 // and both checks read. restack-e2e runs the real integrator too: it
344 // lands one change and rejects another.
345 classes: integrator: {
346 paths: "integrator/**": true
347 paths: "composed/**": true
348 paths: "schema/verification.cue": true
349 requires: "integrator-unit": true
350 requires: "integrator-e2e": true
351 requires: "restack-e2e": true
352 }
353
354 // The security-key signature verifier.
355 classes: sigverify: {
356 paths: "sigverify/**": true
357 requires: "sigverify-unit": true
358 requires: "sigverify-e2e": true
359 }
360
361 // The web UI's module: the export contract, its shared fixture, the
362 // publisher, the server and its browser state, and the receiver. The
363 // publisher's tests also read each project's policy/read and the
364 // instance's registry under the read and identity schemas.
365 // web-push-e2e runs the three programs as they ship, and
366 // web-reader-state-crash kills valley-web inside its browser state's
367 // transactions. Changes require all five checks.
368 classes: web: {
369 paths: "web/**": true
370 paths: "schema/read.cue": true
371 paths: "schema/identity.cue": true
372 requires: "web-unit": true
373 requires: "web-server-unit": true
374 requires: "web-reader-state-crash": true
375 requires: "web-receiver-unit": true
376 requires: "web-push-e2e": true
377 }
378
379 // What a browser engine runs or is served by on a reader page:
380 // web-reader-browser-e2e runs the packaged valley-web under headless
381 // Chromium. So it is required for the reader script and pages, the
382 // layout and the stylesheet whose hash every policy carries, the
383 // rendering and its policies, the dispatch and headers in server.go,
384 // the reader handlers, the command that sets up the browser state, the
385 // check's own test, and the packaging that builds the binary and its
386 // assets. Its definition is its own class's, check-<name> below. The
387 // publisher, package export, archives and the projection of the graph
388 // are not here: a change to them alone needs no browser.
389 classes: "reader-browser": {
390 paths: "web/server/assets/reader.js": true
391 paths: "web/server/assets/style.css": true
392 paths: "web/server/templates/redeem.tmpl": true
393 paths: "web/server/templates/logout.tmpl": true
394 paths: "web/server/templates/layout.tmpl": true
395 paths: "web/server/render.go": true
396 paths: "web/server/server.go": true
397 paths: "web/server/reader.go": true
398 paths: "web/cmd/valley-web/main.go": true
399 paths: "web/cmd/valley-web/browser_test.go": true
400 paths: "nix/packages.nix": true
401 requires: "web-reader-browser-e2e": true
402 }
403
404 // The real publisher's output that web-server-unit serves:
405 // nix/checks/web-published.sh runs the publisher and the CLI as they
406 // ship, and the server's tests read what it writes.
407 classes: "web-published": {
408 paths: "nix/checks/web-published.sh": true
409 requires: "web-server-unit": true
410 }
411
412 // Read access: the two consents a reader needs, the evaluator that
413 // intersects them, and the coverage report. readaccess-unit reads both
414 // schemas, so a change to either requires it, and the web publisher
415 // reads its consents through the module, so web-unit runs too.
416 classes: readaccess: {
417 paths: "readaccess/**": true
418 paths: "schema/read.cue": true
419 paths: "schema/identity.cue": true
420 requires: "readaccess-unit": true
421 requires: "web-unit": true
422 }
423
424 // The valley CLI: the valley command (status/), the rebase engine it
425 // rebases and reads landings with (rebase/), and its completions.
426 // valley-ready drives ready, withdraw, rebase and the verbs that take a
427 // change's handle, valley-changes drives changes and pending,
428 // valley-walk drives review with no change across a host's projects,
429 // valley-plan drives plan against the golden files under
430 // status/testdata/plan/, and valley-self-update drives --version and
431 // self-update. The web publisher reads the valley through plan, pending and knot
432 // show, and its tests in web-unit run the CLI itself, as web-push-e2e
433 // runs the CLI's package.
434 classes: cli: {
435 paths: "status/**": true
436 paths: "rebase/**": true
437 paths: "completions/**": true
438 requires: "valley-go-unit": true
439 requires: "valley-cli": true
440 requires: "review-notes": true
441 requires: "valley-request": true
442 requires: "valley-status": true
443 requires: "valley-ready": true
444 requires: "valley-changes": true
445 requires: "valley-walk": true
446 requires: "valley-knot": true
447 requires: "valley-plan": true
448 requires: "valley-self-update": true
449 requires: "policy-deriver": true
450 requires: "web-unit": true
451 requires: "web-push-e2e": true
452 requires: "integrator-e2e": true
453 }
454
455 // The push path as it ships: web-push-e2e runs the publisher, the
456 // receiver, valley-web and the CLI as nix/packages.nix builds and wraps
457 // them, and exports its host declaration under schema/valley.cue. The
458 // web and cli classes require it for the code it runs.
459 classes: "web-push": {
460 paths: "nix/packages.nix": true
461 paths: "schema/valley.cue": true
462 requires: "web-push-e2e": true
463 }
464
465 // Self-update: its module (selfupdate/), the policy the package ships
466 // for its smoke test, and the home-manager module that runs it on a
467 // timer. valley-go-unit builds the verb with the module, and
468 // valley-self-update drives the verb through the package and holds the
469 // units the home-manager module renders.
470 classes: selfupdate: {
471 paths: "selfupdate/**": true
472 paths: "examples/policy/smoke/**": true
473 paths: "nix/home-module.nix": true
474 requires: "selfupdate-unit": true
475 requires: "valley-go-unit": true
476 requires: "valley-self-update": true
477 }
478
479 // The rebase engine, with its own tests over real repositories. The
480 // verbs that run it are the cli class's, so its paths are there too.
481 classes: rebase: {
482 paths: "rebase/**": true
483 requires: "rebase-unit": true
484 }
485
486 // The restacker, with its unit tests and its planner end to end. It
487 // reads origin through the rebase engine and the policy through the
488 // composed-policy reader it shares with the integrator, so a change to
489 // either requires its checks too.
490 classes: restack: {
491 paths: "restack/**": true
492 paths: "composed/**": true
493 paths: "rebase/**": true
494 requires: "restack-unit": true
495 requires: "restack-e2e": true
496 }
497
498 // What a client verifies an integrator's transfer statement with: the
499 // host's publisher and the default name it publishes, the unit that
500 // runs it, the client's reading of the signers, the instance discovery
501 // it reads them through, the snapshot that asks for them, and the
502 // verifier and cache it checks statements with.
503 // signers-e2e drives them together over the real integrator.
504 classes: signers: {
505 paths: "integrator/signers.go": true
506 paths: "integrator/main.go": true
507 paths: "nix/valley-host.nix": true
508 paths: "status/signers.go": true
509 paths: "status/list.go": true
510 paths: "rebase/snapshot.go": true
511 paths: "rebase/transfer.go": true
512 paths: "rebase/cache.go": true
513 requires: "signers-e2e": true
514 }
515
516 // The web publisher's module, which runs the publisher on a timer in a
517 // sandbox of its own. web-publisher-e2e runs the unit it renders in a
518 // NixOS machine. module-eval, in the module-eval class, holds what it
519 // renders.
520 classes: "web-publisher": {
521 paths: "nix/web-publisher.nix": true
522 requires: "web-publisher-e2e": true
523 }
524
525 // The verification policy: this layer, the pointer to the owning
526 // valley, the schema a policy is written in, and the example policies
527 // the deriver and cue-vet read.
528 classes: policy: {
529 paths: "policy/**": true
530 paths: "schema/verification.cue": true
531 paths: "examples/policy/**": true
532 requires: "policy-deriver": true
533 requires: "derive-unit": true
534 requires: "cue-vet": true
535 requires: "own-policy": true
536 }
537
538 // What module-eval evaluates: the NixOS modules, the host declarations
539 // it renders and the files they are exported from, and the wiring that
540 // hands them to the check. Nothing else changes its derivation. An edit
541 // to another check's script or definition, to the packages, or to a
542 // program's code leaves it unchanged, so those paths are not here. That
543 // holds for nix/checks/ in general: each file there is its own check's,
544 // by the per-check classes below, and module-eval's own files are
545 // nix/checks/module-eval.sh, nix/checks/host-module.nix and
546 // nix/checks/hosts.nix.
547 classes: "module-eval": {
548 paths: "nix/valley-host.nix": true
549 paths: "nix/telemetry.nix": true
550 paths: "nix/web-publisher.nix": true
551 paths: "nix/web-receiver.nix": true
552 paths: "nix/checks.nix": true
553 paths: "nix/checks/hosts.nix": true
554 paths: "nix/checks/host-module.nix": true
555 paths: "schema/valley.cue": true
556 paths: "flake.nix": true
557 paths: "flake.lock": true
558 paths: "examples/host.cue": true
559 paths: "examples/hosts/protected.cue": true
560 paths: "examples/hosts/no-backup.cue": true
561 paths: "examples/hosts/bus.cue": true
562 paths: "examples/hosts/mirrors.cue": true
563 requires: "module-eval": true
564 }
565
566 // The flake, the NixOS module, the packages and the check definitions,
567 // and the host declarations the module checks are evaluated over.
568 // own-policy is here because renaming or removing a flake check would
569 // leave this layer naming a check that no longer exists. A change to
570 // flake.nix or flake.lock requires these and module-eval, which boots
571 // no machine, so a nixpkgs bump boots none.
572 classes: nix: {
573 paths: "nix/**": true
574 paths: "flake.nix": true
575 paths: "flake.lock": true
576 paths: "examples/host.cue": true
577 paths: "examples/hosts/**": true
578 requires: "valley-darwin-eval": true
579 requires: "cue-vet": true
580 requires: "own-policy": true
581 }
582
583 // The schemas, and the example events, attestations and registries they
584 // are vetted against.
585 classes: schema: {
586 paths: "schema/**": true
587 paths: "examples/events/**": true
588 paths: "examples/attestations/**": true
589 paths: "examples/identity/**": true
590 requires: "cue-vet": true
591 requires: "attest-schema": true
592 requires: "identity-schema": true
593 }
594
595 // The knowledge lint itself: its program, the node schema it holds a
596 // graph to, and the example graphs it must accept and reject. The plan
597 // graph's validator is held to the same two by knot-agree.
598 classes: "knowledge-lint": {
599 paths: "nix/knowledge-lint.*": true
600 paths: "schema/node.cue": true
601 paths: "examples/graphs/**": true
602 requires: "knowledge-lint-consumer": true
603 requires: "knowledge-lint-rejects": true
604 requires: "knot-agree": true
605 }
606
607 // The NixOS module and what its end-to-end checks run. The hook checks
608 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
609 // are made of the three declarations named here; ssh-e2e, publish-e2e,
610 // worker-e2e and restack-host-e2e run the module in NixOS machines.
611 // worker-e2e follows main after a landing and gates nothing.
612 classes: "host-module": {
613 paths: "nix/valley-host.nix": true
614 paths: "nix/checks/hosts.nix": true
615 paths: "examples/hosts/protected.cue": true
616 paths: "examples/hosts/bus.cue": true
617 paths: "examples/hosts/mirrors.cue": true
618 requires: "init-e2e": true
619 requires: "mirror-e2e": true
620 requires: "bus-e2e": true
621 requires: "protect-e2e": true
622 requires: "knots-e2e": true
623 requires: "identity-e2e": true
624 requires: "ssh-e2e": true
625 requires: "publish-e2e": true
626 follows: "worker-e2e": true
627 requires: "restack-host-e2e": true
628 requires: "valley-changes": true
629 requires: "valley-walk": true
630 }
631
632 // The Go dependency boundary (AGENTS.md): Go source, module and
633 // workspace manifests, vendor directories and anything named vendor,
634 // which Go vendors from even as a symlink, and the checker's own
635 // module, which its check-go-dependencies class below covers only as a
636 // script and a definition.
637 classes: "go-dependencies": {
638 paths: "**/*.go": true
639 paths: "**/go.mod": true
640 paths: "**/go.sum": true
641 paths: "**/go.work": true
642 paths: "**/go.work.sum": true
643 paths: "**/vendor": true
644 paths: "**/vendor/**": true
645 paths: "nix/checks/go-dependencies-checker/**": true
646 requires: "go-dependencies": true
647 }
648
649 // A check's own files require that check: its script,
650 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
651 // where it has a file of its own. One class per check, named
652 // check-<name>. prose-format is the floor's check, but its script is
653 // here. own-policy fails if a script under nix/checks/ requires no
654 // check. A class can only require here, so a change to the script or
655 // definition of worker-e2e or telemetry-e2e still builds it before
656 // landing, though a change to the subject it tests only follows.
657 // klaus (flow/), the one module that imports third-party modules. Its
658 // four checks build it as it ships, run its unit tests, go vet, and its
659 // end-to-end suite, over the module's Go source, go.mod, go.sum and test
660 // fixtures; its prose is read by none of them. A new kind of file under
661 // flow/ that the checks read takes a path here.
662 classes: flow: {
663 paths: "flow/**/*.go": true
664 paths: "flow/go.mod": true
665 paths: "flow/go.sum": true
666 paths: "flow/**/testdata/**": true
667 requires: "flow-build": true
668 requires: "flow-unit": true
669 requires: "flow-vet": true
670 requires: "flow-e2e": true
671 }
672
673 // What klaus's package and checks are built from besides flow/: the
674 // package definition, the check index, the flake and its nixpkgs pin.
675 // flow-policy reads them too, through its definition, its program's
676 // build and the valley command it runs.
677 classes: "flow-packaging": {
678 paths: "nix/packages.nix": true
679 paths: "nix/checks.nix": true
680 paths: "flake.nix": true
681 paths: "flake.lock": true
682 requires: "flow-build": true
683 requires: "flow-unit": true
684 requires: "flow-vet": true
685 requires: "flow-e2e": true
686 requires: "flow-policy": true
687 }
688
689 // The flow checks' helper: flow-build builds it with its tests and
690 // checks the version with it, and flow-unit and flow-e2e audit tmux
691 // sockets with it.
692 classes: "flow-checker": {
693 paths: "nix/checks/flow-checker/**": true
694 requires: "flow-build": true
695 requires: "flow-unit": true
696 requires: "flow-e2e": true
697 }
698
699 // The valley command flow-e2e runs and flow-policy derives with, as
700 // packages.valley-unstamped builds it: the Go source and go.mod of
701 // status and the modules it builds with, its help texts, the PIV
702 // signer's source, the delta vectors in the delta module, the
703 // attestation helper on its PATH, and the schemas they carry. A path
704 // cannot leave out a test file, so a module's tests match too; its
705 // prose, the approval command, its fixtures, the plan's golden files and
706 // the attestation vectors do not.
707 classes: "flow-valley": {
708 paths: "status/*.go": true
709 paths: "status/go.mod": true
710 paths: "status/help/**": true
711 paths: "approval/*.go": true
712 paths: "approval/go.mod": true
713 paths: "approval/piv/**": true
714 paths: "attest/*.go": true
715 paths: "attest/go.mod": true
716 paths: "change/*.go": true
717 paths: "change/go.mod": true
718 paths: "composed/*.go": true
719 paths: "composed/go.mod": true
720 paths: "delta/*.go": true
721 paths: "delta/go.mod": true
722 paths: "delta/testdata/.gitattributes": true
723 paths: "delta/testdata/vectors.py": true
724 paths: "delta/testdata/valid/**": true
725 paths: "delta/testdata/malformed/**": true
726 paths: "derive/*.go": true
727 paths: "derive/go.mod": true
728 paths: "knot/**/*.go": true
729 paths: "knot/go.mod": true
730 paths: "note/**/*.go": true
731 paths: "note/go.mod": true
732 paths: "rebase/*.go": true
733 paths: "rebase/go.mod": true
734 paths: "selfupdate/*.go": true
735 paths: "selfupdate/go.mod": true
736 paths: "telemetry/**/*.go": true
737 paths: "telemetry/go.mod": true
738 paths: "schema/verification.cue": true
739 paths: "schema/attestation.cue": true
740 requires: "flow-e2e": true
741 requires: "flow-policy": true
742 }
743
744 // flow-policy derives what changes around klaus require, from this
745 // layer over the example floor and the docs template.
746 classes: "flow-policy": {
747 paths: "nix/checks/flow-policy-checker/**": true
748 paths: "policy/project/**": true
749 paths: "examples/policy/instance/floor-format.cue": true
750 paths: "examples/policy/instance/template-docs.cue": true
751 requires: "flow-policy": true
752 }
753
754 for n in list.Concat([ownChecks, ["prose-format"]]) {
755 classes: ("check-\(n)"): {
756 paths: ("nix/checks/\(n).sh"): true
757 paths: ("nix/checks/\(n).nix"): true
758 requires: (n): true
759 }
760 }
761
762 // The other files under nix/checks/, and the checks that read each: the
763 // definitions of a subject's checks, and the helpers and rejection lists
764 // a check is given. cli.nix, which defines every check of the CLI,
765 // is left to the nix class, as is nix/checks.nix, which wires them all.
766 // This map can only require, so telemetry.nix keeps requiring
767 // telemetry-e2e: a change to its definition builds it before landing.
768 let checkFiles = {
769 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
770 "telemetry.nix": ["telemetry-unit", "telemetry-e2e"]
771 "delta.nix": ["delta-unit"]
772 "derive.nix": ["derive-unit", "composed-unit"]
773 "review.nix": ["review-unit"]
774 "identity.nix": ["identity-unit", "identity-e2e"]
775 "approval.nix": ["approval-unit"]
776 "integrator.nix": ["integrator-unit", "integrator-e2e"]
777 "signers.nix": ["signers-e2e"]
778 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
779 "web.nix": ["web-unit", "web-server-unit", "web-reader-state-crash", "web-receiver-unit", "web-image", "readaccess-unit"]
780 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
781 "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
782 "hooks.nix": ["valleyhook-unit", "change-unit", "pushpolicy-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
783 "host-module.nix": ["module-eval"]
784 "flow.nix": ["flow-build", "flow-unit", "flow-vet", "flow-e2e"]
785 "fail-nth.sh": ["policy-deriver", "valley-request"]
786 "review-notes-editor.sh": ["review-notes"]
787 "cue-vet-rejected.txt": ["cue-vet"]
788 "identity-rejected.txt": ["identity-schema"]
789 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
790 }
791 for f, ns in checkFiles {
792 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
793 paths: ("nix/checks/\(f)"): true
794 requires: {for n in ns {(n): true}}
795 }
796 }
797
798 // How far an approval carries across a rebase (#Carry in
799 // schema/verification.cue). Every path not named here is same-paths.
800 //
801 // The hook, the integrator, the signature verifier and the identity
802 // compiler enforce who may do what. An approval of a change to one of
803 // them carries only while no landing has touched the same classes:
804 // same-class. The identity compiler's class is its code and the schema
805 // it holds a registry to. It requires nothing, because the identity and
806 // schema classes already require the checks of its paths.
807 classes: valleyhook: carry: "same-class": true
808 classes: integrator: carry: "same-class": true
809 classes: sigverify: carry: "same-class": true
810 classes: "identity-compiler": {
811 paths: "identity/**": true
812 paths: "schema/identity.cue": true
813 carry: "same-class": true
814 }
815
816 // The policy decides what every change requires, so an approval of a
817 // change to it carries across no landing at all: exact. That is this
818 // layer, the pointer to the owning valley, and the schema a policy is
819 // written in. The example policies are fixtures and stay same-paths. Like
820 // identity-compiler, this class requires nothing: the policy class
821 // requires the checks of its paths.
822 //
823 // This tree holds no registry, grant or secret data of its own. The
824 // registries, grants and keys under examples/ and attest/conformance/
825 // are test fixtures, and the instance's registry is in its instance
826 // repository. So nothing else here is exact.
827 classes: "policy-authority": {
828 paths: "policy/**": true
829 paths: "schema/verification.cue": true
830 carry: exact: true
831 }
832
833 // The restacker's cap is the schema's default of 64 automatic versions
834 // per change.
835}
836
837// What no class above covers falls to the floor's `unclassified` rule and
838// requires prose-format alone. That is the research artefacts under research/,
839// the GitHub mirror's workflow under .github/, and editor settings: files
840// no program here reads.