Skip to content

refactor(review): one finding verifier owns the verdict and its side effects #996

Closed

Description

@dan-petty

Context & Rationale

ai/review/verification.py is 2,230 lines with 100 private functions and no public one. Its entry point _validate_segment_findings (:2078-2140) takes 8 parameters and returns a 3-tuple; pipeline.py and runner.py import it, and tests patch it at three import sites. Tests import 18 underscored names from the module. Checked at 9c879ae.

A Finding reaches its Verdict through seven files: runner._run_orchestrator_review (:2147) → pipeline.execute_finding_verification (:2751) → _verify_single_file_payload (:2630) → verification._validate_segment_findings → _deterministic_pre_verification (:1346) → about 20 _check_*_hallucination functions → _check_catalog_hallucination (:1253) → common_hallucinations.is_common_hallucination / verify_ground_truth_hallucination → verdicts.apply_verdict → auto_record_invalidated_finding; then the LLM validation prompt → _bind_verdicts_to_findings → _apply_single_finding_verification (:1781) → review_environment.execute_finding_criteria → apply_verdict again; back in the pipeline a hand-written copy of 22 of the Finding's 30 fields (pipeline.py:2687-2708) → assert_verdict_invariants → files/*.json; stages/adversarial_debate may re-verdict.

  • apply_verdict has 32 call sites in 7 files (23 in verification.py) and an **extra_updates: Any escape hatch.
  • The human path, commands/review.py verify_finding (:1023), re-implements a Verdict's consequences in _record_verdict_side_effects (:993-1019).
  • pipeline.py and verification.py co-change in 20 of verification's 21 commits.

Deletion test: deterministic checks, catalog suppression, LLM binding, criteria execution and side-effect recording are one concept spread over five files. Collapsing them concentrates complexity.

Scope & Deliverables

Strategic Alignment

Scope added 2026-10-02: checked at 38517a8. #949 (e4ea2e0) moved the human path's verdict side effects into ai/review/adjudication.py (Verdict, judge_reported, judge_candidate, _record_entries). _record_verdict_side_effects no longer exists, and devops review verify (commands/review.py:1012) calls that module. #950 (v0.2.25, in flight) stops deterministic checkers from writing the learned catalog; today they still do (ai/review/verification.py:410-508, :1227-1229). After #950 a machine Verdict records nothing outside the session, and the only rule both paths share is verdicts.apply_verdict with assert_verdict_invariants. Counts at 38517a8: apply_verdict (verdicts.py:189, not :174) has 30 calls in 7 files, 23 of them in verification.py and 2 in the legacy dry-run builders that #995 deletes. **extra_updates is used at verification.py:1823 and review_environment.py:437. Tests import 37 underscored names from verification.py across 23 files, not 18. _validate_segment_findings (:2078-2140) is patched at 3 sites through 2 import paths. The 22-field copy-back is at pipeline.py:2687-2708. stages/adversarial_debate.py is a substring filter of known false positives run at reranking (pipeline.py:2871-2875), not a model debate. pipeline.py changed in 20 of verification.py's 22 commits. #987 (b1fddd0) moved pipeline.py lines after the baseline.

Acceptance criteria

  • The verifier module has one public entry point. It takes one file's findings and that file's context (numbered source, diff text, analysis metadata, conventions) and returns the same findings with verdicts. _validate_segment_findings and its 3-tuple are gone, and the pipeline calls the entry point once per file.
  • The pipeline copies no Finding field back after verification. A test gives a fake verifier verdicts that set each of the 22 fields copied today to a non-default value, and asserts that each value reaches the session's files.
  • apply_verdict has no **extra_updates. Its two users pass named fields.
  • The verifier takes its model through the review's client protocol (refactor(review): delete the legacy segment engine so the orchestrator is the only review engine #995) and the known-false-positive catalog as a parameter. Tests pass a fake model and an in-memory catalog, and patch no module path.
  • No test imports an underscored name from the verifier module. Each behaviour those 37 imports cover is tested through the entry point, or as a refactor(review): one rulebook for known false positives #770 rulebook record once that lands.
  • A test runs the verifier with an in-memory catalog and mitigation ledger, produces an INVALIDATED and a MITIGATED verdict, and asserts that both stores are unchanged.
  • Only verdicts.py assigns status, verified_by or verified_at on a finding under ai/review/. An AST test finds no attribute assignment to them elsewhere. It fails at 38517a8 on the copy-back (pipeline.py:2687-2708).
  • The tests run offline, with no model, network or scanner.
  • changelog.d/996.md records the change under ### Changed. CHANGELOG.md is not edited.
  • uv run devops ci passes.
  • (person-run) A path review of src/devops_cli/ai/review completes after the change, and devops review findings lists verdicts from both the deterministic checks and the model verifier.

Key questions

Activity

  1. added
    type/refactor
    scope/review
    priority/p2-medium
    on Oct 2, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Frozen by the evidence-first review redesign (#1137, owner direction of 2026-10-03): patches to the model generator and verifier stop, and tool-layer fixes continue. This item patches code that #1150 deletes (the verifier path in verification.py, the guards and verifier prompts, construct_validator.py, criteria_evidence.py, and the known-false-positive catalog). Its person-verdict path (adjudication.py) carries into #1150 as "person-recorded verdicts become suppressions".

    It stays open, labelled status/blocked, and closes as not planned with "Superseded by #1150" when that item lands. Until then, the interim is the tools-only review (--no-persona-review --no-verification). Do not start work on it.

  3. added
    status/blocked
    on Oct 3, 2026
  4. added this to the v0.2.34 milestone on Oct 10, 2026
  5. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Moved to v0.2.34: v0.2.34 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)

  6. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Superseded by #1150

  7. removed
    status/blocked
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/reviewtype/refactor

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions