gunk-dev/the-valley

policy.cue

sourcee52aaaabfd3amain's published tip history
19.0 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 declarations
237 // under the web visibility schema. Changes require both checks.
238 classes: webui: {
239 paths: "webui/**": true
240 paths: "schema/web.cue": true
241 requires: "webui-unit": true
242 requires: "webui-server-unit": true
243 }
244
245 // Read access: the two consents a reader needs, the evaluator that
246 // intersects them, and the coverage report. readaccess-unit reads both
247 // schemas, so a change to either requires it, and the web publisher
248 // reads its consents through the module, so webui-unit runs too.
249 classes: readaccess: {
250 paths: "readaccess/**": true
251 paths: "schema/read.cue": true
252 paths: "schema/identity.cue": true
253 requires: "readaccess-unit": true
254 requires: "webui-unit": true
255 }
256
257 // The valley CLI: the script, its Go verbs (status/), the rebase engine
258 // they rebase and read landings with (rebase/), and its completions.
259 // valley-ready drives ready, withdraw, rebase and the verbs that take a
260 // change's handle, valley-changes drives changes and pending,
261 // valley-plan drives plan against the golden files under
262 // status/testdata/plan/, and valley-self-update drives --version and
263 // self-update. derive-unit holds the script's deriver to the Go one.
264 // The web publisher reads the valley through plan, pending and knot
265 // show, and its tests in webui-unit run the CLI itself.
266 classes: cli: {
267 paths: "bin/valley": true
268 paths: "status/**": true
269 paths: "rebase/**": true
270 paths: "completions/**": true
271 requires: "valley-go-unit": true
272 requires: "valley-cli": true
273 requires: "review-notes": true
274 requires: "valley-request": true
275 requires: "valley-status": true
276 requires: "valley-ready": true
277 requires: "valley-changes": true
278 requires: "valley-knot": true
279 requires: "valley-plan": true
280 requires: "valley-self-update": true
281 requires: "policy-deriver": true
282 requires: "derive-unit": true
283 requires: "webui-unit": true
284 }
285
286 // Self-update: its module (selfupdate/), the policy the package ships
287 // for its smoke test, and the home-manager module that runs it on a
288 // timer. valley-go-unit builds the verb with the module, and
289 // valley-self-update drives the verb through the package and holds the
290 // units the home-manager module renders.
291 classes: selfupdate: {
292 paths: "selfupdate/**": true
293 paths: "examples/policy/smoke/**": true
294 paths: "nix/home-module.nix": true
295 requires: "selfupdate-unit": true
296 requires: "valley-go-unit": true
297 requires: "valley-self-update": true
298 }
299
300 // The rebase engine, with its own tests over real repositories. The
301 // verbs that run it are the cli class's, so its paths are there too.
302 classes: rebase: {
303 paths: "rebase/**": true
304 requires: "rebase-unit": true
305 }
306
307 // The restacker, with its unit tests and its planner end to end. It
308 // reads origin through the rebase engine and the policy through the
309 // composed-policy reader it shares with the integrator, so a change to
310 // either requires its checks too.
311 classes: restack: {
312 paths: "restack/**": true
313 paths: "composed/**": true
314 paths: "rebase/**": true
315 requires: "restack-unit": true
316 requires: "restack-e2e": true
317 }
318
319 // What a client verifies an integrator's transfer statement with: the
320 // host's publisher and the default name it publishes, the unit that
321 // runs it, the client's reading of the signers, the instance discovery
322 // it reads them through, and the snapshot that asks for them.
323 // signers-e2e drives them together over the real integrator.
324 classes: signers: {
325 paths: "integrator/signers.go": true
326 paths: "integrator/main.go": true
327 paths: "nix/valley-host.nix": true
328 paths: "status/signers.go": true
329 paths: "status/list.go": true
330 paths: "rebase/snapshot.go": true
331 requires: "signers-e2e": true
332 }
333
334 // The web publisher's module, which runs the publisher on a timer in a
335 // sandbox of its own. webui-publisher-e2e runs the unit it renders in a
336 // NixOS machine. module-eval, in the nix class, holds what it renders.
337 classes: "webui-publisher": {
338 paths: "nix/webui-publisher.nix": true
339 requires: "webui-publisher-e2e": true
340 }
341
342 // The verification policy: this layer, the pointer to the owning
343 // valley, the schema a policy is written in, and the example policies
344 // the derivers and cue-vet read.
345 classes: policy: {
346 paths: "policy/**": true
347 paths: "schema/verification.cue": true
348 paths: "examples/policy/**": true
349 requires: "policy-deriver": true
350 requires: "derive-unit": true
351 requires: "cue-vet": true
352 requires: "own-policy": true
353 }
354
355 // The flake, the NixOS module, the packages and the check definitions,
356 // and the host declarations the module checks are evaluated over.
357 // own-policy is here because renaming or removing a flake check would
358 // leave this layer naming a check that no longer exists. A change to
359 // flake.nix or flake.lock requires these alone, so a nixpkgs bump boots no
360 // machine.
361 classes: nix: {
362 paths: "nix/**": true
363 paths: "flake.nix": true
364 paths: "flake.lock": true
365 paths: "examples/host.cue": true
366 paths: "examples/hosts/**": true
367 requires: "module-eval": true
368 requires: "valley-darwin-eval": true
369 requires: "cue-vet": true
370 requires: "own-policy": true
371 }
372
373 // The schemas, and the example events, attestations and registries they
374 // are vetted against.
375 classes: schema: {
376 paths: "schema/**": true
377 paths: "examples/events/**": true
378 paths: "examples/attestations/**": true
379 paths: "examples/identity/**": true
380 requires: "cue-vet": true
381 requires: "attest-schema": true
382 requires: "identity-schema": true
383 }
384
385 // The knowledge lint itself: its program, the node schema it holds a
386 // graph to, and the example graphs it must accept and reject. The plan
387 // graph's validator is held to the same two by knot-agree.
388 classes: "knowledge-lint": {
389 paths: "nix/knowledge-lint.*": true
390 paths: "schema/node.cue": true
391 paths: "examples/graphs/**": true
392 requires: "knowledge-lint-consumer": true
393 requires: "knowledge-lint-rejects": true
394 requires: "knot-agree": true
395 }
396
397 // The NixOS module and what its end-to-end checks run. The hook checks
398 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
399 // are made of the three declarations named here; ssh-e2e, publish-e2e
400 // and worker-e2e run the module in NixOS machines.
401 classes: "host-module": {
402 paths: "nix/valley-host.nix": true
403 paths: "nix/checks/hosts.nix": true
404 paths: "examples/hosts/protected.cue": true
405 paths: "examples/hosts/bus.cue": true
406 paths: "examples/hosts/mirrors.cue": true
407 requires: "init-e2e": true
408 requires: "mirror-e2e": true
409 requires: "bus-e2e": true
410 requires: "protect-e2e": true
411 requires: "knots-e2e": true
412 requires: "identity-e2e": true
413 requires: "ssh-e2e": true
414 requires: "publish-e2e": true
415 requires: "worker-e2e": true
416 requires: "valley-changes": true
417 }
418
419 // A check's own files require that check: its script,
420 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
421 // where it has a file of its own. One class per check, named
422 // check-<name>. prose-format is the floor's check, but its script is
423 // here. own-policy fails if a script under nix/checks/ requires no
424 // check.
425 for n in list.Concat([ownChecks, ["prose-format"]]) {
426 classes: ("check-\(n)"): {
427 paths: ("nix/checks/\(n).sh"): true
428 paths: ("nix/checks/\(n).nix"): true
429 requires: (n): true
430 }
431 }
432
433 // The other files under nix/checks/, and the checks that read each: the
434 // definitions of a subject's checks, and the helpers and rejection lists
435 // a check is given. cli.nix, which defines every check of bin/valley,
436 // is left to the nix class, as is nix/checks.nix, which wires them all.
437 let checkFiles = {
438 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
439 "delta.nix": ["delta-unit"]
440 "derive.nix": ["derive-unit"]
441 "review.nix": ["review-unit"]
442 "identity.nix": ["identity-unit", "identity-e2e"]
443 "integrator.nix": ["integrator-unit", "integrator-e2e"]
444 "signers.nix": ["signers-e2e"]
445 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
446 "webui.nix": ["webui-unit", "webui-server-unit", "readaccess-unit"]
447 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
448 "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
449 "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
450 "host-module.nix": ["module-eval"]
451 "fail-nth.sh": ["policy-deriver", "valley-request"]
452 "review-notes-editor.sh": ["review-notes"]
453 "cue-vet-rejected.txt": ["cue-vet"]
454 "identity-rejected.txt": ["identity-schema"]
455 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
456 }
457 for f, ns in checkFiles {
458 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
459 paths: ("nix/checks/\(f)"): true
460 requires: {for n in ns {(n): true}}
461 }
462 }
463
464 // How far an approval carries across a rebase (#Carry in
465 // schema/verification.cue). Every path not named here is same-paths.
466 //
467 // The hook, the integrator, the signature verifier and the identity
468 // compiler enforce who may do what. An approval of a change to one of
469 // them carries only while no landing has touched the same classes:
470 // same-class. The identity compiler's class is its code and the schema
471 // it holds a registry to. It requires nothing, because the identity and
472 // schema classes already require the checks of its paths.
473 classes: valleyhook: carry: "same-class": true
474 classes: integrator: carry: "same-class": true
475 classes: sigverify: carry: "same-class": true
476 classes: "identity-compiler": {
477 paths: "identity/**": true
478 paths: "schema/identity.cue": true
479 carry: "same-class": true
480 }
481
482 // The policy decides what every change requires, so an approval of a
483 // change to it carries across no landing at all: exact. That is this
484 // layer, the pointer to the owning valley, and the schema a policy is
485 // written in. The example policies are fixtures and stay same-paths. Like
486 // identity-compiler, this class requires nothing: the policy class
487 // requires the checks of its paths.
488 //
489 // This tree holds no registry, grant or secret data of its own. The
490 // registries, grants and keys under examples/ and attest/conformance/
491 // are test fixtures, and the instance's registry is in its instance
492 // repository. So nothing else here is exact.
493 classes: "policy-authority": {
494 paths: "policy/**": true
495 paths: "schema/verification.cue": true
496 carry: exact: true
497 }
498
499 // The restacker's cap is the schema's default of 64 automatic versions
500 // per change.
501}
502
503// What no class above covers falls to the floor's `unclassified` rule and
504// requires prose-format alone. That is the research artefacts under research/,
505// the GitHub mirror's workflow under .github/, and editor settings: files
506// no program here reads.