Skip to content

fix(review): grep-only criteria neither verify nor invalidate a finding, and prompt examples stop teaching them #846

Closed

Description

@dan-petty

Context & Rationale

_evaluate_criteria_verdict (ai/review/review_environment.py:300-342) treats the two kinds of criteria differently:

  • If the only passing verification commands are tautological (git grep/grep, :292-297), the finding is capped at UNVERIFIED.
  • Any passing invalidation criterion, tautological or not, returns a final INVALIDATED with by=criteria (:306-331). For example, _evaluate_criteria_verdict(['git grep -n os.system app.py'], [], []) returns ('INVALIDATED', 'criteria', ...).

That verdict is final. Criteria run during deterministic pre-verification (verification.py:1276-1279), and only UNVERIFIED findings reach the model (:2039-2048). So a grep that merely finds the code a finding cites dismisses the finding.

The prompts contradict each other:

  • review_output_instruction.md:15 and compose.md:39 (the recompose system prompt, runner.py:1168) show an executable git grep verification criterion as the canonical example.
  • review.md:56 and verify_finding_system.md:38 call grep criteria tautological.

No test checks the shipped prompt examples against the executor.

Scope & Deliverables

  • Deliverable:
    • A passing invalidation criterion whose command is tautological, under the same classifier used for verification, yields UNVERIFIED with a note instead of INVALIDATED.
    • Replace both prompt examples with an allowlisted, non-tautological criterion: a python -c assertion over the cited code.
    • review.md and review_output_instruction.md state that grep-only criteria can neither verify nor invalidate.
    • A parametrised test extracts every executable criterion from the fenced JSON in src/devops_cli/ai/tasks/*.md and personas/*/prompt.md, and checks each one against validate_criteria_command and _is_tautological_verification_command.
  • Acceptance criteria:
    • A finding with only a passing grep invalidation criterion ends UNVERIFIED. A non-tautological passing invalidation criterion still gives INVALIDATED.
    • Golden case: a finding whose only invalidation criterion greps its own cited line stays reportable.
    • The prompt-example test fails on 308a71f and passes after the change.
    • The new tests run offline in at most 1 s.
  • Key questions:
  • Constraint: Act on each verdict separately; never reject a whole reply.

Strategic Alignment

  • Milestone: Backlog
  • Depends on: none

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 the grep rule alone would not have helped: 36 findings were VERIFIED by criteria, and none of their 37 passing commands checks the cited code.

  • 97% of passing python -c criteria (437 of 450) contain no assert, raise or sys.exit.
  • The top CRITICAL finding cites CVE-2021-44228 and was VERIFIED by python -c "import re; print(re.match(r'^[\w\W]*$','test content'))".
  • 59 of 61 criteria-INVALIDATED findings rest on the same kind of command.
  • tests/test_executable_criteria.py:225 and :283 require x = 1; assert x == 1 and assert 1 + 1 == 2 to verify and to invalidate.

