gunk-dev/the-valley

policy.cue

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