gunk-dev/the-valley

checks.nix

sourceaf38e23853bamain's published tip history
9.0 KiB
1# What is tested, and where each test's logic lives.
2#
3# One file per subject, each returning the checks for it. A check's shell
4# body is never here: it is a script under checks/, and a check definition
5# is only what builds it, what it is given, and why it exists.
6#
7# hosts.nix the eval-only host declarations the module checks share
8# host-module.nix module-eval — what the NixOS modules render from a
9# declaration, and what they must refuse: the host
10# module and the web publisher's beside it
11# schema.nix cue-vet, attest-schema, identity-schema — the schemas
12# against the examples they accept and the ones they
13# must reject
14# knowledge.nix knowledge-lint-consumer, knowledge-lint-rejects,
15# prose-format — the lint's reusable and rejection
16# forms, and the prose
17# knot.nix knot-unit, knot-agree — the plan graph's module, and
18# its validator held to the schema and the lint
19# delta.nix delta-unit — valley-delta-v1, its conformance vectors,
20# and the trees it reads and refuses
21# derive.nix derive-unit — the Go deriver of required checks, held
22# to bin/valley's
23# review.nix review-unit — review records, their binding to the
24# version judged, and their append-only history
25# attest.nix attest-unit, attest-conformance, attest-e2e — the
26# helper's unit tests, the written form as a fixed
27# contract, and the helper driven end to end
28# integrator.nix integrator-unit, integrator-e2e — the verdict rules,
29# and the controller over real repositories
30# restack.nix restack-unit, restack-e2e — the restacker's planner
31# and its write passes, over repositories wired with
32# the rendered hook
33# signers.nix signers-e2e — the signers the host publishes, read by
34# a fresh client to verify the real integrator's landing
35# hooks.nix valleyhook-unit, note-unit, change-unit,
36# exactjson-unit, mirror-e2e, bus-e2e, protect-e2e,
37# knots-e2e, init-e2e — the hooks the module renders,
38# run against real git, the formats they read, and the
39# init script that wires them
40# approval.nix approval-unit — approval statements, their signing
41# and verification, and the PIV session signer
42# identity.nix identity-unit, identity-e2e — the compiler's unit
43# tests, and the registry compiler over a real
44# instance repository, against the hand-written
45# artifacts it replaces, and the hook reading its grants
46# sigverify.nix sigverify-unit, sigverify-e2e — the security-key
47# signature verifier against real ssh-keygen, real git
48# and OpenSSH's software authenticator
49# web.nix web-unit, web-server-unit, web-reader-state-crash,
50# web-receiver-unit, web-image, readaccess-unit — the
51# web UI's export contract (projection, manifest, upload
52# checks, and receiver state directory), the valley-web
53# server and its browser state, that state's
54# transactions killed and failed at each step, the
55# valley-web-receive receiver, the edge container image,
56# and the two read-access consents and coverage report
57# web-reader-browser-e2e.nix
58# web-reader-browser-e2e — the reader page in headless
59# Chromium in the build sandbox, behind a TLS proxy
60# web-push-e2e.nix web-push-e2e — the push path end to end over the
61# shipped publisher, receiver, valley-web and CLI,
62# with real git
63# cli.nix valley-cli, review-notes, policy-deriver,
64# own-policy, valley-request, rebase-unit,
65# valley-go-unit, valley-status, valley-ready,
66# valley-changes, valley-knot, valley-plan,
67# selfupdate-unit, valley-self-update,
68# valley-darwin-eval — bin/valley, its Go verbs, the
69# rebase engine, self-update and its home-manager
70# module, the-valley's own policy, and the CLI's
71# package evaluated for Darwin
72# ssh-e2e.nix ssh-e2e — the push boundary over a real sshd in a
73# NixOS machine, and the request grant's handoff
74# publish-e2e.nix publish-e2e — an integrator landing reaching the push
75# mirror and the bus, in a NixOS machine running the
76# real controller
77# worker-e2e.nix worker-e2e — the build slice and the check worker in a
78# NixOS machine: the worker's key, its enrollment and
79# its evidence on origin, and the slice's caps on its
80# builds and on builds that are not its own
81# restack-host-e2e.nix
82# restack-host-e2e — the restacker's service in a NixOS
83# machine: its controller restacking a ready change
84# over sshd as its own principal, its Unix user's
85# isolation, and what its key can push
86# web-publisher-e2e.nix
87# web-publisher-e2e — the web publisher's sandbox in
88# a NixOS machine: the unit the module renders, with a
89# probe in place of the publisher, and the read links'
90# wrapper run as root, delivering through the policy
91# unit to a receiver
92#
93# Fixtures live with the thing they are fixtures of: host declarations,
94# attestations, events, graphs and policies under examples/, attestation
95# vectors under attest/, delta vectors under delta/, the integrator's
96# scenarios under integrator/e2e/.
97#
98# A check is given only the files it reads, so an edit to any other file
99# leaves its derivation, and the evidence for it, unchanged. A source path
100# names one file or directory, and lib.fileset narrows a directory to the
101# part of it a check reads. The sandbox holds a check to what it is given:
102# a file it reads and was not given fails it. nix/tools/drv-churn.sh
103# measures which checks an edit changes.
104{
105 pkgs,
106 lib,
107 self,
108 system,
109 packages,
110}:
111let
112 hosts = import ./checks/hosts.nix {
113 inherit
114 pkgs
115 lib
116 self
117 ;
118 };
119 # The same hosts over stand-ins for the programs they run, for the checks
120 # that read what the module renders and run none of the programs.
121 stubbedHosts = import ./checks/hosts.nix {
122 inherit
123 pkgs
124 lib
125 self
126 ;
127 stubbed = true;
128 };
129 # The part of a directory a check reads: the paths given, each in its
130 # place under root.
131 partOf =
132 root: paths:
133 lib.fileset.toSource {
134 inherit root;
135 fileset = lib.fileset.unions paths;
136 };
137 # integrator-e2e's stand-ins for nix and nix-store, without its
138 # scenarios. attest-e2e, valley-request, signers-e2e and restack-e2e run
139 # through these two and read nothing else of integrator/e2e/.
140 nixStandIns = partOf ../integrator/e2e [
141 ../integrator/e2e/nix
142 ../integrator/e2e/nix-store
143 ];
144 # The CLI a NixOS test machine installs. It is the real installed
145 # package, built as if nix knew no commit, so its version is always
146 # 0.1.0-unknown. packages.valley's version names the commit the flake is
147 # built from. A machine that installed it would get a new derivation, and
148 # boot again, for every new commit, even one with the same tree. attest
149 # exports a tree with no commit, so it gives both packages the same
150 # derivation. valley-cli and valley-self-update test the version that
151 # names the commit.
152 machineValley =
153 (import ./packages.nix {
154 inherit pkgs lib;
155 rev = null;
156 }).valley;
157 args = {
158 inherit
159 pkgs
160 lib
161 self
162 system
163 packages
164 hosts
165 stubbedHosts
166 partOf
167 nixStandIns
168 machineValley
169 ;
170 };
171in
172import ./checks/host-module.nix args
173// import ./checks/schema.nix args
174// import ./checks/knowledge.nix args
175// import ./checks/knot.nix args
176// import ./checks/delta.nix args
177// import ./checks/derive.nix args
178// import ./checks/review.nix args
179// import ./checks/attest.nix args
180// import ./checks/integrator.nix args
181// import ./checks/restack.nix args
182// import ./checks/signers.nix args
183// import ./checks/hooks.nix args
184// import ./checks/approval.nix args
185// import ./checks/identity.nix args
186// import ./checks/sigverify.nix args
187// import ./checks/web.nix args
188// import ./checks/web-push-e2e.nix args
189// import ./checks/web-reader-browser-e2e.nix args
190// import ./checks/cli.nix args
191// import ./checks/ssh-e2e.nix args
192// import ./checks/publish-e2e.nix args
193// import ./checks/worker-e2e.nix args
194// import ./checks/telemetry.nix args
195// import ./checks/restack-host-e2e.nix args
196// import ./checks/web-publisher-e2e.nix args