feat(kernel): gate the DoD against discovery scope (#699)

Session 954da1a9 asked for an eight-view web UI and shipped a Vite starter
page. Discovery settled all eight items in brief.scope; the analyst emitted
four criteria, all part="Project Foundation"; the architect planned against
that DoD, so the run scaffolded Vite, Tailwind and TanStack Query and stopped.
The plan-compile gate and the final reviewer both graded the shrunken DoD, so
a plan delivering 5% of the request passed clean.

Each DoD criterion now carries `covers`: the 0-based indexes into discovery
brief.scope it proves. A post-stage scope_coverage gate fails the analyst
retryably when an index has no criterion, handing back the dropped items
verbatim. Pure function of two recorded artifacts, so replay recomputes it and
no verdict event is needed.

Ceiling is index bookkeeping, not semantics: a criterion claiming covers:[3]
without really proving scope[3] still passes. It catches the silent collapse,
not a weak criterion.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013dVqqci5H5b3s6xzv6Lojq
This commit is contained in:
2026-08-11 19:56:43 +04:00
parent 53f1ebfea9
commit 700f59ef0d
5 changed files with 226 additions and 7 deletions
@@ -41,20 +41,27 @@ Emit the `dod` artifact once. Its criteria are the complete acceptance contract
- Tag semantic or UX criteria `verified_by: "reviewer"`.
- Copy discovery `brief.non_goals` into `out_of_scope`; this is a hard review boundary.
- Cover the entire in-scope brief now. Later stages may not silently add criteria.
- Give every criterion a `covers` array: the 0-based indexes into discovery `brief.scope` it proves.
Walk `brief.scope` in order and account for every index. A scope-coverage gate fails this stage
and hands back the uncovered items verbatim. Two criteria proving one scope item repeat its index.
One criterion proving three items lists all three. A criterion that serves the run rather than a
scope item (the named task, a failure path) gets `[]`.
- Include at least one criterion proving the named task is carried through to the implementation
plan, and one criterion for each material failure or recovery path identified during discovery.
Call `emit_artifact` with a JSON object matching this shape:
`{"summary": string, "criteria": [{"id": string, "statement": string, "part": string,
"verified_by": "gate" | "reviewer"}], "out_of_scope": [string]}`.
"verified_by": "gate" | "reviewer", "covers": [integer]}], "out_of_scope": [string]}`.
Example:
Example, for a discovery brief whose `scope` is
`["Bounded validation gate", "Operator sees the diagnostic"]`:
```json
{
"summary": "Deliver the bounded validation gate for task gate-42.",
"criteria": [
{"id":"c1","statement":"The project typecheck passes before completion","part":"terminal gate","verified_by":"gate"},
{"id":"c2","statement":"The operator sees the recorded diagnostic","part":"workflow UX","verified_by":"reviewer"}
{"id":"c1","statement":"The project typecheck passes before completion","part":"terminal gate","verified_by":"gate","covers":[0]},
{"id":"c2","statement":"The operator sees the recorded diagnostic","part":"workflow UX","verified_by":"reviewer","covers":[1]},
{"id":"c3","statement":"The implementation plan names task gate-42","part":"task threading","verified_by":"reviewer","covers":[]}
],
"out_of_scope": ["Changing the workflow topology"]
}