Added scope. The prompt half moves to #951, which owns the prompt text; this item owns the executor.

  • Evidence rule, on both sides (review_environment.py:292-342):
    • A passing command counts only if its AST imports the cited module, or opens the cited path, AND contains assert, raise or sys.exit(<non-constant>).
    • pytest counts only on a test that imports the cited code.
    • grep, git grep, git log, wc, cat, head, tail and find never count.
    • A command that does not count is recorded in criteria_execution_results and leaves the finding UNVERIFIED for the model.
    • When both a verification and an invalidation criterion pass, the pair is non-discriminating: UNVERIFIED with a note.
  • Model-written verdict fields.
    • reset_verification_state also clears confidence_score, citation_line, mitigating_mechanism, perimeter_files, regression_test and criteria_execution_results.
    • A citation counts only from an explicit citation key, never from the echoed location.
    • The verifier input (_build_validation_prompt) no longer carries the reviewer's confidence_score, status, reportable, criteria_execution_results, verified_criteria_matched or thinking.
    • Confidence is clamped to [0, 1] on every write; 3 findings carried 2.0.
  • A refutation of the criteria is not a refutation of the code. An INVALIDATED verdict whose reason is about the criteria (tautolog|criteri\w+ (only|merely)|only confirms) and that has no explicit citation becomes UNVERIFIED. There were 14 in the session.
  • Verifier coverage.
    • New notes verifier-no-verdict and verifier-reply-unparsed (verification.py:2071-2078), counted in profile.json. In the session, 233 of 357 UNVERIFIED findings carried no note.
  • Verdict copy-back (pipeline.py:2673, triage idx 203). One VERDICT_FIELDS tuple next to apply_verdict holds every field the verifier owns, and the copy-back uses it.
  • Test hermeticity (triage idx 84). tests/test_finding_repetition_compression.py:62 stops reading the local .data cache.
  • Tests:
    • Invert test_executable_criteria.py:225 and :283.
    • A positive case: a temp app.py plus python -c "from app import f; assert f(...) == ..." verifies.
    • A golden replay of the session's three worst commands (the regex echo, git log --grep, python -c "import fastapi; print(...)") shows none of them settles a verdict.
  • Order. fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847 (criteria environment and timeout) lands with or right after this item, or the evidence rule leaves almost nothing verifiable: 34% of commands that import the subject timed out at 5 s.

Scope added 2026-10-02: in the branch reviews of release/v0.2.25, the response cache replayed 192 and 238 persona replies (sessions 20261002-163203 and 20261002-180320) but only 3 and 6 verifier replies, because the verifier prompt changes on every run. _build_validation_prompt serialises each finding with model_dump() and drops only verified and mitigated (ai/review/verification.py:314-323). The deliverable above removes six reviewer fields. Criteria execution also writes invalidated_criteria_matched (ai/review/review_environment.py:414-422) and, on an UNVERIFIED outcome, invalidation_reason (review_environment.py:402, written at ai/review/verdicts.py:168). Both change when a criterion times out, and 28-45% of executions hit the 5 s limit in those sessions. Removing fields one by one leaves the next one in, so this item tests byte identity directly. finding_id is safe to keep: it is the finding's position in that call (verification.py:2103-2113). The release review evaluation (.data/review-evaluation-20261002.md, section 1.4) estimates 17-24 more verifier replays per run and 10-15 fewer status changes on unchanged code once it holds. One caveat: a replayed wrong verdict then repeats in every run.

  • Verifying the same finding twice produces byte-identical verifier prompts. A test builds the prompt for one finding in two runs that differ only in criteria durations and stdout, one timed-out criterion, the reviewer's confidence and the invalidation_reason a timeout leaves. It asserts the two prompts are equal. RAG is stubbed, and the test runs offline in under 1 s. It fails at 38517a8.
  • The findings block is built from an allowlist of the claim's own fields (finding_id, title, description, location, severity, fix, references, category, observed and expected values, and the criteria as written), not from model_dump() minus a denylist. A test asserts the serialised keys equal the allowlist, so a field added to Finding later stays out of the verifier prompt until someone adds it.
  • With the response cache on, verifying the same unchanged file twice reaches the model once. The test uses the real client over a fake HTTP transport, as tests/test_ai_client_providers_and_embeddings.py does for persona calls, and runs offline.

Scope added 2026-10-02 from review session 20261002-214641 (.data/review-evaluation-20261002-s6.md, sections 1 and 7): a verifier reply cut at its token cap decided a verdict. JSON repair (core/serialization.py, since 22bba04) salvaged the truncated reply for ai/mcp/server.py:202 into an INVALIDATED verdict whose reason stops mid-sentence. The earlier evaluation's statement that a cut reply binds no verdict was wrong. In the same session 9 reported entries had no verdict: 5 withdrawn as self-refutations, 3 cut and 1 inconclusive.

  • A verifier reply whose finish reason is length binds no verdict. Its findings stay UNVERIFIED with the no-verdict note naming the cut. A test feeds a stub reply cut mid-JSON that the repair path would salvage into INVALIDATED and asserts no verdict is applied.
  • The no-verdict note also covers a withdrawn self-refutation and an inconclusive reply, so every reported UNVERIFIED finding says why it has no verdict.

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 #1035, 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