gunk-dev/the-valley

policy.cue

source057d26402526main's published tip history
9.5 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-status-unit", // temporary alias of valley-go-unit while the rename lands
42 "valley-cli",
43 "review-notes",
44 "valley-request",
45 "valley-status",
46 "valley-ready",
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 and the CLI's Go verbs write.
91 // Both read a record through it, so a change to it owes their tests as
92 // 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 }
101
102 // The note envelope. The hook and attest both read notes through it, so
103 // a change to it owes their tests as well as its own.
104 classes: note: {
105 paths: "note/**": true
106 requires: "note-unit": true
107 requires: "valleyhook-unit": true
108 requires: "protect-e2e": true
109 requires: "attest-unit": true
110 requires: "attest-e2e": true
111 }
112
113 // The attestation helper, and the conformance vectors under
114 // attest/conformance/ that hold its written form fixed.
115 classes: attest: {
116 paths: "attest/**": true
117 requires: "attest-unit": true
118 requires: "attest-conformance": true
119 requires: "attest-e2e": true
120 }
121
122 // The identity registry compiler, and the registries it is driven over.
123 classes: identity: {
124 paths: "identity/**": true
125 paths: "examples/identity/**": true
126 requires: "identity-unit": true
127 requires: "identity-e2e": true
128 }
129
130 // The integrator, and the end-to-end scenarios under integrator/e2e/.
131 classes: integrator: {
132 paths: "integrator/**": true
133 requires: "integrator-unit": true
134 requires: "integrator-e2e": true
135 }
136
137 // The security-key signature verifier.
138 classes: sigverify: {
139 paths: "sigverify/**": true
140 requires: "sigverify-unit": true
141 requires: "sigverify-e2e": true
142 }
143
144 // The valley CLI: the script, its Go verbs (status/), and its
145 // completions. valley-ready drives ready, withdraw and the verbs that
146 // take a change's handle.
147 classes: cli: {
148 paths: "bin/valley": true
149 paths: "status/**": true
150 paths: "completions/**": true
151 requires: "valley-go-unit": true
152 requires: "valley-cli": true
153 requires: "review-notes": true
154 requires: "valley-request": true
155 requires: "valley-status": true
156 requires: "valley-ready": true
157 requires: "policy-deriver": true
158 }
159
160 // The verification policy: this layer, the pointer to the owning
161 // valley, the schema a policy is written in, and the example policies
162 // the deriver and cue-vet read.
163 classes: policy: {
164 paths: "policy/**": true
165 paths: "schema/verification.cue": true
166 paths: "examples/policy/**": true
167 requires: "policy-deriver": true
168 requires: "cue-vet": true
169 requires: "own-policy": true
170 }
171
172 // The flake, the NixOS module, the packages and the check definitions,
173 // and the host declarations the module checks are evaluated over.
174 // own-policy is here because renaming or removing a flake check would
175 // leave this layer naming a check that no longer exists. A change to
176 // flake.nix or flake.lock owes these alone, so a nixpkgs bump boots no
177 // machine.
178 classes: nix: {
179 paths: "nix/**": true
180 paths: "flake.nix": true
181 paths: "flake.lock": true
182 paths: "examples/host.cue": true
183 paths: "examples/hosts/**": true
184 requires: "module-eval": true
185 requires: "valley-darwin-eval": true
186 requires: "cue-vet": true
187 requires: "own-policy": true
188 }
189
190 // The schemas, and the example events, attestations and registries they
191 // are vetted against.
192 classes: schema: {
193 paths: "schema/**": true
194 paths: "examples/events/**": true
195 paths: "examples/attestations/**": true
196 paths: "examples/identity/**": true
197 requires: "cue-vet": true
198 requires: "attest-schema": true
199 requires: "identity-schema": true
200 }
201
202 // The knowledge lint itself: its program, the node schema it holds a
203 // graph to, and the example graphs it must accept and reject.
204 classes: "knowledge-lint": {
205 paths: "nix/knowledge-lint.*": true
206 paths: "schema/node.cue": true
207 paths: "examples/graphs/**": true
208 requires: "knowledge-lint": true
209 requires: "knowledge-lint-consumer": true
210 requires: "knowledge-lint-rejects": true
211 }
212
213 // The NixOS module and what its end-to-end checks run. The hook checks
214 // follow the scripts out of the hosts in nix/checks/hosts.nix, which
215 // are made of the three declarations named here; ssh-e2e and
216 // publish-e2e run the module in NixOS machines.
217 classes: "host-module": {
218 paths: "nix/valley-host.nix": true
219 paths: "nix/checks/hosts.nix": true
220 paths: "examples/hosts/protected.cue": true
221 paths: "examples/hosts/bus.cue": true
222 paths: "examples/hosts/mirrors.cue": true
223 requires: "init-e2e": true
224 requires: "mirror-e2e": true
225 requires: "bus-e2e": true
226 requires: "protect-e2e": true
227 requires: "identity-e2e": true
228 requires: "ssh-e2e": true
229 requires: "publish-e2e": true
230 }
231
232 // A check's own files owe that check: its script,
233 // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix,
234 // where it has a file of its own. One class per check, named
235 // check-<name>. prose-format is the floor's check, but its script is
236 // here. own-policy fails if a script under nix/checks/ owes no check.
237 for n in list.Concat([ownChecks, ["prose-format"]]) {
238 classes: ("check-\(n)"): {
239 paths: ("nix/checks/\(n).sh"): true
240 paths: ("nix/checks/\(n).nix"): true
241 requires: (n): true
242 }
243 }
244
245 // The other files under nix/checks/, and the checks that read each: the
246 // definitions of a subject's checks, and the helpers and rejection lists
247 // a check is given. cli.nix, which defines every check of bin/valley,
248 // is left to the nix class, as is nix/checks.nix, which wires them all.
249 let checkFiles = {
250 "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"]
251 "identity.nix": ["identity-unit", "identity-e2e"]
252 "integrator.nix": ["integrator-unit", "integrator-e2e"]
253 "sigverify.nix": ["sigverify-unit", "sigverify-e2e"]
254 "schema.nix": ["cue-vet", "attest-schema", "identity-schema"]
255 "knowledge.nix": ["knowledge-lint", "knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"]
256 "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"]
257 "host-module.nix": ["module-eval"]
258 "fail-nth.sh": ["policy-deriver", "valley-request"]
259 "review-notes-editor.sh": ["review-notes"]
260 "cue-vet-rejected.txt": ["cue-vet"]
261 "identity-rejected.txt": ["identity-schema"]
262 "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"]
263 }
264 for f, ns in checkFiles {
265 classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): {
266 paths: ("nix/checks/\(f)"): true
267 requires: {for n in ns {(n): true}}
268 }
269 }
270}
271
272// What no class above covers falls to the floor's `unclassified` rule and
273// owes prose-format alone. That is the research artefacts under research/,
274// the GitHub mirror's workflow under .github/, and editor settings: files
275// no program here reads.