feat(voyage): S9 — NW1 reviewer-output schema contract (TDD, ungated)
Codify the /trekreview Phase 5 reviewer JSON contract as a validated schema so main validates each reviewer's output instead of merely JSON.parse-ing it, and re-asks on schema failure (not just parse failure). Retires the fragility at trekreview.md:202-204. No Workflow dependency (S8 tier 1, ships regardless). New lib/review/findings-schema.mjs (3-layer Content -> Raw-text -> CLI shim, reusing result.mjs error-shape + rule-catalogue RULE_KEYS/SEVERITY_VALUES): - validateFindings(payload): hard errors on load-bearing fields the dedup triplet + verdict depend on — file, rule_key (in catalogue), severity (enum), line (integer >= 0); accumulates all errors; per-finding location. - extractFindingsBlock(text): last fenced ```json block (the :202 contract). - validateReviewerOutput(text): extract + parse + schema, unifying parse and schema failures under one bounded re-ask path. Stable codes: FINDINGS_NOT_OBJECT/_NOT_ARRAY/_NO_JSON_BLOCK/_PARSE_ERROR (top), FINDING_MISSING_FILE/_MISSING_RULE_KEY/_UNKNOWN_RULE_KEY/_BAD_SEVERITY/_BAD_LINE (per-finding). Descriptive fields + unknown keys tolerated (forward-compat). Phase 5 prose: replace "parse last json block; on parse error re-emit" with "validate against findings-schema; on failure re-ask conforming JSON, bounded N=2; never feed unvalidated findings to the coordinator". TDD: 27 failing tests first, then minimal code to pass. Suite 606 -> 647 (645 pass / 2 skip / 0 fail). claude plugin validate clean (only the known root-CLAUDE.md warning). Plan: docs/W1-narrow-wins-plan.md S9. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqBYc8Ltrk7LipyJmGxXiB
This commit is contained in:
parent
90cd473885
commit
b149538d43
3 changed files with 438 additions and 3 deletions
|
|
@ -199,9 +199,25 @@ Each reviewer prompt includes:
|
|||
- **Brief path** — `{brief_path}` (read on demand; do not inline).
|
||||
- **Rule catalogue** — reference to `lib/review/rule-catalogue.mjs`.
|
||||
|
||||
Collect each reviewer's trailing JSON block (last fenced `json` block in
|
||||
their output). Parse with `JSON.parse()`. On parse error, ask the agent
|
||||
to re-emit the JSON only.
|
||||
Collect each reviewer's trailing JSON block and **validate it against the
|
||||
reviewer-output schema** rather than merely parsing it. Run:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/lib/review/findings-schema.mjs --json <reviewer-output-file>
|
||||
```
|
||||
|
||||
`validateReviewerOutput` in `lib/review/findings-schema.mjs` extracts the
|
||||
last fenced `json` block, parses it, and schema-checks every finding
|
||||
(load-bearing fields: `file`, `rule_key` ∈ catalogue, `severity` ∈ enum,
|
||||
`line` integer ≥ 0). Parse failure and schema failure surface through the
|
||||
same stable error codes (`FINDINGS_NO_JSON_BLOCK`, `FINDINGS_PARSE_ERROR`,
|
||||
`FINDING_*`).
|
||||
|
||||
On any failure, re-ask **that reviewer** to re-emit a conforming JSON
|
||||
block only — quote the reported error codes/locations so the fix is
|
||||
targeted. **Bounded retries: N=2.** If the output still fails after 2
|
||||
re-asks, stop and report which reviewer produced non-conforming output;
|
||||
do not feed unvalidated findings to the coordinator.
|
||||
|
||||
In `quick` mode, launch only `code-correctness-reviewer`. The Executive
|
||||
Summary will note the brief-conformance pass was skipped.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue