| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-f41f718 |
| 4 | status: decided |
| 5 | title: "Compose verification policy from a valley floor and project requirements" |
| 6 | created: 2026-07-31 |
| 7 | source: cosmo-readiness design pass, 2026-07-31 |
| 8 | --- |
| 9 | |
| 10 | # Compose verification policy from a valley floor and project requirements |
| 11 | |
| 12 | Verification policy maps changed paths to required checks. It is declared in CUE and combines a |
| 13 | valley's shared policy, called the **floor**, with the project's own requirements. A project can add |
| 14 | requirements and override optional defaults. It cannot remove a mandatory requirement from the |
| 15 | floor. |
| 16 | |
| 17 | [schema/verification.cue](../../schema/verification.cue) defines the format, and |
| 18 | [examples/policy/](../../examples/policy/) demonstrates composition. |
| 19 | [[ida-1ec03b1]](../ideas/ida-1ec03b1-path-scoped-verification-policy.md) establishes that the |
| 20 | required checks come from the actual diff. |
| 21 | |
| 22 | ## Policy layers |
| 23 | |
| 24 | The valley repository carries the floor and project-type templates. Qinling serves this role for the |
| 25 | current deployment. Each project carries a separate policy directory defining its additional classes |
| 26 | and checks. |
| 27 | |
| 28 | Both directories use the same schema. CUE unification combines their constraints, so the effective |
| 29 | value must satisfy both layers. |
| 30 | |
| 31 | The floor should remain small. It expresses requirements the valley applies to every project it |
| 32 | owns. Most project-specific requirements belong in the project's policy or in templates it selects. |
| 33 | |
| 34 | Policy belongs to the valley and project, independent of which hosts run them. Placing verification |
| 35 | policy in a host declaration would allow two hosts serving the same valley to disagree about its |
| 36 | rules. The deployment boundary is described in |
| 37 | [[dcr-9b5da04]](dcr-9b5da04-hosts-serve-isolated-valleys.md). |
| 38 | |
| 39 | ## Mandatory requirements and optional defaults |
| 40 | |
| 41 | CUE represents the distinction directly: |
| 42 | |
| 43 | - A concrete `true` requirement in the floor cannot unify with a project's `false`. |
| 44 | - A default such as `bool | *true` applies unless the project supplies another permitted value. |
| 45 | - Open structs allow projects to add classes and checks. |
| 46 | - Project-type definitions supply reusable policy fragments that a project selects and refines. |
| 47 | |
| 48 | A class's required checks, path patterns, and the `unclassified` requirements are sets represented |
| 49 | as structs keyed by name. Composition must combine entries by name; positional lists would not |
| 50 | provide that behavior. |
| 51 | |
| 52 | When both layers contribute to the same class, its enabled path patterns and requirements combine. A |
| 53 | project cannot remove a concrete floor pattern to avoid the checks attached to it. |
| 54 | |
| 55 | ## Selecting required checks |
| 56 | |
| 57 | Class matching is a set operation. For each changed path, find every class it matches. The required |
| 58 | check set is the union of those classes' enabled requirements. |
| 59 | |
| 60 | Classes can overlap. A knowledge node may require both knowledge validation and prose formatting. A |
| 61 | change touching prose and code requires the checks for both; no separate mixed-change rule is |
| 62 | needed. |
| 63 | |
| 64 | Every policy must explicitly declare `unclassified`, which determines the checks for a path matching |
| 65 | no class. This makes uncovered paths an intentional policy choice. |
| 66 | |
| 67 | Each required check name must exist in the composed catalogue. Unknown names fail validation. |
| 68 | Otherwise a misspelling could silently remove a check. |
| 69 | |
| 70 | Change signatures are a structural integration requirement. They are not selected by path class. |
| 71 | [[dcr-9c75283]](dcr-9c75283-substrate-adoption-and-the-core.md) separately defines the core approval |
| 72 | requirement and the policy exemptions available for ordinary changes. |
| 73 | |
| 74 | ## Where policy is read |
| 75 | |
| 76 | The floor is read from the valley repository's integrated tip. A project cannot substitute a |
| 77 | vendored copy or choose an old floor revision. The provenance of the input is what makes the floor |
| 78 | mandatory; CUE cannot determine where a file came from. |
| 79 | |
| 80 | The project's policy is read from the target branch's integrated tip. A proposed change therefore |
| 81 | cannot supply the policy used to admit itself. |
| 82 | |
| 83 | Weakening a valley requirement needs an integrated change in the valley repository under the rules |
| 84 | that already govern that repository. Templates may be pinned because they are optional defaults a |
| 85 | project could otherwise write itself. |
| 86 | |
| 87 | [[ida-5006606]](../ideas/ida-5006606-a-project-names-its-owning-valley.md) defines how a project |
| 88 | identifies its owning valley. |
| 89 | [[ida-a9e274c]](../ideas/ida-a9e274c-mandated-checks-come-from-the-instance.md) explains how |
| 90 | valley-mandated check implementations are supplied. |
| 91 | [[bd-eaefe82]](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md) tracks the separate |
| 92 | risk of trusting check definitions from a submitted branch. |
| 93 | |
| 94 | ## Directories and composition |
| 95 | |
| 96 | Each policy layer is a CUE package. All files in its directory participate in unification; no extra |
| 97 | manifest is needed. |
| 98 | |
| 99 | The valley determines which floor documents are loaded. Projects choose which template definitions |
| 100 | to embed. Concrete fields apply when loaded; definitions remain inactive until selected. |
| 101 | |
| 102 | Two files can contribute requirements to the same class. Incompatible constraints fail validation |
| 103 | with the conflicting fields and source locations. File order must not select a winner. |
| 104 | |
| 105 | The directory convention also makes policy inspectable with ordinary repository tools. It does not |
| 106 | give a project authority to edit the valley's floor. |
| 107 | |
| 108 | ## Missing layers and bootstrap |
| 109 | |
| 110 | A missing project layer adds no project-specific requirements. The floor and core still apply. This |
| 111 | permits a project's first policy change to pass through normal integration. |
| 112 | |
| 113 | [[dcr-9c75283]](dcr-9c75283-substrate-adoption-and-the-core.md) defines the adopted bootstrap |
| 114 | design: a valley with no floor operates under the core's physical-approval requirement. An empty |
| 115 | floor cannot remove that requirement. |
| 116 | |
| 117 | The core's approval mechanism must be available before this bootstrap behavior is enabled. The |
| 118 | current policy tooling requires the valley policy directory and reports its absence. Operators must |
| 119 | not interpret a missing or unreadable policy input as permission to integrate without checks. |
| 120 | |
| 121 | ## Validation examples |
| 122 | |
| 123 | The worked policy in [examples/policy/](../../examples/policy/) demonstrates a mandatory |
| 124 | prose-format check, a second file adding link checking to the same class, and a documentation |
| 125 | template offering knowledge lint as a default. The project adds its own shell-checking class and |
| 126 | declines the optional knowledge check. |
| 127 | |
| 128 | This exercises the important composition cases: |
| 129 | |
| 130 | - Adding project requirements succeeds. |
| 131 | - Declining an optional default succeeds. |
| 132 | - Declining a mandatory check or removing mandatory path coverage fails. |
| 133 | - Selecting an undefined template or check fails. |
| 134 | - Invalid names, unsupported runners, unknown fields, and unsafe path patterns fail. |
| 135 | - An empty project declaration composes to the floor. |
| 136 | |
| 137 | These examples establish schema behavior. Live enforcement also depends on the policy resolver, |
| 138 | check execution, evidence verification, and protected-ref enforcement. |
| 139 | |
| 140 | ## Deployment and verification |
| 141 | |
| 142 | [bin/valley](../../bin/valley) provides `valley checks` to report the checks required by a diff. The |
| 143 | review workflow can run those checks, sign the results, and submit an integration request. The |
| 144 | integrator evaluates the request against governing policy and evidence before updating the protected |
| 145 | target. |
| 146 | |
| 147 | The initial live exercise uses Qinling and the-valley, with overlapping prose and knowledge classes. |
| 148 | Useful observations are: |
| 149 | |
| 150 | - A knowledge-only change requires knowledge lint and prose formatting. |
| 151 | - A change confined to an ordinary Markdown document requires prose formatting. |
| 152 | - An attempt to disable mandatory formatting fails composition. |
| 153 | - Invalid node frontmatter fails the knowledge check with the file and field identified. |
| 154 | - An uncovered path receives the declared `unclassified` requirements. |
| 155 | |
| 156 | These observations check both missing requirements and unnecessary requirements. Reading a plausible |
| 157 | policy file is insufficient evidence that the full path works. |
| 158 | |
| 159 | ## Migration consequences |
| 160 | |
| 161 | A project clone contains its own policy but needs the current valley floor to determine its full |
| 162 | requirements. This is the cost of allowing a valley to impose rules across projects. Pinned optional |
| 163 | templates preserve part of the offline workflow. |
| 164 | |
| 165 | Cosmo additionally needs policy for Nix formatting and its five-machine build matrix. Check latency |
| 166 | remains a practical concern. Migration also requires verified policy provenance and enforced |
| 167 | integration; a command that merely reports required checks cannot replace the existing gate. |
| 168 | |
| 169 | [[oc-87deec8]](../outcomes/oc-87deec8-valley-can-host-cosmo.md) tracks those migration requirements. |
| 170 | [[ida-7638082]](../ideas/ida-7638082-host-has-no-check-runner.md) inventories the checks that must |
| 171 | be accounted for. The system's own policy changes remain part of the history described in |
| 172 | [self-transparency.md](../../design/self-transparency.md). |