| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-f41f718 |
| 4 | status: proposed |
| 5 | title: Verification policy is a declared document — where it lives is the fork to resolve |
| 6 | created: 2026-07-31 |
| 7 | source: cosmo-readiness design pass, 2026-07-31 |
| 8 | --- |
| 9 | |
| 10 | # Declared verification policy |
| 11 | |
| 12 | Verification policy — the mapping from path classes to required checks — becomes a declared CUE |
| 13 | document. This node proposes that, and states the one fork it does not resolve: whether the document |
| 14 | lives in the host declaration, in the project's own repository, or split across both. A concrete |
| 15 | draft schema accompanies the proposal ([schema/verification.cue](../../schema/verification.cue) and |
| 16 | the sample at [examples/verification-policy.cue](../../examples/verification-policy.cue)) so the |
| 17 | shape can be read rather than imagined. |
| 18 | |
| 19 | The 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)) |
| 21 | establishes that required checks are derived from the actual tree diff and never from a |
| 22 | contributor's claim, that `.the-valley/**` takes signature plus knowledge lint while code takes the |
| 23 | full suite and a mixed diff takes the max, and — the sentence this node acts on — that the policy |
| 24 | itself is data, so it is a CUE document versioned in-repo. What is missing is the schema and the |
| 25 | answer to _in which repo_. |
| 26 | |
| 27 | ## Why this is needed now |
| 28 | |
| 29 | cosmo 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 |
| 31 | branch protection makes that gate the condition of merging. S1 direct-push mode has no pull request |
| 32 | object, so migrating cosmo to a valley host does not weaken that gate — it deletes it. The |
| 33 | repository that builds five machines would land changes with nothing checking them, and nothing on |
| 34 | the valley host runs a check today. Declared verification policy is the piece that has to exist |
| 35 | before cosmo can be hosted here. The wider readiness picture is tracked separately as the |
| 36 | cosmo-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 | |
| 42 | A `verification` field on `#Project` in [schema/valley.cue](../../schema/valley.cue), carrying the |
| 43 | path classes and required checks. The host knows what each project it serves must pass. |
| 44 | |
| 45 | Changing policy means changing the host declaration, which means a host deploy. No contributor to a |
| 46 | project can change that project's checks; only whoever owns the host's declaration can. A fresh |
| 47 | clone knows nothing on its own — clone the project and there is no way to say what its changes must |
| 48 | pass without asking a host. A project served by two hosts has two independent declarations, free to |
| 49 | diverge silently, and neither host is wrong. An enforcement point on the host has the policy in hand |
| 50 | before a push arrives, so a `pre-receive` hook could read it with no access to the pushed tree at |
| 51 | all, and the integrator could read it the same way. |
| 52 | |
| 53 | The cost is the one that matters: policy is not versioned with the code it gates. A change that adds |
| 54 | a check and the code needing that check cannot land together — they land in two repositories, in an |
| 55 | order nothing enforces. |
| 56 | |
| 57 | ### Option B — in the project's own repository |
| 58 | |
| 59 | A 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)) |
| 62 | already adopted: a project's declaration travels in its store, and host config shrinks toward a |
| 63 | serving list. |
| 64 | |
| 65 | Anyone who can land a change in the project can change its policy, and that change goes through the |
| 66 | policy in force before it. A fresh clone knows everything: the policy document plus the repository's |
| 67 | own checks say exactly what a change must pass, offline, with no host contacted. A project served by |
| 68 | two hosts means the same thing on both, by construction, because both read the same file out of the |
| 69 | same tree. Checks travel with the code that needs them, so adding a check and the code it covers is |
| 70 | one commit. |
| 71 | |
| 72 | The enforcement question is sharper here and is worth stating plainly. At push time an in-repo |
| 73 | policy 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 |
| 75 | that problem, because it already holds both trees and can read the policy at the target ref's tip — |
| 76 | the policy that is already integrated. Weakening then takes two landings: one that changes the |
| 77 | policy under the old policy, and then the change that wanted the weakening. That is the right shape, |
| 78 | and it is another reason integration-time enforcement beats push-time enforcement, consistent with |
| 79 | the one structural invariant in [contribute.md](../../design/contribute.md). |
| 80 | |
| 81 | What Option B alone cannot do is let a host insist. A project whose policy document goes empty — or |
| 82 | never had one — is served exactly as before, and nothing notices. For cosmo that is the whole |
| 83 | problem restated: a gate a project can remove by editing its own repository is weaker than the |
| 84 | branch protection it replaces. |
| 85 | |
| 86 | ### Option C — split |
| 87 | |
| 88 | The project declares which checks apply to which paths. The host declares that verification is |
| 89 | required for that project, and nothing about its content. |
| 90 | |
| 91 | This gives each side the half it can actually hold. The project owns the content of its checks, so |
| 92 | they travel with the code, a fresh clone is self-sufficient, and two hosts agree. The host owns |
| 93 | whether the gate exists at all, so a project cannot disable its own gate by landing a commit, and a |
| 94 | host can refuse to serve a project whose policy has gone missing. The host-side field is readable |
| 95 | before any tree is fetched, which is what makes that refusal cheap. |
| 96 | |
| 97 | The 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 |
| 99 | declaration of requirement, not a second copy of the policy. |
| 100 | |
| 101 | ## Recommendation |
| 102 | |
| 103 | Option C, with essentially all of the weight in the project. |
| 104 | |
| 105 | The project-side document is the substance, and it is what the draft schema ships. The host-side |
| 106 | half is one optional block — enabled or not, plus the source it reads policy from — sketched in the |
| 107 | draft as `#ProjectVerification` and deliberately **not** applied to `schema/valley.cue`. It is not |
| 108 | applied because no enforcement point reads it yet, and a host option the host cannot act on |
| 109 | misrepresents 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 | |
| 112 | Two consequences follow from the recommendation and should be read as part of it. Enforcement |
| 113 | belongs to the integrator, not to a `pre-receive` hook, so declared policy is inert data until Phase |
| 114 | 3 ([roadmap.md](../../design/roadmap.md)); Phase 2 is where a contributor can first produce the |
| 115 | evidence a policy asks for. And the checks a policy names are ordinary flake checks in the reference |
| 116 | implementation, so a project that already has checks has most of a policy — the document says which |
| 117 | ones apply where, not what a check is. |
| 118 | |
| 119 | ## What the draft schema commits to |
| 120 | |
| 121 | The draft is small on purpose, and three choices in it are load-bearing. |
| 122 | |
| 123 | Class 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 | |
| 128 | A path matching no class is answered explicitly, by a required `unclassified` field. The failure |
| 129 | this document must never have is a path that quietly requires nothing, so the policy has to state |
| 130 | what an uncovered path costs rather than defaulting to silence. |
| 131 | |
| 132 | The signature is deliberately absent. [[ida-1ec03b1]] lists it alongside the knowledge lint because |
| 133 | it is enumerating what a knowledge-only diff must satisfy, but the signature is required of every |
| 134 | change by the structural invariant and the integrator, whatever paths the diff touches. It is not |
| 135 | path-scoped, so it is not policy. |
| 136 | |
| 137 | The draft's own rejections are pinned by running `cue vet`, not by inspection: an unknown check |
| 138 | name, a stray top-level field, a host-side concern written into a policy, an absolute or `..` path |
| 139 | pattern, an unimplemented runner, an unknown field inside a class, and a malformed name all fail vet |
| 140 | with an error naming the field. Those rejections are not yet wired into a flake check, because the |
| 141 | draft is deliberately unwired. |
| 142 | |
| 143 | ## The staged path: qinling first, cosmo second |
| 144 | |
| 145 | Every feature built for cosmo readiness is exercised live on the gunk-dev instance, on a project |
| 146 | already hosted there, before cosmo depends on it. The projects on classic-laddie today are |
| 147 | the-valley and qinling, and both are markdown-only. So the first exercisable class is knowledge and |
| 148 | prose — the formatter-idempotence check this repo already ships as a flake check, plus the |
| 149 | frontmatter and reference-integrity linting [[ida-1ec03b1]] describes — and not the `nix build` |
| 150 | class cosmo eventually needs. |
| 151 | |
| 152 | ### The smallest thing that could be turned on |
| 153 | |
| 154 | Four pieces, none of which is an enforcement point: |
| 155 | |
| 156 | 1. 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. |
| 161 | 2. `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. |
| 164 | 3. 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. |
| 166 | 4. The two checks are run against the trees the deriver named. |
| 167 | |
| 168 | ### What observing it succeed looks like |
| 169 | |
| 170 | The standard is verified by looking, not by reviewing configuration. Reading the policy file and |
| 171 | agreeing 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 | |
| 186 | Naming 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 | |
| 202 | Proposed. The fork above is resolved at hand-review, not by this branch. The draft schema is a |
| 203 | draft: it is not referenced by `schema/valley.cue`, not covered by the flake's `cue-vet` check, and |
| 204 | not 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)) |