gunk-dev/the-valley

policy.cue

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