Skip to content

feat(code-review): scope backstop and repeat runs to the unreviewed delta - #2199

Merged
bdfinst merged 1 commit into
mainfrom
feat/2167-verdict-ledger-consume
Sep 23, 2026
Merged

bdfinst merged 1 commit into
mainfrom
feat/2167-verdict-ledger-consume

Conversation

@bdfinst

@bdfinst bdfinst commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • New scripts/verdict_scope.py resolver consults the per-lens verdict ledger (feat(hooks): record per-lens review verdicts bound to a content hash #2166) and skips dispatching lens L against file F only on an exact (L, F, current-content-hash) match whose most-recent row is pass — fail-closed everywhere else.
  • Wired into /code-review step 4 (per-agent dispatch, with a new ledgerSkipped --json field and "report loudly, never silently" prose) and into /build's sub-steps 4/6 checkpoints (which now also emit the dispatch-prompt scope marker so their own dispatches get recorded) — Step 6's backstop scopes to the unreviewed delta for free, with no Step-6-specific code.
  • A dedicated backstop review panel (correctness/security/structure/test/test-smell/spec-compliance/doc/arch-review) surfaced 5 real issues, all fixed and covered by new tests:
    • _load_json_arg crashed (ENAMETOOLONG) on a realistic multi-lens, multi-file --lens-files payload — verified by reproduction before fixing.
    • The ledger's path canonicalization was writer-only; added a shared hooks/lib/review_verdicts.canonical_path used by both the writer and verdict_scope.py's reader.
    • The verdict recorder could record pass for an in-scope file on a non-clean (fail/warn) lens result when no issue happened to name that specific file; it now marks every in-scope file findings in that case.
    • The ledger is untrusted, unauthenticated local state — load_verdicts now refuses a ledger tracked by git, closing a path where a forged, committed row could suppress security-review on a malicious file.
    • Fixed a field-naming mismatch between output-format.md's ledgerSkipped example and the ledger's real snake_case schema.

Test Plan

  • python3 -m pytest plugins/dev-team/tests tests/repo tests/agents tests/commands tests/docs tests/knowledge tests/stack_aware tests/skills tests/scripts tests/hooks -q — 11239 passed, 0 failed, 48 skipped.
  • scripts/check_md_references.py and plugins/dev-team/hooks/lib/build_knowledge_index.py clean.
  • ruff check clean on all new/changed Python files.
  • --lens-files crash reproduced against unpatched code, then confirmed fixed.
  • Cold/warm identical-findings CLI proof against a real emit_review_verdict-written ledger (test_cli_warm_run_after_real_pass_verdicts_skips_unchanged_files_only).
  • Deliberate saboteur test proving resolve_dispatch's gate can actually fail (per this repo's own "a gate that cannot fail is worse than no gate" rule).
  • pre-push local CI gate (full suite + hook/script unit tests + static checks) green before push.

Closes #2167
Part of #2164


🤖 Generated with Claude Code

https://claude.ai/code/session_01KGHpm7gtqNb8NM2Smf76u7


Generated by Claude Code

…elta

Implements #2167 (part of #2164): a new scripts/verdict_scope.py resolver
consults the per-lens verdict ledger (#2166) before dispatching a review
lens, skipping only an exact (lens, file, current-content-hash) match whose
most-recent ledger row is `pass`. Wired into /code-review step 4's per-agent
dispatch (with loud, never-silent reporting via a new `ledgerSkipped`
output-format field) and into /build's sub-steps 4/6 checkpoints (which now
also emit the dispatch-prompt scope marker so their own dispatches get
recorded), so Step 6's backstop scopes to the unreviewed delta for free.

Backstop review (correctness/security/structure/test/test-smell/
spec-compliance/doc/arch-review) surfaced and fixed:
- _load_json_arg crashed (ENAMETOOLONG) on a realistic multi-lens,
  multi-file --lens-files payload; now tries an inline JSON parse first.
- The ledger's own file_path/hash canonicalization was writer-only; added a
  shared hooks/lib/review_verdicts.canonical_path used by both the writer
  and the reader, closing a silent-miss (never a false skip) gap.
- The verdict recorder could record `pass` for an in-scope file on a
  non-clean (fail/warn) lens result when no issue happened to name that
  file; it now marks every in-scope file `findings` in that case.
- The ledger is untrusted, unauthenticated local state; load_verdicts now
  refuses a ledger that is tracked by git, closing a self-certification
  path where a forged, committed row could suppress security-review.
- Fixed a field-naming mismatch between output-format.md's ledgerSkipped
  example and the ledger's real snake_case schema.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KGHpm7gtqNb8NM2Smf76u7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(code-review): scope the backstop and repeat runs to the unreviewed delta

2 participants