| 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). |
| 5 | package verification |
| 6 | |
| 7 | import ( |
| 8 | "list" |
| 9 | "strings" |
| 10 | ) |
| 11 | |
| 12 | project: { |
| 13 | // the-valley takes no knowledge lint of its own tree. The docs |
| 14 | // template's lint checks a knowledge graph kept in the source, and |
| 15 | // the-valley's source holds none: its plan graph is project storage, at |
| 16 | // refs/the-valley/knots, and the push hook holds it to the knot |
| 17 | // module's rules. The nodes under archive/.the-valley/ are history that |
| 18 | // never changes, so linting them against today's schema protects |
| 19 | // nothing. The lint itself stays covered: the knowledge-lint class |
| 20 | // below requires its consumer and rejection checks. |
| 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 | "knots-e2e", |
| 30 | "note-unit", |
| 31 | "change-unit", |
| 32 | "knot-unit", |
| 33 | "knot-agree", |
| 34 | "delta-unit", |
| 35 | "derive-unit", |
| 36 | "review-unit", |
| 37 | "attest-unit", |
| 38 | "attest-conformance", |
| 39 | "attest-e2e", |
| 40 | "identity-unit", |
| 41 | "identity-e2e", |
| 42 | "integrator-unit", |
| 43 | "integrator-e2e", |
| 44 | "restack-unit", |
| 45 | "restack-e2e", |
| 46 | "signers-e2e", |
| 47 | "sigverify-unit", |
| 48 | "sigverify-e2e", |
| 49 | "rebase-unit", |
| 50 | "valley-go-unit", |
| 51 | "valley-cli", |
| 52 | "review-notes", |
| 53 | "valley-request", |
| 54 | "valley-status", |
| 55 | "valley-ready", |
| 56 | "valley-changes", |
| 57 | "valley-knot", |
| 58 | "valley-plan", |
| 59 | "valley-darwin-eval", |
| 60 | "selfupdate-unit", |
| 61 | "valley-self-update", |
| 62 | "policy-deriver", |
| 63 | "own-policy", |
| 64 | "module-eval", |
| 65 | "cue-vet", |
| 66 | "attest-schema", |
| 67 | "identity-schema", |
| 68 | "knowledge-lint-consumer", |
| 69 | "knowledge-lint-rejects", |
| 70 | "init-e2e", |
| 71 | "mirror-e2e", |
| 72 | "bus-e2e", |
| 73 | "ssh-e2e", |
| 74 | "publish-e2e", |
| 75 | ] |
| 76 | for n in ownChecks { |
| 77 | checks: (n): { |
| 78 | runner: "nix" |
| 79 | attribute: n |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // The integrator's scenarios take about a minute, and ssh-e2e and |
| 84 | // publish-e2e boot NixOS machines. Every other check here takes seconds |
| 85 | // once its packages are built. |
| 86 | checks: "integrator-e2e": cost: "slow" |
| 87 | checks: "ssh-e2e": cost: "slow" |
| 88 | checks: "publish-e2e": cost: "slow" |
| 89 | |
| 90 | // Each class below is one part of the tree and the checks that read it. |
| 91 | // A path in two classes requires both sets. A Go module's unit check is |
| 92 | // its package built again with its tests, which runs `go test`. The |
| 93 | // package itself runs no tests (nix/packages.nix). |
| 94 | |
| 95 | // The pre-receive hook and the git user's login shell. protect-e2e |
| 96 | // pushes to bare repositories wired with the hook a host renders, |
| 97 | // valley-ready pushes change records through that hook, and knots-e2e |
| 98 | // pushes the plan graph through it. |
| 99 | classes: valleyhook: { |
| 100 | paths: "valleyhook/**": true |
| 101 | requires: "valleyhook-unit": true |
| 102 | requires: "protect-e2e": true |
| 103 | requires: "valley-ready": true |
| 104 | requires: "knots-e2e": true |
| 105 | } |
| 106 | |
| 107 | // The change record, which the hook guards, the CLI's Go verbs and the |
| 108 | // rebase engine write, and the integrator and the review module read. |
| 109 | // Each reads a record through it, so a change to it requires their tests |
| 110 | // as well as its own. |
| 111 | classes: change: { |
| 112 | paths: "change/**": true |
| 113 | requires: "change-unit": true |
| 114 | requires: "review-unit": true |
| 115 | requires: "valleyhook-unit": true |
| 116 | requires: "protect-e2e": true |
| 117 | requires: "rebase-unit": true |
| 118 | requires: "valley-go-unit": true |
| 119 | requires: "valley-ready": true |
| 120 | requires: "valley-changes": true |
| 121 | requires: "integrator-unit": true |
| 122 | requires: "integrator-e2e": true |
| 123 | } |
| 124 | |
| 125 | // The plan graph's module, which the CLI's Go verbs write the graph |
| 126 | // with and the hook validates it with. knot-agree holds its validator |
| 127 | // to the node schema and the knowledge lint, valley-knot and |
| 128 | // valley-plan drive the verbs that use it, and knots-e2e pushes |
| 129 | // through the hook. |
| 130 | classes: knot: { |
| 131 | paths: "knot/**": true |
| 132 | requires: "knot-unit": true |
| 133 | requires: "knot-agree": true |
| 134 | requires: "valley-go-unit": true |
| 135 | requires: "valley-knot": true |
| 136 | requires: "valley-plan": true |
| 137 | requires: "valleyhook-unit": true |
| 138 | requires: "knots-e2e": true |
| 139 | } |
| 140 | |
| 141 | // valley-delta-v1, which the CLI's Go verbs compare a version with its |
| 142 | // approved version through, and which the review module recomputes a |
| 143 | // review's binding with. delta-unit holds it to its conformance vectors, |
| 144 | // valley-go-unit builds the verbs with it, valley-ready and review-notes |
| 145 | // drive review over the comparison, and review-unit binds reviews with |
| 146 | // its bounded reading. |
| 147 | classes: delta: { |
| 148 | paths: "delta/**": true |
| 149 | requires: "delta-unit": true |
| 150 | requires: "valley-go-unit": true |
| 151 | requires: "valley-ready": true |
| 152 | requires: "review-notes": true |
| 153 | requires: "review-unit": true |
| 154 | } |
| 155 | |
| 156 | // Review records: the record, its binding to the version it judged, and |
| 157 | // its append-only history. review-unit runs its tests against real git. |
| 158 | classes: review: { |
| 159 | paths: "review/**": true |
| 160 | requires: "review-unit": true |
| 161 | } |
| 162 | |
| 163 | // The deriver of required checks, and the composed-policy reader it reads |
| 164 | // the whole policy through. derive-unit holds the deriver to bin/valley's, |
| 165 | // and valley-go-unit builds the verb that prints its answer with both. |
| 166 | classes: derive: { |
| 167 | paths: "derive/**": true |
| 168 | paths: "composed/**": true |
| 169 | requires: "derive-unit": true |
| 170 | requires: "valley-go-unit": true |
| 171 | } |
| 172 | |
| 173 | // The note envelope. The hook and attest both read notes through it, |
| 174 | // and the identity compiler reads its approval files back with it, so a |
| 175 | // change to it requires their tests as well as its own. |
| 176 | classes: note: { |
| 177 | paths: "note/**": true |
| 178 | requires: "note-unit": true |
| 179 | requires: "valleyhook-unit": true |
| 180 | requires: "protect-e2e": true |
| 181 | requires: "attest-unit": true |
| 182 | requires: "attest-e2e": true |
| 183 | requires: "identity-unit": true |
| 184 | } |
| 185 | |
| 186 | // The attestation helper, and the conformance vectors under |
| 187 | // attest/conformance/ that hold its written form fixed. |
| 188 | classes: attest: { |
| 189 | paths: "attest/**": true |
| 190 | requires: "attest-unit": true |
| 191 | requires: "attest-conformance": true |
| 192 | requires: "attest-e2e": true |
| 193 | } |
| 194 | |
| 195 | // The identity registry compiler, and the registries it is driven over. |
| 196 | classes: identity: { |
| 197 | paths: "identity/**": true |
| 198 | paths: "examples/identity/**": true |
| 199 | requires: "identity-unit": true |
| 200 | requires: "identity-e2e": true |
| 201 | } |
| 202 | |
| 203 | // The integrator, the end-to-end scenarios under integrator/e2e/, and the |
| 204 | // verification schema, which the integrator composes every policy under |
| 205 | // and both checks read. |
| 206 | classes: integrator: { |
| 207 | paths: "integrator/**": true |
| 208 | paths: "composed/**": true |
| 209 | paths: "schema/verification.cue": true |
| 210 | requires: "integrator-unit": true |
| 211 | requires: "integrator-e2e": true |
| 212 | } |
| 213 | |
| 214 | // The security-key signature verifier. |
| 215 | classes: sigverify: { |
| 216 | paths: "sigverify/**": true |
| 217 | requires: "sigverify-unit": true |
| 218 | requires: "sigverify-e2e": true |
| 219 | } |
| 220 | |
| 221 | // The valley CLI: the script, its Go verbs (status/), the rebase engine |
| 222 | // they rebase and read landings with (rebase/), and its completions. |
| 223 | // valley-ready drives ready, withdraw, rebase and the verbs that take a |
| 224 | // change's handle, valley-changes drives changes and pending, |
| 225 | // valley-plan drives plan against the golden files under |
| 226 | // status/testdata/plan/, and valley-self-update drives --version and |
| 227 | // self-update. derive-unit holds the script's deriver to the Go one. |
| 228 | classes: cli: { |
| 229 | paths: "bin/valley": true |
| 230 | paths: "status/**": true |
| 231 | paths: "rebase/**": true |
| 232 | paths: "completions/**": true |
| 233 | requires: "valley-go-unit": true |
| 234 | requires: "valley-cli": true |
| 235 | requires: "review-notes": true |
| 236 | requires: "valley-request": true |
| 237 | requires: "valley-status": true |
| 238 | requires: "valley-ready": true |
| 239 | requires: "valley-changes": true |
| 240 | requires: "valley-knot": true |
| 241 | requires: "valley-plan": true |
| 242 | requires: "valley-self-update": true |
| 243 | requires: "policy-deriver": true |
| 244 | requires: "derive-unit": true |
| 245 | } |
| 246 | |
| 247 | // Self-update: its module (selfupdate/), the policy the package ships |
| 248 | // for its smoke test, and the home-manager module that runs it on a |
| 249 | // timer. valley-go-unit builds the verb with the module, and |
| 250 | // valley-self-update drives the verb through the package and holds the |
| 251 | // units the home-manager module renders. |
| 252 | classes: selfupdate: { |
| 253 | paths: "selfupdate/**": true |
| 254 | paths: "examples/policy/smoke/**": true |
| 255 | paths: "nix/home-module.nix": true |
| 256 | requires: "selfupdate-unit": true |
| 257 | requires: "valley-go-unit": true |
| 258 | requires: "valley-self-update": true |
| 259 | } |
| 260 | |
| 261 | // The rebase engine, with its own tests over real repositories. The |
| 262 | // verbs that run it are the cli class's, so its paths are there too. |
| 263 | classes: rebase: { |
| 264 | paths: "rebase/**": true |
| 265 | requires: "rebase-unit": true |
| 266 | } |
| 267 | |
| 268 | // The restacker, with its unit tests and its planner end to end. It |
| 269 | // reads origin through the rebase engine and the policy through the |
| 270 | // composed-policy reader it shares with the integrator, so a change to |
| 271 | // either requires its checks too. |
| 272 | classes: restack: { |
| 273 | paths: "restack/**": true |
| 274 | paths: "composed/**": true |
| 275 | paths: "rebase/**": true |
| 276 | requires: "restack-unit": true |
| 277 | requires: "restack-e2e": true |
| 278 | } |
| 279 | |
| 280 | // What a client verifies an integrator's transfer statement with: the |
| 281 | // host's publisher and the default name it publishes, the unit that |
| 282 | // runs it, the client's reading of the signers, the instance discovery |
| 283 | // it reads them through, and the snapshot that asks for them. |
| 284 | // signers-e2e drives them together over the real integrator. |
| 285 | classes: signers: { |
| 286 | paths: "integrator/signers.go": true |
| 287 | paths: "integrator/main.go": true |
| 288 | paths: "nix/valley-host.nix": true |
| 289 | paths: "status/signers.go": true |
| 290 | paths: "status/list.go": true |
| 291 | paths: "rebase/snapshot.go": true |
| 292 | requires: "signers-e2e": true |
| 293 | } |
| 294 | |
| 295 | // The verification policy: this layer, the pointer to the owning |
| 296 | // valley, the schema a policy is written in, and the example policies |
| 297 | // the derivers and cue-vet read. |
| 298 | classes: policy: { |
| 299 | paths: "policy/**": true |
| 300 | paths: "schema/verification.cue": true |
| 301 | paths: "examples/policy/**": true |
| 302 | requires: "policy-deriver": true |
| 303 | requires: "derive-unit": true |
| 304 | requires: "cue-vet": true |
| 305 | requires: "own-policy": true |
| 306 | } |
| 307 | |
| 308 | // The flake, the NixOS module, the packages and the check definitions, |
| 309 | // and the host declarations the module checks are evaluated over. |
| 310 | // own-policy is here because renaming or removing a flake check would |
| 311 | // leave this layer naming a check that no longer exists. A change to |
| 312 | // flake.nix or flake.lock requires these alone, so a nixpkgs bump boots no |
| 313 | // machine. |
| 314 | classes: nix: { |
| 315 | paths: "nix/**": true |
| 316 | paths: "flake.nix": true |
| 317 | paths: "flake.lock": true |
| 318 | paths: "examples/host.cue": true |
| 319 | paths: "examples/hosts/**": true |
| 320 | requires: "module-eval": true |
| 321 | requires: "valley-darwin-eval": true |
| 322 | requires: "cue-vet": true |
| 323 | requires: "own-policy": true |
| 324 | } |
| 325 | |
| 326 | // The schemas, and the example events, attestations and registries they |
| 327 | // are vetted against. |
| 328 | classes: schema: { |
| 329 | paths: "schema/**": true |
| 330 | paths: "examples/events/**": true |
| 331 | paths: "examples/attestations/**": true |
| 332 | paths: "examples/identity/**": true |
| 333 | requires: "cue-vet": true |
| 334 | requires: "attest-schema": true |
| 335 | requires: "identity-schema": true |
| 336 | } |
| 337 | |
| 338 | // The knowledge lint itself: its program, the node schema it holds a |
| 339 | // graph to, and the example graphs it must accept and reject. The plan |
| 340 | // graph's validator is held to the same two by knot-agree. |
| 341 | classes: "knowledge-lint": { |
| 342 | paths: "nix/knowledge-lint.*": true |
| 343 | paths: "schema/node.cue": true |
| 344 | paths: "examples/graphs/**": true |
| 345 | requires: "knowledge-lint-consumer": true |
| 346 | requires: "knowledge-lint-rejects": true |
| 347 | requires: "knot-agree": true |
| 348 | } |
| 349 | |
| 350 | // The NixOS module and what its end-to-end checks run. The hook checks |
| 351 | // follow the scripts out of the hosts in nix/checks/hosts.nix, which |
| 352 | // are made of the three declarations named here; ssh-e2e and |
| 353 | // publish-e2e run the module in NixOS machines. |
| 354 | classes: "host-module": { |
| 355 | paths: "nix/valley-host.nix": true |
| 356 | paths: "nix/checks/hosts.nix": true |
| 357 | paths: "examples/hosts/protected.cue": true |
| 358 | paths: "examples/hosts/bus.cue": true |
| 359 | paths: "examples/hosts/mirrors.cue": true |
| 360 | requires: "init-e2e": true |
| 361 | requires: "mirror-e2e": true |
| 362 | requires: "bus-e2e": true |
| 363 | requires: "protect-e2e": true |
| 364 | requires: "knots-e2e": true |
| 365 | requires: "identity-e2e": true |
| 366 | requires: "ssh-e2e": true |
| 367 | requires: "publish-e2e": true |
| 368 | requires: "valley-changes": true |
| 369 | } |
| 370 | |
| 371 | // A check's own files require that check: its script, |
| 372 | // nix/checks/<name>.sh, and its definition, nix/checks/<name>.nix, |
| 373 | // where it has a file of its own. One class per check, named |
| 374 | // check-<name>. prose-format is the floor's check, but its script is |
| 375 | // here. own-policy fails if a script under nix/checks/ requires no |
| 376 | // check. |
| 377 | for n in list.Concat([ownChecks, ["prose-format"]]) { |
| 378 | classes: ("check-\(n)"): { |
| 379 | paths: ("nix/checks/\(n).sh"): true |
| 380 | paths: ("nix/checks/\(n).nix"): true |
| 381 | requires: (n): true |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | // The other files under nix/checks/, and the checks that read each: the |
| 386 | // definitions of a subject's checks, and the helpers and rejection lists |
| 387 | // a check is given. cli.nix, which defines every check of bin/valley, |
| 388 | // is left to the nix class, as is nix/checks.nix, which wires them all. |
| 389 | let checkFiles = { |
| 390 | "attest.nix": ["attest-unit", "attest-conformance", "attest-e2e"] |
| 391 | "delta.nix": ["delta-unit"] |
| 392 | "derive.nix": ["derive-unit"] |
| 393 | "review.nix": ["review-unit"] |
| 394 | "identity.nix": ["identity-unit", "identity-e2e"] |
| 395 | "integrator.nix": ["integrator-unit", "integrator-e2e"] |
| 396 | "signers.nix": ["signers-e2e"] |
| 397 | "sigverify.nix": ["sigverify-unit", "sigverify-e2e"] |
| 398 | "schema.nix": ["cue-vet", "attest-schema", "identity-schema"] |
| 399 | "knowledge.nix": ["knowledge-lint-consumer", "knowledge-lint-rejects", "prose-format"] |
| 400 | "hooks.nix": ["valleyhook-unit", "change-unit", "mirror-e2e", "protect-e2e", "init-e2e", "bus-e2e"] |
| 401 | "host-module.nix": ["module-eval"] |
| 402 | "fail-nth.sh": ["policy-deriver", "valley-request"] |
| 403 | "review-notes-editor.sh": ["review-notes"] |
| 404 | "cue-vet-rejected.txt": ["cue-vet"] |
| 405 | "identity-rejected.txt": ["identity-schema"] |
| 406 | "knowledge-lint-rejected.txt": ["knowledge-lint-rejects"] |
| 407 | } |
| 408 | for f, ns in checkFiles { |
| 409 | classes: ("check-file-\(strings.Replace(f, ".", "-", -1))"): { |
| 410 | paths: ("nix/checks/\(f)"): true |
| 411 | requires: {for n in ns {(n): true}} |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | // How far an approval carries across a rebase (#Carry in |
| 416 | // schema/verification.cue). Every path not named here is same-paths. |
| 417 | // |
| 418 | // The hook, the integrator, the signature verifier and the identity |
| 419 | // compiler enforce who may do what. An approval of a change to one of |
| 420 | // them carries only while no landing has touched the same classes: |
| 421 | // same-class. The identity compiler's class is its code and the schema |
| 422 | // it holds a registry to. It requires nothing, because the identity and |
| 423 | // schema classes already require the checks of its paths. |
| 424 | classes: valleyhook: carry: "same-class": true |
| 425 | classes: integrator: carry: "same-class": true |
| 426 | classes: sigverify: carry: "same-class": true |
| 427 | classes: "identity-compiler": { |
| 428 | paths: "identity/**": true |
| 429 | paths: "schema/identity.cue": true |
| 430 | carry: "same-class": true |
| 431 | } |
| 432 | |
| 433 | // The policy decides what every change requires, so an approval of a |
| 434 | // change to it carries across no landing at all: exact. That is this |
| 435 | // layer, the pointer to the owning valley, and the schema a policy is |
| 436 | // written in. The example policies are fixtures and stay same-paths. Like |
| 437 | // identity-compiler, this class requires nothing: the policy class |
| 438 | // requires the checks of its paths. |
| 439 | // |
| 440 | // This tree holds no registry, grant or secret data of its own. The |
| 441 | // registries, grants and keys under examples/ and attest/conformance/ |
| 442 | // are test fixtures, and the instance's registry is in its instance |
| 443 | // repository. So nothing else here is exact. |
| 444 | classes: "policy-authority": { |
| 445 | paths: "policy/**": true |
| 446 | paths: "schema/verification.cue": true |
| 447 | carry: exact: true |
| 448 | } |
| 449 | |
| 450 | // The restacker's cap is the schema's default of 64 automatic versions |
| 451 | // per change. |
| 452 | } |
| 453 | |
| 454 | // What no class above covers falls to the floor's `unclassified` rule and |
| 455 | // requires prose-format alone. That is the research artefacts under research/, |
| 456 | // the GitHub mirror's workflow under .github/, and editor settings: files |
| 457 | // no program here reads. |