feat(review): the code-correctness reviewer checks the repo's tracked instruction files

This commit is contained in:
Kjell Tore Guttormsen 2026-11-02 20:47:15 +01:00
commit fcba232ccd
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
10 changed files with 807 additions and 17 deletions

View file

@ -215,6 +215,12 @@ every file from Phase 3 into a treatment bucket:
| `deep-review` | Default for every changed file not in the other two rows — code, tests, `commands/`, `agents/`, `skills/` Markdown, and the instruction files `CLAUDE.md`, `AGENTS.md` and `.claude/rules/**`. |
| `summary-only` | `docs/**`, Markdown files at the repo root other than `CLAUDE.md` and `AGENTS.md` (README, CHANGELOG), `tests/fixtures/**`. |
A changed instruction file (`CLAUDE.md`, `AGENTS.md`, `.claude/rules/*.md`) at any depth, `docs/**` included, gets deep review: `instruction-scope.mjs --triage` lists them.
```bash
git -c core.quotePath=false diff --name-only -z {before_sha}..{after_sha} | xargs -0 node ${CLAUDE_PLUGIN_ROOT}/lib/review/instruction-scope.mjs --triage
```
Hard refuse-with-suggestion gates — use `AskUserQuestion`:
```
@ -426,7 +432,7 @@ a report."
| Agent | Mode-gated | Purpose |
|-------|------------|---------|
| `brief-conformance-reviewer` | Skipped in `quick` | Trace each Success Criterion + Non-Goal to delivered code. Emits findings tagged with rule_keys from the conformance/scope categories. |
| `code-correctness-reviewer` | Always runs | 7-dimension code review. Emits findings tagged with rule_keys from the correctness/security/maintenance/tests categories. |
| `code-correctness-reviewer` | Always runs | 8-dimension code review. Emits findings tagged with rule_keys from the correctness/security/maintenance/tests categories, plus the conformance-category instruction-file keys `CLAUDE_MD_DEVIATION` and `CLAUDE_MD_STALE`. |
Each reviewer prompt includes:
- **Diff context** — the unified diff from Phase 3, truncated per file
@ -436,6 +442,22 @@ Each reviewer prompt includes:
- **Brief path** — `{brief_path}` (read on demand; do not inline).
- **Rule catalogue** — reference to `lib/review/rule-catalogue.mjs`.
**The instruction set.** The `code-correctness-reviewer` prompt also gets the
repo's tracked instruction files for this diff, from `instruction-scope.mjs --set`
at `{after_sha}`:
```bash
git -c core.quotePath=false diff --name-only {before_sha}..{after_sha} > "{project_dir}/.review-changed.txt"
node ${CLAUDE_PLUGIN_ROOT}/lib/review/instruction-scope.mjs --set --repo . --sha {after_sha} --changed "{project_dir}/.review-changed.txt"
```
On exit 0, list its `files` under **Instruction files** and tell the reviewer
to check the diff against exactly these files and no other instruction file
(dimension 8, `CLAUDE_MD_DEVIATION` / `CLAUDE_MD_STALE`, MINOR). On exit 2,
tell it that none could be read; finalize (Phase 7) then sets every finding
under those two keys aside under Declined to Judge (`instruction-out-of-set`),
as it does any such finding whose `instruction_ref` is not in the set.
**From round 2** (`round` ≥ 2 from Phase 3), each reviewer prompt also gets
the round input:
- the round diff, `git diff {round_base}..{after_sha}`, beside the run's diff;