feat(#1602): deterministic coverage-metadata UAT routing for verify-work
Add an optional structured `coverage:` block to SUMMARY.md frontmatter and a deterministic classifier that `verify-work` consumes to route deliverables to auto-pass vs human-UAT — replacing the rejected #1598/#1599 post-hoc heuristic. - New `src/coverage.cts` (→ bin/lib/coverage.cjs) parses the nested coverage block (extractFrontmatter can't — its `-` items are scalars-only; this is a focused parser, sibling of parseMustHavesBlock), validates each entry, and classifies into auto_passed vs present. Frozen MODE/PRESENT_REASON/ERROR_CODE typed-IR surface. Exposed via `uat classify-coverage --summary <f>`. - Auto-pass is the narrow proven case only: strict-boolean human_judgment:false AND non-empty all-`pass` verification AND zero validation errors. Everything else — judgment, empty/failing verification, malformed entry — routes to the human (fail-safe). A malformed block falls back to legacy prose extraction and surfaces an error; an absent block is byte-identical to pre-#1602. - execute-plan create_summary populates the block (fail-safe default human_judgment:true); verify-work extract_tests consumes it; create_uat_file marks auto-passed entries `source: automated`. - Templates (summary + 3 variants), CONTEXT.md predicate + glossary, INVENTORY, eslint/gitignore registration, and Diataxis docs (COMMANDS reference + USER-GUIDE explanation) updated. - Behavioral tests via the CLI (no source-grep); parser-robustness regressions for the null-entry/comment-header/mis-indent cases found in adversarial review. Closes #1602 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,7 @@
|
||||
* UAT Audit:
|
||||
* audit-uat Scan all phases for unresolved UAT/verification items
|
||||
* uat render-checkpoint --file <path> Render the current UAT checkpoint block
|
||||
* uat classify-coverage --summary <path> Classify a SUMMARY coverage block into auto-passed vs human-UAT (#1602)
|
||||
*
|
||||
* Open Artifact Audit:
|
||||
* audit-open [--json] Scan all .planning/ artifact types for unresolved items
|
||||
@@ -1360,12 +1361,16 @@ async function runCommand(command, args, cwd, raw, defaultValue, originalCommand
|
||||
|
||||
case 'uat': {
|
||||
const subcommand = args[1];
|
||||
const uat = require('./lib/uat.cjs');
|
||||
if (subcommand === 'render-checkpoint') {
|
||||
const uat = require('./lib/uat.cjs');
|
||||
const options = parseNamedArgs(args, ['file']);
|
||||
uat.cmdRenderCheckpoint(cwd, options, raw);
|
||||
} else if (subcommand === 'classify-coverage') {
|
||||
const coverage = require('./lib/coverage.cjs');
|
||||
const options = parseNamedArgs(args, ['summary', 'file']);
|
||||
coverage.cmdClassify(cwd, options, raw);
|
||||
} else {
|
||||
error('Unknown uat subcommand. Available: render-checkpoint', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
error('Unknown uat subcommand. Available: render-checkpoint, classify-coverage', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ key-decisions:
|
||||
- "Decision 1"
|
||||
patterns-established:
|
||||
- "Pattern 1: description"
|
||||
# coverage: (#1602) optional per-deliverable UAT-routing block — see templates/summary.md <coverage_guidance>.
|
||||
# Add live `coverage:` entries (id/description/verification[]/human_judgment[/rationale]) to enable
|
||||
# deterministic UAT routing in verify-work; OMIT for legacy prose-only SUMMARYs. When coverage is
|
||||
# uncertain, default human_judgment: true with a rationale — never auto-skip the human.
|
||||
duration: Xmin
|
||||
completed: YYYY-MM-DD
|
||||
status: complete
|
||||
|
||||
@@ -13,6 +13,9 @@ key-files:
|
||||
created: [important files created]
|
||||
modified: [important files modified]
|
||||
key-decisions: []
|
||||
# coverage: (#1602) optional per-deliverable UAT-routing block — see templates/summary.md <coverage_guidance>.
|
||||
# Add live `coverage:` entries to enable deterministic UAT routing in verify-work; OMIT for legacy
|
||||
# prose-only SUMMARYs. When coverage is uncertain, default human_judgment: true — never auto-skip the human.
|
||||
duration: Xmin
|
||||
completed: YYYY-MM-DD
|
||||
status: complete
|
||||
|
||||
@@ -14,6 +14,10 @@ key-files:
|
||||
modified: [important files modified]
|
||||
key-decisions:
|
||||
- "Decision 1"
|
||||
# coverage: (#1602) optional per-deliverable UAT-routing block — see templates/summary.md <coverage_guidance>.
|
||||
# Add live `coverage:` entries (id/description/verification[]/human_judgment[/rationale]) to enable
|
||||
# deterministic UAT routing in verify-work; OMIT for legacy prose-only SUMMARYs. When coverage is
|
||||
# uncertain, default human_judgment: true with a rationale — never auto-skip the human.
|
||||
duration: Xmin
|
||||
completed: YYYY-MM-DD
|
||||
status: complete
|
||||
|
||||
@@ -40,6 +40,24 @@ patterns-established:
|
||||
|
||||
requirements-completed: [] # REQUIRED — Copy ALL requirement IDs from this plan's `requirements` frontmatter field.
|
||||
|
||||
# Coverage metadata (#1602) — one entry per shipped deliverable. Drives DETERMINISTIC UAT routing in verify-work.
|
||||
# OMIT this whole block for legacy/prose-only SUMMARYs — verify-work then falls back to the ## Accomplishments bullets
|
||||
# (byte-identical behavior for un-migrated phases). See <coverage_guidance> below for the contract.
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "[deliverable in human-readable form — what would have been a prose ## Accomplishments bullet]"
|
||||
requirement: "[REQ-ID from this plan's `requirements`, or omit if none]"
|
||||
verification:
|
||||
- kind: unit # unit | integration | e2e | automated_ui | manual_procedural | other
|
||||
ref: "[tests/path.test.ts#test name | playwright:shot.png | command invocation]"
|
||||
status: pass # pass | fail | unknown — from the latest run
|
||||
human_judgment: false # REQUIRED boolean. false => may auto-pass IF every verification status is `pass`.
|
||||
- id: D2
|
||||
description: "[a deliverable that needs a human to sign off]"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "[REQUIRED when human_judgment: true — why automation is insufficient]"
|
||||
|
||||
# Metrics
|
||||
duration: Xmin
|
||||
completed: YYYY-MM-DD
|
||||
@@ -148,6 +166,29 @@ None - no external service configuration required.
|
||||
**Population:** Frontmatter is populated during summary creation in execute-plan.md. See `<step name="create_summary">` for field-by-field guidance.
|
||||
</frontmatter_guidance>
|
||||
|
||||
<coverage_guidance>
|
||||
**Purpose (#1602):** The `coverage:` block is a per-deliverable Requirements Traceability Matrix. It lets `verify-work`'s `extract_tests` step route deliverables DETERMINISTICALLY — auto-passing those proven by passing tests and reserving human UAT for genuine judgment — instead of re-deriving coverage from prose. Consumed via `gsd-tools uat classify-coverage --summary <SUMMARY>`.
|
||||
|
||||
**Field semantics:**
|
||||
|
||||
| Field | Purpose |
|
||||
|---|---|
|
||||
| `id` | Stable identifier (`D1`, `D2`…) for cross-referencing from UAT.md and audit reports. Must be unique within the SUMMARY. |
|
||||
| `description` | The deliverable in human-readable form — what would have been a prose bullet. |
|
||||
| `requirement` | Links back to a REQUIREMENTS.md REQ-ID (joins `requirements-completed`). Optional. |
|
||||
| `verification[].kind` | Enum: `unit \| integration \| e2e \| automated_ui \| manual_procedural \| other`. |
|
||||
| `verification[].ref` | Test path + descriptor (`file#test name`), Playwright screenshot ref, or command invocation. Required per entry. |
|
||||
| `verification[].status` | `pass \| fail \| unknown` — populated from the latest test run. |
|
||||
| `human_judgment` | Explicit boolean; REQUIRED. `true` always routes to a human. |
|
||||
| `rationale` | REQUIRED when `human_judgment: true`. The audit trail for why automation is insufficient. |
|
||||
|
||||
**Deterministic contract (what the classifier does):**
|
||||
- A deliverable auto-passes (no human prompt) **only** when `human_judgment: false` AND `verification` is non-empty AND every `verification[].status` is `pass`. This is the narrow, fully-proven case.
|
||||
- **Everything else is presented to a human** — `human_judgment: true`, an empty `verification:`, any non-`pass`/`unknown` status, or any schema error. A false-negative is a redundant prompt (the status quo); a false-positive ships a bug UAT existed to catch.
|
||||
- **Fail-safe default:** if you cannot determine coverage for a deliverable, you MUST set `human_judgment: true` with `rationale: "Coverage not determined at authoring time — verifier must classify"`. Never leave a deliverable's `human_judgment` empty, and never set it `false` just to skip the prompt — auto-pass additionally requires a passing `verification` entry, so the flag alone cannot skip the human.
|
||||
- `coverage: []` means "no deliverables to classify" (the single-confirmation path). OMITTING the block entirely means "legacy" — `verify-work` falls back to prose `## Accomplishments` extraction unchanged.
|
||||
</coverage_guidance>
|
||||
|
||||
<one_liner_rules>
|
||||
The one-liner MUST be substantive:
|
||||
|
||||
|
||||
@@ -377,6 +377,11 @@ Create `{phase}-{plan}-SUMMARY.md` at `.planning/phases/XX-name/`. Use `~/.claud
|
||||
|
||||
**Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (**MUST** copy `requirements` array from PLAN.md frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date).
|
||||
|
||||
**Coverage block (#1602):** Populate the `coverage:` frontmatter block — one entry per shipped deliverable (the structured form of each `## Accomplishments` bullet). For each deliverable, aggregate the task-level `<verify>` results and tests:
|
||||
- A task whose `<verify>` command passed or whose matching test passed → a `verification` entry with `kind` + `ref` (`tests/path#name`, Playwright screenshot ref, or command) + `status: pass`, and `human_judgment: false`.
|
||||
- A judgment-dependent deliverable (UX adequacy, external/multi-session behavior, anything no test asserts) → `human_judgment: true` with a `rationale`.
|
||||
- **Every deliverable MUST be classified.** If you cannot determine coverage, default to `human_judgment: true` with `rationale: "Coverage not determined at authoring time — verifier must classify"`. Never set `human_judgment: false` without a non-empty all-`pass` `verification` — `verify-work` auto-passes (skips the human) ONLY on that proof, so an unproven `false` still routes to the human but loses the audit trail. Omit the whole block only for a genuinely prose-only SUMMARY (verify-work then uses the legacy `## Accomplishments` path). The block is validated downstream by `gsd-tools uat classify-coverage`.
|
||||
|
||||
Title: `# Phase [X] Plan [Y]: [Name] Summary`
|
||||
|
||||
One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
|
||||
|
||||
@@ -178,7 +178,24 @@ fi
|
||||
|
||||
The verb owns the canonical regex `/^As a .+, I want to .+, so that .+\.$/` and returns slot extractions plus per-error guidance when invalid. Halt UAT generation on failure — never attempt to derive user-flow steps from a non-User-Story goal (low-quality UAT).
|
||||
|
||||
**Extract testable deliverables from SUMMARY.md:**
|
||||
**Coverage-aware deterministic classification (#1602).** Before deriving checkpoints from prose, classify each SUMMARY's structured `coverage:` block. For each `*-SUMMARY.md`:
|
||||
|
||||
```bash
|
||||
COVERAGE=$(gsd_run query uat.classify-coverage --summary "$SUMMARY_FILE")
|
||||
```
|
||||
|
||||
Read the JSON result (`mode`, `total`, `all_auto_covered`, `auto_passed[]`, `present[]`, `errors[]`):
|
||||
|
||||
- **`mode: legacy`** (no `coverage:` block, OR a malformed block that could not be parsed) → **fall through** to the prose-based extraction below. Behavior is byte-identical to pre-#1602 for un-migrated SUMMARYs; do NOT auto-pass anything. If `errors[]` is non-empty (a `malformed_block`), note the broken coverage block to the user before proceeding so the SUMMARY can be fixed.
|
||||
- **`mode: coverage`** →
|
||||
- Each `auto_passed[]` entry is recorded in UAT.md as `result: pass`, `source: automated` (see `create_uat_file`) — **do not present it as a checkpoint.** It is deterministically covered by the passing tests in its `verification` refs.
|
||||
- Each `present[]` entry becomes a human UAT checkpoint: use its `description` as the test and carry its `rationale` into the checkpoint context. The `reason` (`human_judgment` / `no_verification` / `verification_not_passing` / `validation_failed`) explains why a human is needed.
|
||||
- If `all_auto_covered` is `true` (every entry auto-passed, including the `coverage: []` case) → do NOT generate zero checkpoints; present a **single confirmation summary** listing the auto-covered deliverables with their covering tests and ask the user to confirm.
|
||||
- Surface any `errors[]` to the user (malformed coverage block) but still treat their entries as human checkpoints — **never drop a deliverable** (fail-safe).
|
||||
|
||||
The cold-start smoke test injection below still applies in `coverage` mode.
|
||||
|
||||
**Extract testable deliverables from SUMMARY.md (legacy fallback — used when `mode: legacy`):**
|
||||
|
||||
Parse for:
|
||||
1. **Accomplishments** - Features/functionality added
|
||||
@@ -252,6 +269,18 @@ result: [pending]
|
||||
|
||||
...
|
||||
|
||||
**Coverage auto-passed entries (#1602):** for each `auto_passed[]` entry from `uat classify-coverage`, write a Tests entry pre-resolved as automated — these are NOT presented to the user:
|
||||
|
||||
```
|
||||
### N. [coverage description]
|
||||
expected: [coverage description]
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: [D-id]
|
||||
```
|
||||
|
||||
The `source: automated` marker is additive — existing consumers that read only `result:` are unaffected.
|
||||
|
||||
## Summary
|
||||
|
||||
total: [N]
|
||||
|
||||
Reference in New Issue
Block a user