Skip to content

fix(review): mitigation and confirmation verdicts must point at evidence that exists #845

Closed

Description

@dan-petty

Context & Rationale

Only INVALIDATED verdicts are checked against evidence (ai/review/verification.py:1647-1651). The MITIGATED branch (:1653-1659, with _verdict_status at :1419-1434) checks that a mechanism and a perimeter are present, never that they exist. derive_recommendation excludes MITIGATED findings (ai/review_schema.py:1153).

Probe through _apply_single_finding_verification:

  • Finding: HIGH, 'Command injection via os.system'.
  • Verdict: mechanism 'shlex.quote wrapper in safe_exec', perimeter files ['src/does/not/exist.py'], citation line 999 of a 4-line file.
  • Result: MITIGATED, verified_by=llm, no note, and the recommendation is APPROVE.
  • A model VERIFIED verdict that cites line 999 also passes unchecked.

Why _resolve_target_file can't be reused for containment. It accepts absolute paths and ../ escapes; it returned /etc/hostname. docs/SDLC.md:142 requires safe_resolve_subpath (core/paths.py:34).

Interaction with #789. On multi-page reviews, #789 makes every UNVERIFIED finding non-reportable (verification.py:2120-2123), so this fix needs #789 to take full effect.

Scope & Deliverables

  • Deliverable:
    • A MITIGATED verdict stays MITIGATED only when both of these hold:
      • every perimeter file resolves inside the reviewed tree through safe_resolve_subpath;
      • at least one identifier from the mechanism (via _extract_code_symbols) appears in a perimeter file or in the finding's file.
    • Otherwise the verdict becomes UNVERIFIED, stays reportable, and gets a verification_note naming the check that failed.
    • A verified_by=llm VERIFIED verdict whose citation line falls outside the file becomes UNVERIFIED with a note.
    • Checks are per verdict. A reply is never rejected or retried as a whole.
    • Use fix(review): verdicts bind across conflicting titles and absence wording shields nonexistent constructs #790's placeholder set if it has landed.
    • compute_verdict_distributions counts degraded mitigations.
    • Add golden cases to tests/golden/review_findings.json and tests/test_review_regression_harness.py.
  • Acceptance criteria:
    • The probe's fabricated mitigation gives (status, reportable) == ('UNVERIFIED', True). The note names src/does/not/exist.py, and the recommendation is 'REQUEST CHANGES', including on a multi-page review once fix(review): multi-page reviews drop unverified findings and can recommend approval #789 is in.
    • A mitigation whose perimeter file exists and contains the named mechanism stays MITIGATED.
    • An absolute or ../ perimeter path counts as unresolved.
    • A VERIFIED verdict citing a line outside the file is downgraded. An in-range citation stays VERIFIED.
    • In a reply with one fabricated verdict and one valid verdict, the valid one is unchanged.
    • assert_verdict_invariants holds on every path. The new tests run offline in at most 1 s.
  • Key questions:
    • Does a mitigation in a file outside a PR's materialised files count as unresolved? (proposed) Yes. Report it as UNVERIFIED and name the path.
  • Constraint:
    • Downgrade or annotate only (task-601).
    • No new network calls.

Strategic Alignment

Scope extended (2026-10-02, review session 20261001-224227)

Moved into v0.2.25 with the review-loop work the owner asked for. In that session 28 findings were MITIGATED, and all of them were reported and counted as defects:

  • 18 mechanisms contain no code identifier, for example "Input validation and sanitization".
  • 5 mechanisms describe the defect itself ("caught but not logged", "does not fully sanitize", "is expected to handle").
  • 2 perimeters point at .devops/review.md.
  • 11 carry verified=True, because _build_verdict_updates (verdicts.py:157) defaults MITIGATED to verified.

Added scope:

  • Self-negating mechanisms. A mechanism that negates itself (but (does )?not|is expected to|intended to|too permissive) becomes UNVERIFIED with a note.
  • Perimeters. A documentation or conventions file (.md) is not a perimeter.
  • The flag. MITIGATED sets verified=False.
  • Perimeter matching (triage idx 446). mitigations._normalize_path strips ./ as a prefix instead of .lstrip("./"), which also strips a leading dot from .devops/... and .github/... paths, and keeps exact matching for absolute paths.
  • Tests. Add the five self-negating mechanisms and the .devops/review.md perimeter to tests/test_verdict_writers.py, plus a .github/... perimeter path that must match itself.

Scope added 2026-10-03 from review sessions 20261003-005122 (S7) and 20261003-012555 (S8) (.data/review-evaluation-20261003-s7-s8.md, sections 3 and 6, D8): a confirmation or mitigation whose own reason refutes the claim is applied as given. In S8 qwen3-coder returned "verified": true on workspace.py:43 and main.py:84 with reasons saying no untrusted input reaches the import (cache llm_6818ef36, ledger row 10050; llm_f3d7fc26, row 10067). In S7 it returned 3 MITIGATED verdicts whose reasons argue the defect is absent (main.py:84, release.py:60, indexer.py:12) and 1 VERIFIED (test_security_bandit.py:142-154) whose reason claims "the test execution passes" although that criterion failed with No module named 'pytest'. The self-refutation guard (_without_self_refutation) only handles the reverse direction, an invalidation whose reason confirms. Since #948 ranks VERIFIED findings first, 2 of S8's top 8 report rows are such verdicts.

  • A VERIFIED or MITIGATED verdict whose reason negates the finding's claim (the same claim overlap and negation the self-refutation guard uses, mirrored), or that asserts a criterion passed when its recorded result failed, is not applied: the finding stays UNVERIFIED with its own note kind. Golden cases from the six cached replies llm_6818ef36, llm_f3d7fc26, llm_3ec3580c, llm_54a55488, llm_952922a2 and llm_4617de34, trimmed to fixtures.
  • A confirmation whose reason supports the claim is still applied; a test pins one such case.

Activity

  1. added
    type/bug
    scope/review
    priority/p1-high
    on Oct 1, 2026
  2. modified the milestones: v0.2.27, v0.2.25 on Oct 1, 2026
  3. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Closed by #1055, merged into release/v0.2.25.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  4. added a commit that references this issue on Oct 3, 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/p1-highscope/reviewtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions