gunk-dev/the-valley

policy.cue

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