gunk-dev/the-valley

dcr-f41f718-declared-verification-policy.md

source342d77d65a25main's published tip history
13.1 KiB · Rendered
1---
2type: decision
3id: dcr-f41f718
4status: proposed
5title: Verification policy is a declared document — where it lives is the fork to resolve
6created: 2026-07-31
7source: cosmo-readiness design pass, 2026-07-31
8---
9
10# Declared verification policy
11
12Verification policy — the mapping from path classes to required checks — becomes a declared CUE
13document. This node proposes that, and states the one fork it does not resolve: whether the document
14lives in the host declaration, in the project's own repository, or split across both. A concrete
15draft schema accompanies the proposal ([schema/verification.cue](../../schema/verification.cue) and
16the sample at [examples/verification-policy.cue](../../examples/verification-policy.cue)) so the
17shape can be read rather than imagined.
18
19The design this gives a home to is already written down. [[ida-1ec03b1]]
20([ida-1ec03b1-path-scoped-verification-policy.md](../ideas/ida-1ec03b1-path-scoped-verification-policy.md))
21establishes that required checks are derived from the actual tree diff and never from a
22contributor's claim, that `.the-valley/**` takes signature plus knowledge lint while code takes the
23full suite and a mixed diff takes the max, and — the sentence this node acts on — that the policy
24itself is data, so it is a CUE document versioned in-repo. What is missing is the schema and the
25answer to _in which repo_.
26
27## Why this is needed now
28
29cosmo gates every change through GitHub Actions. Its `.github/workflows/ci.yml` runs `nixfmt --check`
30and a `nix build` matrix over classic-laddie, makers-nix and johnny-walker, and branch protection
31makes that gate the condition of merging. S1 direct-push mode has no pull request object, so
32migrating cosmo to a valley host does not weaken that gate — it deletes it. The repository that
33builds five machines would land changes with nothing checking them, and nothing on the valley host
34runs a check today. Declared verification policy is the piece that has to exist before cosmo can be
35hosted here. The wider readiness picture is tracked separately as the cosmo-readiness outcome node,
36in flight on branch `oc/cosmo-readiness`.
37
38## The fork: where the policy document lives
39
40### Option A — in the host declaration
41
42A `verification` field on `#Project` in [schema/valley.cue](../../schema/valley.cue), carrying the
43path classes and required checks. The host knows what each project it serves must pass.
44
45Changing policy means changing the host declaration, which means a host deploy. No contributor to a
46project can change that project's checks; only whoever owns the host's declaration can. A fresh clone
47knows nothing on its own — clone the project and there is no way to say what its changes must pass
48without asking a host. A project served by two hosts has two independent declarations, free to
49diverge silently, and neither host is wrong. An enforcement point on the host has the policy in hand
50before a push arrives, so a `pre-receive` hook could read it with no access to the pushed tree at
51all, and the integrator could read it the same way.
52
53The cost is the one that matters: policy is not versioned with the code it gates. A change that adds
54a check and the code needing that check cannot land together — they land in two repositories, in an
55order nothing enforces.
56
57### Option B — in the project's own repository
58
59A versioned CUE document in the project's tree. This is the plainer reading of [[ida-1ec03b1]]'s
60"versioned in-repo", and it is the direction [[ida-3e87f5c]]
61([ida-3e87f5c-self-describing-projects.md](../ideas/ida-3e87f5c-self-describing-projects.md))
62already adopted: a project's declaration travels in its store, and host config shrinks toward a
63serving list.
64
65Anyone who can land a change in the project can change its policy, and that change goes through the
66policy in force before it. A fresh clone knows everything: the policy document plus the repository's
67own checks say exactly what a change must pass, offline, with no host contacted. A project served by
68two hosts means the same thing on both, by construction, because both read the same file out of the
69same tree. Checks travel with the code that needs them, so adding a check and the code it covers is
70one commit.
71
72The enforcement question is sharper here and is worth stating plainly. At push time an in-repo policy
73lives in the tree being pushed, which is to say it is supplied by the change being gated; a
74`pre-receive` hook reading it would let a change weaken its own gate. The integrator does not have
75that problem, because it already holds both trees and can read the policy at the target ref's tip —
76the policy that is already integrated. Weakening then takes two landings: one that changes the
77policy under the old policy, and then the change that wanted the weakening. That is the right shape,
78and it is another reason integration-time enforcement beats push-time enforcement, consistent with
79the one structural invariant in [contribute.md](../../design/contribute.md).
80
81What Option B alone cannot do is let a host insist. A project whose policy document goes empty — or
82never had one — is served exactly as before, and nothing notices. For cosmo that is the whole
83problem restated: a gate a project can remove by editing its own repository is weaker than the branch
84protection it replaces.
85
86### Option C — split
87
88The project declares which checks apply to which paths. The host declares that verification is
89required for that project, and nothing about its content.
90
91This gives each side the half it can actually hold. The project owns the content of its checks, so
92they travel with the code, a fresh clone is self-sufficient, and two hosts agree. The host owns
93whether the gate exists at all, so a project cannot disable its own gate by landing a commit, and a
94host can refuse to serve a project whose policy has gone missing. The host-side field is readable
95before any tree is fetched, which is what makes that refusal cheap.
96
97The risk is drift in the other direction: a host-side field that grows from "verified" into "verified
98against these checks" is Option A wearing Option C's clothes. The field has to stay one declaration
99of requirement, not a second copy of the policy.
100
101## Recommendation
102
103Option C, with essentially all of the weight in the project.
104
105The project-side document is the substance, and it is what the draft schema ships. The host-side half
106is one optional block — enabled or not, plus the source it reads policy from — sketched in the draft
107as `#ProjectVerification` and deliberately **not** applied to `schema/valley.cue`. It is not applied
108because no enforcement point reads it yet, and a host option the host cannot act on misrepresents the
109boundary; the same reasoning kept per-project access out of both CUE and Nix in [[dcr-0f5d9b1]]
110([dcr-0f5d9b1-cue-config-host-module.md](./dcr-0f5d9b1-cue-config-host-module.md)).
111
112Two consequences follow from the recommendation and should be read as part of it. Enforcement belongs
113to the integrator, not to a `pre-receive` hook, so declared policy is inert data until Phase 3
114([roadmap.md](../../design/roadmap.md)); Phase 2 is where a contributor can first produce the
115evidence a policy asks for. And the checks a policy names are ordinary flake checks in the reference
116implementation, so a project that already has checks has most of a policy — the document says which
117ones apply where, not what a check is.
118
119## What the draft schema commits to
120
121The draft is small on purpose, and three choices in it are load-bearing.
122
123Class matching is a set operation, never first-match. A change's required checks are the union of
124`requires` over every class that at least one changed path matches. Classes may overlap deliberately
125— a knowledge node is both knowledge and prose — and the union is the entirety of [[ida-1ec03b1]]'s
126"mixed takes the max" rule. There is no separate mixed case, and no ordering to get wrong.
127
128A path matching no class is answered explicitly, by a required `unclassified` field. The failure this
129document must never have is a path that quietly requires nothing, so the policy has to state what an
130uncovered path costs rather than defaulting to silence.
131
132The signature is deliberately absent. [[ida-1ec03b1]] lists it alongside the knowledge lint because
133it is enumerating what a knowledge-only diff must satisfy, but the signature is required of every
134change by the structural invariant and the integrator, whatever paths the diff touches. It is not
135path-scoped, so it is not policy.
136
137The draft's own rejections are pinned by running `cue vet`, not by inspection: an unknown check name,
138a stray top-level field, a host-side concern written into a policy, an absolute or `..` path pattern,
139an unimplemented runner, an unknown field inside a class, and a malformed name all fail vet with an
140error naming the field. Those rejections are not yet wired into a flake check, because the draft is
141deliberately unwired.
142
143## The staged path: qinling first, cosmo second
144
145Every feature built for cosmo readiness is exercised live on the gunk-dev instance, on a project
146already hosted there, before cosmo depends on it. The projects on classic-laddie today are the-valley
147and qinling, and both are markdown-only. So the first exercisable class is knowledge and prose — the
148formatter-idempotence check this repo already ships as a flake check, plus the frontmatter and
149reference-integrity linting [[ida-1ec03b1]] describes — and not the `nix build` class cosmo
150eventually needs.
151
152### The smallest thing that could be turned on
153
154Four pieces, none of which is an enforcement point:
155
1561. qinling gains a policy document — the sample at
157 [examples/verification-policy.cue](../../examples/verification-policy.cue) is written as exactly
158 that policy: a `knowledge` class over `.the-valley/**` requiring a knowledge lint, a `prose` class
159 over `**/*.md` requiring the prose format check, and both required for a path outside either.
1602. `knowledge-lint` is built as a flake check in qinling: frontmatter vetted against a CUE `#Node`
161 schema, and reference integrity — `[[wiki-links]]`, `blocked_by` ids, and relative links all
162 resolve. `prose-format` already exists in this repo and is copied or shared.
1633. A read-only deriver: given two commits, list the changed paths, match them against the policy, and
164 print the required check names. It reports; it blocks nothing.
1654. The two checks are run against the trees the deriver named.
166
167### What observing it succeed looks like
168
169The standard is verified by looking, not by reviewing configuration. Reading the policy file and
170agreeing that it says the right thing is not the exercise.
171
172- A commit that actually landed in qinling touching a knowledge node is fed to the deriver, and it
173 prints exactly `knowledge-lint` and `prose-format` — the union of two overlapping classes, observed
174 rather than asserted.
175- A commit touching only `README.md` prints exactly `prose-format`. The knowledge lint's absence is
176 the observation; a policy that over-requires is as wrong as one that under-requires, and only the
177 second failure is loud.
178- A node's frontmatter is deliberately broken on a scratch branch. `knowledge-lint` fails against
179 that tree, and the failure names the file and the field.
180- A file no class covers — a shell script in a markdown-only repository — makes the deriver print the
181 `unclassified` set. The hole announces itself instead of being found later.
182
183### What cosmo additionally requires
184
185Naming these keeps the qinling exercise from being mistaken for cosmo readiness.
186
187- A `format` class over `**/*.nix` requiring `nixfmt --check`, and a build class requiring the
188 five-machine build matrix. The schema expresses both today; nothing else about them is ready.
189- An answer to check latency. Five machines' worth of `nix build` is not something a contributor's
190 machine finishes quickly, and neither placement of the policy document changes that. It is a real
191 open question this node does not close.
192- The host-side half, actually implemented. cosmo is precisely the case where a project must not be
193 able to remove its own gate, so the field sketched in the draft has to exist and be read by
194 something.
195- An enforcement point — Phase 3's integrator, or a deliberate interim. Until then this machinery
196 observes and reports, and **cosmo must not migrate onto an observation**. That is the difference
197 between qinling exercising the feature and cosmo depending on it.
198
199## Status
200
201Proposed. The fork above is resolved at hand-review, not by this branch. The draft schema is a draft:
202it is not referenced by `schema/valley.cue`, not covered by the flake's `cue-vet` check, and not read
203by [nix/valley-host.nix](../../nix/valley-host.nix).
204
205## Related
206
207- The design this implements: [[ida-1ec03b1]]
208 ([ida-1ec03b1-path-scoped-verification-policy.md](../ideas/ida-1ec03b1-path-scoped-verification-policy.md))
209- The direction that argues for the project-side placement: [[ida-3e87f5c]]
210 ([ida-3e87f5c-self-describing-projects.md](../ideas/ida-3e87f5c-self-describing-projects.md))
211- The store the policy travels in: [[dcr-5da1f36]]
212 ([dcr-5da1f36-project-is-repo.md](./dcr-5da1f36-project-is-repo.md))
213- Why the host schema stays free of options the host cannot act on: [[dcr-0f5d9b1]]
214 ([dcr-0f5d9b1-cue-config-host-module.md](./dcr-0f5d9b1-cue-config-host-module.md))