gunk-dev/the-valley

policy.cue

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