gunk-dev/the-valley

dcr-f41f718-declared-verification-policy.md

sourcecb6c77e7517bmain'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
30`nixfmt --check` and a `nix build` matrix over classic-laddie, makers-nix and johnny-walker, and
31branch protection makes that gate the condition of merging. S1 direct-push mode has no pull request
32object, so migrating cosmo to a valley host does not weaken that gate — it deletes it. The
33repository that builds five machines would land changes with nothing checking them, and nothing on
34the valley host runs a check today. Declared verification policy is the piece that has to exist
35before cosmo can be hosted here. The wider readiness picture is tracked separately as the
36cosmo-readiness outcome node, in 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
47clone knows nothing on its own — clone the project and there is no way to say what its changes must
48pass without 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
73policy lives 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
84branch protection 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
98"verified against these checks" is Option A wearing Option C's clothes. The field has to stay one
99declaration of 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
106half is one optional block — enabled or not, plus the source it reads policy from — sketched in the
107draft as `#ProjectVerification` and deliberately **not** applied to `schema/valley.cue`. It is not
108applied because no enforcement point reads it yet, and a host option the host cannot act on
109misrepresents the boundary; the same reasoning kept per-project access out of both CUE and Nix in
110[[dcr-0f5d9b1]] ([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
113belongs to the integrator, not to a `pre-receive` hook, so declared policy is inert data until Phase
1143 ([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
129this document must never have is a path that quietly requires nothing, so the policy has to state
130what an uncovered 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
138name, a stray top-level field, a host-side concern written into a policy, an absolute or `..` path
139pattern, an unimplemented runner, an unknown field inside a class, and a malformed name all fail vet
140with an error naming the field. Those rejections are not yet wired into a flake check, because the
141draft is deliberately 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
147the-valley and qinling, and both are markdown-only. So the first exercisable class is knowledge and
148prose — the formatter-idempotence check this repo already ships as a flake check, plus the
149frontmatter and reference-integrity linting [[ida-1ec03b1]] describes — and not the `nix build`
150class cosmo eventually 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`
159 class over `**/*.md` requiring the prose format check, and both required for a path outside
160 either.
1612. `knowledge-lint` is built as a flake check in qinling: frontmatter vetted against a CUE `#Node`
162 schema, and reference integrity — `[[wiki-links]]`, `blocked_by` ids, and relative links all
163 resolve. `prose-format` already exists in this repo and is copied or shared.
1643. A read-only deriver: given two commits, list the changed paths, match them against the policy,
165 and print the required check names. It reports; it blocks nothing.
1664. The two checks are run against the trees the deriver named.
167
168### What observing it succeed looks like
169
170The standard is verified by looking, not by reviewing configuration. Reading the policy file and
171agreeing that it says the right thing is not the exercise.
172
173- A commit that actually landed in qinling touching a knowledge node is fed to the deriver, and it
174 prints exactly `knowledge-lint` and `prose-format` — the union of two overlapping classes,
175 observed rather than asserted.
176- A commit touching only `README.md` prints exactly `prose-format`. The knowledge lint's absence is
177 the observation; a policy that over-requires is as wrong as one that under-requires, and only the
178 second failure is loud.
179- A node's frontmatter is deliberately broken on a scratch branch. `knowledge-lint` fails against
180 that tree, and the failure names the file and the field.
181- A file no class covers — a shell script in a markdown-only repository — makes the deriver print
182 the `unclassified` set. The hole announces itself instead of being found later.
183
184### What cosmo additionally requires
185
186Naming these keeps the qinling exercise from being mistaken for cosmo readiness.
187
188- A `format` class over `**/*.nix` requiring `nixfmt --check`, and a build class requiring the
189 five-machine build matrix. The schema expresses both today; nothing else about them is ready.
190- An answer to check latency. Five machines' worth of `nix build` is not something a contributor's
191 machine finishes quickly, and neither placement of the policy document changes that. It is a real
192 open question this node does not close.
193- The host-side half, actually implemented. cosmo is precisely the case where a project must not be
194 able to remove its own gate, so the field sketched in the draft has to exist and be read by
195 something.
196- An enforcement point — Phase 3's integrator, or a deliberate interim. Until then this machinery
197 observes and reports, and **cosmo must not migrate onto an observation**. That is the difference
198 between qinling exercising the feature and cosmo depending on it.
199
200## Status
201
202Proposed. The fork above is resolved at hand-review, not by this branch. The draft schema is a
203draft: it is not referenced by `schema/valley.cue`, not covered by the flake's `cue-vet` check, and
204not read by [nix/valley-host.nix](../../nix/valley-host.nix).
205
206## Related
207
208- The design this implements: [[ida-1ec03b1]]
209 ([ida-1ec03b1-path-scoped-verification-policy.md](../ideas/ida-1ec03b1-path-scoped-verification-policy.md))
210- The direction that argues for the project-side placement: [[ida-3e87f5c]]
211 ([ida-3e87f5c-self-describing-projects.md](../ideas/ida-3e87f5c-self-describing-projects.md))
212- The store the policy travels in: [[dcr-5da1f36]]
213 ([dcr-5da1f36-project-is-repo.md](./dcr-5da1f36-project-is-repo.md))
214- Why the host schema stays free of options the host cannot act on: [[dcr-0f5d9b1]]
215 ([dcr-0f5d9b1-cue-config-host-module.md](./dcr-0f5d9b1-cue-config-host-module.md))