gunk-dev/the-valley

dcr-f41f718-declared-verification-policy.md

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