gunk-dev/the-valley

policy.cue

source885985671589main's published tip history
11.4 KiB
1// the-valley's project layer: what this one project declares above the
2// floor. The floor is the owning valley's (qinling 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 "attest-unit",
36 "attest-conformance",
37 "attest-e2e",
38 "identity-unit",
39 "identity-e2e",
40 "integrator-unit",
41 "integrator-e2e",
42 "sigverify-unit",
43 "sigverify-e2e",
44 "valley-go-unit",
45 "valley-cli",
46 "review-notes",
47 "valley-request",
48 "valley-status",
49 "valley-ready",
50 "valley-changes",
51 "valley-knot",
52 "valley-plan",
53 "valley-darwin-eval",
54 "policy-deriver",
55 "own-policy",
56 "module-eval",
57 "cue-vet",
58 "attest-schema",
59 "identity-schema",
60 "knowledge-lint-consumer",
61 "knowledge-lint-rejects",
62 "init-e2e",
63 "mirror-e2e",
64 "bus-e2e",
65 "ssh-e2e",
66 "publish-e2e",
67 ]
68 for n in ownChecks {
69 checks: (n): {
70 runner: "nix"
71 attribute: n
72 }
73 }
74
75 // The integrator's scenarios take about a minute, and ssh-e2e and
76 // publish-e2e boot NixOS machines. Every other check here takes seconds
77 // once its packages are built.
78 checks: "integrator-e2e": cost: "slow"
79 checks: "ssh-e2e": cost: "slow"
80 checks: "publish-e2e": cost: "slow"
81
82 // Each class below is one part of the tree and the checks that read it.
83 // A path in two classes requires both sets. A Go module's unit check is its
84 // package, whose checkPhase runs `go test`.
85
86 // The pre-receive hook and the git user's login shell. protect-e2e
87 // pushes to bare repositories wired with the hook a host renders,
88 // valley-ready pushes change records through that hook, and knots-e2e
89 // pushes the plan graph through it.
90 classes: valleyhook: {
91 paths: "valleyhook/**": true
92 requires: "valleyhook-unit": true
93 requires: "protect-e2e": true
94 requires: "valley-ready": true
95 requires: "knots-e2e": true
96 }
97
98 // The change record, which the hook guards, the CLI's Go verbs write and
99 // the integrator reads. Each reads a record through it, so a change to
100 // it requires their tests as well as its own.
101 classes: change: {
102 paths: "change/**": true
103 requires: "change-unit": true
104 requires: "valleyhook-unit": true
105 requires: "protect-e2e": true
106 requires: "valley-go-unit": true
107 requires: "valley-ready": true
108 requires: "valley-changes": true
109 requires: "integrator-unit": true
110 requires: "integrator-e2e": true
111 }
112
113 // The plan graph's module, which the CLI's Go verbs write the graph
114 // with and the hook validates it with. knot-agree holds its validator
115 // to the node schema and the knowledge lint, valley-knot and
116 // valley-plan drive the verbs that use it, and knots-e2e pushes
117 // through the hook.
118 classes: knot: {
119 paths: "knot/**": true
120 requires: "knot-unit": true
121 requires: "knot-agree": true
122 requires: "valley-go-unit": true
123 requires: "valley-knot": true
124 requires: "valley-plan": true
125 requires: "valleyhook-unit": true
126 requires: "knots-e2e": true
127 }
128
129 // valley-delta-v1, which the CLI's Go verbs compare a version with its
130 // approved version through. delta-unit holds it to its conformance
131 // vectors, valley-go-unit builds the verbs with it, and valley-ready and
132 // review-notes drive review over the comparison.
133 classes: delta: {
134 paths: "delta/**": true
135 requires: "delta-unit": true
136 requires: "valley-go-unit": true
137 requires: "valley-ready": true
138 requires: "review-notes": true
139 }
140
141 // The note envelope. The hook and attest both read notes through it, so
142 // a change to it requires their tests as well as its own.
143 classes: note: {
144 paths: "note/**": true
145 requires: "note-unit": true
146 requires: "valleyhook-unit": true
147 requires: "protect-e2e": true
148 requires: "attest-unit": true
149 requires: "attest-e2e": true
150 }
151
152 // The attestation helper, and the conformance vectors under
153 // attest/conformance/ that hold its written form fixed.
154 classes: attest: {
155 paths: "attest/**": true
156 requires: "attest-unit": true
157 requires: "attest-conformance": true
158 requires: "attest-e2e": true
159 }
160
161 // The identity registry compiler, and the registries it is driven over.
162 classes: identity: {
163 paths: "identity/**": true
164 paths: "examples/identity/**": true
165 requires: "identity-unit": true
166 requires: "identity-e2e": true
167 }
168
169 // The integrator, and the end-to-end scenarios under integrator/e2e/.
170 classes: integrator: {
171 paths: "integrator/**": true
172 requires: "integrator-unit": true
173 requires: "integrator-e2e": true
174 }
175
176 // The security-key signature verifier.
177 classes: sigverify: {
178 paths: "sigverify/**": true
179 requires: "sigverify-unit": true
180 requires: "sigverify-e2e": true
181 }
182
183 // The valley CLI: the script, its Go verbs (status/), and its
184 // completions. valley-ready drives ready, withdraw and the verbs that
185 // take a change's handle, valley-changes drives changes and pending,
186 // and valley-plan drives plan against the golden files under
187 // status/testdata/plan/.
188 classes: cli: {
189 paths: "bin/valley": true
190 paths: "status/**": true
191 paths: "completions/**": true
192 requires: "valley-go-unit": true
193 requires: "valley-cli": true
194 requires: "review-notes": true
195 requires: "valley-request": true
196 requires: "valley-status": true
197 requires: "valley-ready": true
198 requires: "valley-changes": true
199 requires: "valley-knot": true
200 requires: "valley-plan": true
201 requires: "policy-deriver": true
202 }
203
204 // The verification policy: this layer, the pointer to the owning
205 // valley, the schema a policy is written in, and the example policies
206 // the deriver and cue-vet read.
207 classes: policy: {
208 paths: "policy/**": true
209 paths: "schema/verification.cue": true
210 paths: "examples/policy/**": true
211 requires: "policy-deriver": true
212 requires: "cue-vet": true
213 requires: "own-policy": true
214 }
215
216 // The flake, the NixOS module, the packages and the check definitions,
217 // and the host declarations the module checks are evaluated over.
218 // own-policy is here because renaming or removing a flake check would
219 // leave this layer naming a check that no longer exists. A change to
220 // flake.nix or flake.lock requires these alone, so a nixpkgs bump boots no
221 // machine.
222 classes: nix: {
223 paths: "nix/**": true
224 paths: "flake.nix": true
225 paths: "flake.lock": true
226 paths: "examples/host.cue": true
227 paths: "examples/hosts/**": true
228 requires: "module-eval": true
229 requires: "valley-darwin-eval": true
230 requires: "cue-vet": true
231 requires: "own-policy": true
232 }
233
234 // The schemas, and the example events, attestations and registries they
235 // are vetted against.
236 classes: schema: {
237 paths: "schema/**": true
238 paths: "examples/events/**": true
239 paths: "examples/attestations/**": true
240 paths: "examples/identity/**": true
241 requires: "cue-vet": true
242 requires: "attest-schema": true
243 requires: "identity-schema": true
244 }
245
246 // The knowledge lint itself: its program, the node schema it holds a
247 // graph to, and the example graphs it must accept and reject. The plan
248 // graph's validator is held to the same two by knot-agree.
249 classes: "knowledge-lint": {
250 paths: "nix/knowledge-lint.*": true
251 paths: "schema/node.cue": true
252 paths: "examples/graphs/**": true
253 requires: "knowledge-lint-consumer": true
254 requires: "knowledge-lint-rejects": true
255 requires: "knot-agree": true
256 }
257
258 // The NixOS module and what its end-to-end checks run. The hook checks
259 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
260 // are made of the three declarations named here; ssh-e2e and
261 // publish-e2e run the module in NixOS machines.
262 classes: "host-module": {
263 paths: "nix/valley-host.nix": true
264 paths: "nix/checks/hosts.nix": true
265 paths: "examples/hosts/protected.cue": true
266 paths: "examples/hosts/bus.cue": true
267 paths: "examples/hosts/mirrors.cue": true
268 requires: "init-e2e": true
269 requires: "mirror-e2e": true
270 requires: "bus-e2e": true
271 requires: "protect-e2e": true
272 requires: "knots-e2e": true
273 requires: "identity-e2e": true
274 requires: "ssh-e2e": true
275 requires: "publish-e2e": true
276 requires: "valley-changes": true
277 }
278
279 // A check's own files require that check: its script,
280 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
281 // where it has a file of its own. One class per check, named
282 // check-<name>. prose-format is the floor's check, but its script is
283 // here. own-policy fails if a script under nix/checks/ requires no
284 // check.
285 for n in list.Concat([ownChecks, ["prose-format"]]) {
286 classes: ("check-\(n)"): {
287 paths: ("nix/checks/\(n).sh"): true
288 paths: ("nix/checks/\(n).nix"): true
289 requires: (n): true
290 }
291 }
292
293 // The other files under nix/checks/, and the checks that read each: the
294 // definitions of a subject's checks, and the helpers and rejection lists
295 // a check is given. cli.nix, which defines every check of bin/valley,
296 // is left to the nix class, as is nix/checks.nix, which wires them all.
297 let checkFiles = {
298 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
299 "delta.nix": ["delta-unit"]
300 "identity.nix": ["identity-unit", "identity-e2e"]
301 "integrator.nix": ["integrator-unit", "integrator-e2e"]
302 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
303 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
304 "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
305 "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
306 "host-module.nix": ["module-eval"]
307 "fail-nth.sh": ["policy-deriver", "valley-request"]
308 "review-notes-editor.sh": ["review-notes"]
309 "cue-vet-rejected.txt": ["cue-vet"]
310 "identity-rejected.txt": ["identity-schema"]
311 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
312 }
313 for f, ns in checkFiles {
314 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
315 paths: ("nix/checks/\(f)"): true
316 requires: {for n in ns {(n): true}}
317 }
318 }
319}
320
321// What no class above covers falls to the floor's `unclassified` rule and
322// requires prose-format alone. That is the research artefacts under research/,
323// the GitHub mirror's workflow under .github/, and editor settings: files
324// no program here reads.