gunk-dev/the-valley

policy.cue

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