gunk-dev/the-valley

policy.cue

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