gunk-dev/the-valley

policy.cue

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