gunk-dev/the-valley

policy.cue

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