| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-f41f718 |
| 4 | status: decided |
| 5 | title: Verification policy is a declared document, composed from an instance floor and a project layer |
| 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 — is a declared CUE document. |
| 13 | It is composed from two documents, not one. The group's instance repository carries a mandatory |
| 14 | floor and a set of project-type templates; the project's own repository carries everything above the |
| 15 | floor. The effective policy is the unification of the two. The schema is |
| 16 | [schema/verification.cue](../../schema/verification.cue), with a worked two-document example at |
| 17 | [examples/verification-instance.cue](../../examples/verification-instance.cue) and |
| 18 | [examples/verification-project.cue](../../examples/verification-project.cue), so the shape can be |
| 19 | read rather than imagined. |
| 20 | |
| 21 | The design this gives a home to is already written down. [[ida-1ec03b1]] |
| 22 | ([ida-1ec03b1-path-scoped-verification-policy.md](../ideas/ida-1ec03b1-path-scoped-verification-policy.md)) |
| 23 | establishes that required checks are derived from the actual tree diff and never from a |
| 24 | contributor's claim, that `.the-valley/**` takes signature plus knowledge lint while code takes the |
| 25 | full suite and a mixed diff takes the max, and — the sentence this node acts on — that the policy |
| 26 | itself is data, so it is a CUE document versioned in-repo. This node supplies the schema and the |
| 27 | answer to _in which repo_. |
| 28 | |
| 29 | ## Why this is needed now |
| 30 | |
| 31 | cosmo gates every change through GitHub Actions. Its `.github/workflows/ci.yml` runs |
| 32 | `nixfmt --check` and a `nix build` matrix over classic-laddie, makers-nix and johnny-walker, and |
| 33 | branch protection makes that gate the condition of merging. S1 direct-push mode has no pull request |
| 34 | object, so migrating cosmo to a valley instance does not weaken that gate — it deletes it. The |
| 35 | repository that builds five machines would land changes with nothing checking them, and nothing on |
| 36 | the instance runs a check today. Declared verification policy is the piece that has to exist before |
| 37 | cosmo can be hosted here. The wider readiness picture is tracked separately as the cosmo-readiness |
| 38 | outcome node, in flight on branch `oc/cosmo-readiness`. |
| 39 | |
| 40 | ## The two layers |
| 41 | |
| 42 | Both layers are the same schema and the same kind of document: a CUE document versioned in the |
| 43 | repository it belongs to. The weight sits in the project layer, and the floor is deliberately small. |
| 44 | |
| 45 | The **instance layer** is the group's policy. A group has exactly one instance — that binding is |
| 46 | settled in [[ida-8482624]] |
| 47 | ([ida-8482624-federation-groups.md](../ideas/ida-8482624-federation-groups.md)) and in |
| 48 | [architecture.md § federation](../../design/architecture.md#federation-the-group-is-the-unit) — so |
| 49 | the instance repository is the group's repository, and for the gunk-dev instance that is qinling. It |
| 50 | states the minimum: the checks no project in the group may decline, plus project-type templates that |
| 51 | give a project of a known type a sensible starting set. |
| 52 | |
| 53 | The **project layer** is the project's own policy, a versioned document in its own tree. It states |
| 54 | everything else: the classes the project cares about, the checks it adds, and the template defaults |
| 55 | it declines. |
| 56 | |
| 57 | The two compose by unification, which can only narrow, so the floor is a floor by construction: the |
| 58 | project layer can add to it and cannot subtract from it. Both layers say what; they differ only in |
| 59 | whether a project can answer back. That is what keeps the two halves from being two vocabularies to |
| 60 | learn, and what makes the composition a single `cue vet`. |
| 61 | |
| 62 | The discipline this asks for is keeping the floor minimal. The floor is the minimum a group is |
| 63 | willing to enforce on projects it has not read; a floor that keeps absorbing checks until it |
| 64 | describes every class of every project has stopped being a floor. |
| 65 | |
| 66 | Policy has no business at a lower layer than the instance. Group to instance is 1-to-1, but instance |
| 67 | to host deliberately is not: an instance is instantiable on a single machine and equally runnable as |
| 68 | a distributed system, with git hosting sharding across hosts and nothing in the architecture |
| 69 | assuming co-location. classic-laddie being the whole of the gunk-dev instance today is a fact about |
| 70 | deployment, not about the design. A policy field on a host would therefore be a policy field on _one |
| 71 | of several_ possible carriers of the same instance, free to diverge from its siblings with neither |
| 72 | one wrong. The host is not involved at any point, and [schema/valley.cue](../../schema/valley.cue) |
| 73 | carries nothing about verification. |
| 74 | |
| 75 | ## Mandatory versus overridable is one bit per check, in CUE's own semantics |
| 76 | |
| 77 | This is why CUE suits the model rather than merely carrying it. Unification can only narrow, so the |
| 78 | _form_ of a value decides whether a project can answer back, and the schema needs no flag it would |
| 79 | have to interpret. |
| 80 | |
| 81 | - A **concrete** constraint from the floor — a check required with the value `true` — cannot be |
| 82 | unset. A project supplying `false` conflicts, and `cue vet` fails naming the field. |
| 83 | - A **template default** — written as the disjunction `bool | *true` — is overridable. It reads as |
| 84 | `true` when nobody says otherwise, and a project supplying `false` unifies cleanly to `false`. |
| 85 | - **Open structs** mean a project may always add classes and checks, and can never remove the |
| 86 | floor's. |
| 87 | - **Project-type templates** are policy fragments a project selects by name and then narrows, so a |
| 88 | project that is an ordinary instance of its type works with very little configuration and can |
| 89 | still override the non-mandatory parts or define its own. |
| 90 | |
| 91 | ## Everything that composes is keyed, never a list |
| 92 | |
| 93 | CUE unifies lists positionally and requires equal length, so two lists that were written |
| 94 | independently simply conflict. Every part of the policy that has to compose across the two layers |
| 95 | therefore cannot be a list. |
| 96 | |
| 97 | The path classes are keyed by class name rather than held in a list of class values. A class's |
| 98 | required checks, the `unclassified` set, and a class's path patterns are all sets written as structs |
| 99 | from name to `bool` rather than lists of names. When both layers name the same class, it is one |
| 100 | class: its coverage and its requirements are the union of what each layer contributed, and nothing |
| 101 | either layer made concrete can be taken back. |
| 102 | |
| 103 | Keying a class's `paths` the same way is load-bearing and easy to miss. If coverage were a list, a |
| 104 | project could rewrite a floor class's patterns wholesale; keyed and concrete, a floor class's |
| 105 | coverage cannot be narrowed to a path the project never touches, which would otherwise escape the |
| 106 | floor everywhere else. |
| 107 | |
| 108 | ## Forcing comes from the floor's provenance, not from CUE |
| 109 | |
| 110 | Unification on its own forces nothing. A project that vendored a copy of the floor into its own tree |
| 111 | and edited the copy would unify perfectly well; the copy is simply not the floor. What makes a floor |
| 112 | a floor is where it is read from: the instance repository's integrated tip, never the project's |
| 113 | tree. |
| 114 | |
| 115 | Weakening the floor therefore takes two landings. Changing the floor is a change landing in the |
| 116 | instance repository, under that repository's own policy and its own integrator, and it is visible in |
| 117 | that repository's history — which is what [self-transparency.md](../../design/self-transparency.md) |
| 118 | asks of the system's own configuration. The schema cannot enforce this, because a schema cannot see |
| 119 | which file a field came from. The tool that composes a policy is what makes it true, and the schema |
| 120 | says so in its comments. |
| 121 | |
| 122 | ## The two halves resolve at different times |
| 123 | |
| 124 | The mandatory floor resolves at head. A floor a project could pin is not a floor: pinning it would |
| 125 | make every past floor permanently available as an alternative to the current one, and weakening |
| 126 | would take one landing again — the project's. |
| 127 | |
| 128 | Templates may be pinned. They are defaults, a project can already override them, and a stale default |
| 129 | costs nothing the project could not have written by hand. |
| 130 | |
| 131 | ## The document count is free; the enumeration is not |
| 132 | |
| 133 | Each layer is described above as one document. That is how the example is written, not something CUE |
| 134 | imposes. A CUE package unifies any number of files, and unification is commutative and associative, |
| 135 | so file boundaries carry no meaning and factoring a layer across several documents is semantically |
| 136 | free. Two floor documents may contribute mandatory checks to the same class and compose without |
| 137 | complaint. Two documents that disagree on the same check fail at vet time, and the error names both |
| 138 | files and both line numbers, so a silent last-write-wins is not possible. That is what makes |
| 139 | fragmenting policy safe rather than risky. |
| 140 | |
| 141 | The constraint that does exist is not the number of documents but who enumerates the set. A floor a |
| 142 | project can decline to load is not a floor, so floor documents are enumerated by the instance, while |
| 143 | template documents are selected by the project. That is the mandatory-versus-overridable distinction |
| 144 | above, expressed at document granularity instead of at field granularity. |
| 145 | |
| 146 | Collecting policy into a standard directory is the natural expression of it, because a CUE package |
| 147 | already works that way: the directory is the enumeration, so no manifest is needed and nothing has |
| 148 | to list which files count. One directory holds both layers, because CUE's definition-versus-field |
| 149 | distinction does the selection. A concrete field is floor and loads unconditionally; a project-type |
| 150 | template written as a definition is inert until a project embeds it. Whether a policy document is |
| 151 | mandatory or optional is therefore visible in the syntax of the file itself. This repository already |
| 152 | uses the same move: [.the-valley/README.md](../README.md) describes the knowledge graph as "a |
| 153 | directory convention, not a system", where listing is `ls` and search is `grep` and no indexer |
| 154 | exists. A policy directory is that convention applied again rather than a new mechanism. |
| 155 | |
| 156 | The obvious comparison is a workflow directory in a hosted forge, and it breaks in two places. |
| 157 | Workflow files are independent of one another; policy files unify. A new file in the floor directory |
| 158 | changes the effective policy of every project in the group. Contradictions fail loudly as above, but |
| 159 | silent addition is real and has no equivalent in the workflow-directory model. The second difference |
| 160 | matters more: a workflow directory has no floor. Anyone who can write it controls the checks |
| 161 | completely, which is precisely what this design denies a project. So the same convention is applied |
| 162 | twice with different authority — the floor directory in the instance repository, resolved at head, |
| 163 | and the project's own directory in its own tree. The drop-in property is safe only because of where |
| 164 | each directory lives. A project adding a document to its own directory can only narrow; a project |
| 165 | able to write the floor directory would be the entire gate gone. |
| 166 | |
| 167 | A worked directory is at [examples/policy/](../../examples/policy/). Two floor documents contribute |
| 168 | to the same `prose` class — one requiring `prose-format`, one added later requiring `link-check`, |
| 169 | both pinning the same coverage pattern — and the composed class requires both. A `docs` template is |
| 170 | written as the definition `#docs`, and composing the instance directory alone exports a policy with |
| 171 | no `knowledge` class at all: the definition contributes nothing until the project document embeds |
| 172 | it. That project document embeds it, declines the template's defaulted knowledge lint, and adds a |
| 173 | `shellcheck` class of its own. A third floor document contradicting the second fails vet naming both |
| 174 | files: |
| 175 | |
| 176 | ``` |
| 177 | floor.classes.prose.requires."link-check": conflicting values true and false: |
| 178 | ./examples/policy/instance/floor-references.cue:19:27 |
| 179 | ./floor-disagree.cue:3:48 |
| 180 | ``` |
| 181 | |
| 182 | ## What the schema commits to |
| 183 | |
| 184 | Class matching is a set operation, never first-match. A change's required checks are the union of |
| 185 | `requires` over every class that at least one changed path matches. Classes may overlap deliberately |
| 186 | — a knowledge node is both knowledge and prose — and the union is the entirety of [[ida-1ec03b1]]'s |
| 187 | "mixed takes the max" rule. There is no separate mixed case, and no ordering to get wrong. |
| 188 | |
| 189 | A path matching no class is answered explicitly, by a required `unclassified` field. The failure |
| 190 | this document must never have is a path that quietly requires nothing, so the policy has to state |
| 191 | what an uncovered path costs rather than defaulting to silence. |
| 192 | |
| 193 | The signature is deliberately absent. [[ida-1ec03b1]] lists it alongside the knowledge lint because |
| 194 | it is enumerating what a knowledge-only diff must satisfy, but the signature is required of every |
| 195 | change by the structural invariant and the integrator, whatever paths the diff touches. It is not |
| 196 | path-scoped, so it is not policy. |
| 197 | |
| 198 | Every check name a class requires must exist in the composed catalogue. A name that does not lands |
| 199 | in `checks` as an incomplete check and fails vet. Without this, a typo is not a vet error — it is a |
| 200 | check that silently stops being required. |
| 201 | |
| 202 | ## Evidence: the worked example |
| 203 | |
| 204 | The claims above are pinned by running `cue vet`, not by inspection. The example in `examples/` is |
| 205 | two documents. The instance layer makes `prose-format` mandatory over `**/*.md` and for uncovered |
| 206 | paths, and offers a `docs` project type whose knowledge lint is a default. The project layer selects |
| 207 | that type, adds a `shellcheck` class of its own, and declines the defaulted knowledge lint. |
| 208 | |
| 209 | Both directions were run. |
| 210 | |
| 211 | ``` |
| 212 | $ cue vet -c schema/verification.cue \ |
| 213 | examples/verification-instance.cue examples/verification-project.cue |
| 214 | $ echo $? |
| 215 | 0 |
| 216 | ``` |
| 217 | |
| 218 | The composed `policy` exports with `knowledge-lint` at `false` — the project's legitimate override — |
| 219 | alongside the floor's `prose-format` at `true` and the project's own `shellcheck` class. A project |
| 220 | that instead tries to unset the mandatory check fails, and the error names the field: |
| 221 | |
| 222 | ``` |
| 223 | $ cue vet -c schema/verification.cue examples/verification-instance.cue unset.cue |
| 224 | policy.classes.prose.requires."prose-format": conflicting values false and true: |
| 225 | ./examples/verification-instance.cue:29:29 |
| 226 | ... |
| 227 | ./unset.cue:3:52 |
| 228 | ``` |
| 229 | |
| 230 | Narrowing a floor class's coverage fails the same way, at `policy.classes.prose.paths."**/*.md"`. |
| 231 | Selecting a project type the instance does not define is an evaluation error rather than a silent |
| 232 | fallback. An unknown check name, a stray top-level field, an absolute or `..` path pattern, an |
| 233 | unimplemented runner, an unknown field inside a class, and a malformed name all fail vet with an |
| 234 | error naming the field. A project document that declares nothing at all vets, and composes to the |
| 235 | floor exactly. |
| 236 | |
| 237 | The example is evidence for the schema and nothing more. It is not the live exercise on qinling, |
| 238 | which is a separate step described below. The schema is unwired: it is not referenced by |
| 239 | [schema/valley.cue](../../schema/valley.cue), not covered by the flake's `cue-vet` check, and not |
| 240 | read by [nix/valley-host.nix](../../nix/valley-host.nix), so these rejections are demonstrated |
| 241 | rather than run continuously. |
| 242 | |
| 243 | ## What this costs |
| 244 | |
| 245 | A project is now self-describing only above the floor, which trims [[ida-3e87f5c]] |
| 246 | ([ida-3e87f5c-self-describing-projects.md](../ideas/ida-3e87f5c-self-describing-projects.md)). A |
| 247 | clone of the project alone can no longer state its required set; it can state what the project adds, |
| 248 | and must consult the instance repository for the rest. That is a deliberate trade for the group |
| 249 | being able to force compliance, which is the whole reason the floor exists. The timing split |
| 250 | preserves most of the offline story: templates may be pinned, so the only thing a clone genuinely |
| 251 | cannot answer alone is the current floor, and the floor is small by design. |
| 252 | |
| 253 | Enforcement belongs to the integrator, which already holds both trees and reads the policy at the |
| 254 | target ref's tip — the policy that is already integrated — so a change never supplies the policy |
| 255 | that gates it. That is consistent with the one structural invariant in |
| 256 | [contribute.md](../../design/contribute.md), and it means declared policy is inert data until Phase |
| 257 | 3 ([roadmap.md](../../design/roadmap.md)); Phase 2 is where a contributor can first produce the |
| 258 | evidence a policy asks for. The checks a policy names are ordinary flake checks in the reference |
| 259 | implementation, so a project that already has checks has most of a policy — the document says which |
| 260 | ones apply where, not what a check is. |
| 261 | |
| 262 | ## The staged path: qinling first, cosmo second |
| 263 | |
| 264 | Every feature built for cosmo readiness is exercised live on the gunk-dev instance, on a project |
| 265 | already hosted there, before cosmo depends on it. The projects on the instance today are the-valley |
| 266 | and qinling, and both are markdown-only. So the first exercisable class is knowledge and prose — the |
| 267 | formatter-idempotence check this repo already ships as a flake check, plus the frontmatter and |
| 268 | reference-integrity linting [[ida-1ec03b1]] describes — and not the `nix build` class cosmo |
| 269 | eventually needs. |
| 270 | |
| 271 | qinling is also the instance repository, so the first exercise carries both layers at once: qinling |
| 272 | holds the floor and the templates, and the-valley holds a project policy that composes with them. |
| 273 | |
| 274 | ### The smallest thing that could be turned on |
| 275 | |
| 276 | Four pieces, none of which is an enforcement point: |
| 277 | |
| 278 | 1. qinling gains the instance document — a floor requiring the prose format check over `**/*.md` and |
| 279 | for uncovered paths, and a `docs` project type offering the knowledge lint — and the-valley gains |
| 280 | a project document that selects that type. The example in `examples/` is written as very nearly |
| 281 | those two files. |
| 282 | 2. `knowledge-lint` is built as a flake check: frontmatter vetted against a CUE `#Node` schema, and |
| 283 | reference integrity — `[[wiki-links]]`, `blocked_by` ids, and relative links all resolve. |
| 284 | `prose-format` already exists in this repo and is copied or shared. |
| 285 | 3. A read-only deriver: given the instance tip, a project tree, and two commits, compose the policy, |
| 286 | list the changed paths, match them against the composed classes, and print the required check |
| 287 | names. It reports; it blocks nothing. |
| 288 | 4. The two checks are run against the trees the deriver named. |
| 289 | |
| 290 | ### What observing it succeed looks like |
| 291 | |
| 292 | The standard is verified by looking, not by reviewing configuration. Reading the policy files and |
| 293 | agreeing that they say the right thing is not the exercise. |
| 294 | |
| 295 | - A commit that actually landed in the-valley touching a knowledge node is fed to the deriver, and |
| 296 | it prints exactly `knowledge-lint` and `prose-format` — the union of two overlapping classes, one |
| 297 | contributed by each layer, observed rather than asserted. |
| 298 | - A commit touching only `README.md` prints exactly `prose-format`. The knowledge lint's absence is |
| 299 | the observation; a policy that over-requires is as wrong as one that under-requires, and only the |
| 300 | second failure is loud. |
| 301 | - The project document is edited to decline `prose-format`, and the deriver refuses to compose the |
| 302 | policy at all, naming the field. The floor is observed to hold against the project rather than |
| 303 | argued to. |
| 304 | - A node's frontmatter is deliberately broken on a scratch branch. `knowledge-lint` fails against |
| 305 | that tree, and the failure names the file and the field. |
| 306 | - A file no class covers — a shell script in a markdown-only repository — makes the deriver print |
| 307 | the `unclassified` set. The hole announces itself instead of being found later. |
| 308 | |
| 309 | ### What cosmo additionally requires |
| 310 | |
| 311 | Naming these keeps the qinling exercise from being mistaken for cosmo readiness. |
| 312 | |
| 313 | - A `format` class over `**/*.nix` requiring `nixfmt --check`, and a build class requiring the |
| 314 | five-machine build matrix. The schema expresses both today; nothing else about them is ready. |
| 315 | - An answer to check latency. Five machines' worth of `nix build` is not something a contributor's |
| 316 | machine finishes quickly, and neither layer's owning the policy changes that. It is a real open |
| 317 | question this node does not close. |
| 318 | - The floor actually read from the instance repository's tip by something, rather than from whatever |
| 319 | tree happens to be at hand. Provenance is the whole of the forcing, so an implementation that gets |
| 320 | it wrong has no floor at all. |
| 321 | - An enforcement point — Phase 3's integrator, or a deliberate interim. Until then this machinery |
| 322 | observes and reports, and **cosmo must not migrate onto an observation**. That is the difference |
| 323 | between qinling exercising the feature and cosmo depending on it. |
| 324 | |
| 325 | ## Related |
| 326 | |
| 327 | - The design this implements: [[ida-1ec03b1]] |
| 328 | ([ida-1ec03b1-path-scoped-verification-policy.md](../ideas/ida-1ec03b1-path-scoped-verification-policy.md)) |
| 329 | - The group-to-instance binding the instance layer rests on: [[ida-8482624]] |
| 330 | ([ida-8482624-federation-groups.md](../ideas/ida-8482624-federation-groups.md)) |
| 331 | - The direction the project layer continues, and that the floor trims: [[ida-3e87f5c]] |
| 332 | ([ida-3e87f5c-self-describing-projects.md](../ideas/ida-3e87f5c-self-describing-projects.md)) |
| 333 | - The store the policy travels in: [[dcr-5da1f36]] |
| 334 | ([dcr-5da1f36-project-is-repo.md](./dcr-5da1f36-project-is-repo.md)) |
| 335 | - Why the host schema stays free of options a host cannot act on: [[dcr-0f5d9b1]] |
| 336 | ([dcr-0f5d9b1-cue-config-host-module.md](./dcr-0f5d9b1-cue-config-host-module.md)) |