Skip to content

fix(review): a correct refutation stands when the guard's evidence is a path token, a citation inside the finding's own lines, or generic scanner wording #1021

Closed as not planned

Description

@dan-petty

Problem

Two guards that protect findings from hallucinated refutations undo correct ones. In review session 20261002-205520 (S5, the first branch review after #951, at 38517a8), 11 of 19 raw verifier refutations were overturned (58%, against 9 of 43 in S3 and 7 of 42 in S4). 10 of the 11 refutations were correct, and the overturned findings are 10 of S5's 24 reported entries (.data/review-evaluation-20261002-s5.md, section 5.3). Had they stood, about 15 entries would have been reported. S6 (20261002-214641) replays the same verdicts from the cache.

How each guard misfires (lines at 79e1e93):

  • A path token becomes the construct. extract_finding_construct_candidates (src/devops_cli/ai/review/construct_validator.py:228-243) takes symbols from the title and description. For 4 Semgrep findings (indexer, qdrant, and settings twice), the only candidate is devops_cli, taken from the absolute /workspaces/... path in the scanner's description. No cited line contains it, so _validate_citation_line (src/devops_cli/ai/review/verification.py:1615-1668) downgrades the refutation to UNVERIFIED. The same token drives _find_text_relocation (construct_validator.py:271-277), which moved those findings to the first line mentioning devops_cli: the import lines indexer.py:12, qdrant.py:18 and settings.py:19. That is the mechanism behind fix(review): location parsing keeps placeholder, prose-laden and truncated locations #788's wrong-line relocations.
  • The citation check reads one line. For tests/test_ai_request_priority.py, the verifier cited line 200, but the assertion is on line 202, inside the finding's own range 201-202. _validate_citation_line reads only the cited line (verification.py:1654). The verifier also miscites lines while quoting the right one (it cited settings.py:678 while quoting line 656).
  • Self-refutation withdrawal on generic words. _without_self_refutation (verification.py:1550-1567) withdraws an invalidation whose reason "confirms" the finding when the reason's words overlap the finding's claims at _RESTATEMENT_OVERLAP = 0.6 (:1511). On 4 kube-linter findings, the shared words are scanner boilerplate (kube, linter, security, warning), at 0.667. On the task-593 finding, _NEGATION (:1508-1510) misses "incorrectly", so a negating reason reads as a confirmation.

The guards still do their job once: the 11th overturned refutation, on tests/test_review_prompt_consistency.py:434-439, was hallucinated (it said line 439 is blank; it holds exec(code, …)), and the guard rightly distrusted it. The fix must keep that case.

Acceptance criteria

  • Path components never become construct candidates or relocation anchors. A candidate that occurs only inside a filesystem path in the finding's text (a segment between / separators, or the package name of the reviewed file's own path) is dropped. A test with a Semgrep finding whose description holds /workspaces/x/src/devops_cli/ai/rag/indexer.py gets no devops_cli candidate and is not relocated.
  • A refutation's citation counts when the cited line or any line of the finding's own cited range holds a construct token, or the quoted text in the reason matches a line within 3 lines of the citation that lies inside the finding's range. A test replays the test_ai_request_priority.py case: the refutation stands.
  • The restatement overlap ignores scanner boilerplate words (the scanner's name and its rule-title vocabulary, kept as a named table beside the guard), and _NEGATION recognises "incorrect", "incorrectly", "false", "falsely", "mistaken" and "wrongly". Tests replay the 4 kube-linter findings and the task-593 finding: no withdrawal.
  • Golden replays from S5's saved verdicts (.data/reviews/20261002-205520, fixtures trimmed to the finding, the verifier item and the cited lines): indexer, qdrant, settings twice and test_ai_request_priority keep INVALIDATED; the 4 kube-linter findings and task-593 keep INVALIDATED; test_review_prompt_consistency stays UNVERIFIED (the hallucinated refutation is still blocked).
  • The tests run offline, call no model, and each runs well under 1 s.
  • changelog.d/1021.md records the fix under ### Fixed. CHANGELOG.md is not edited.
  • uv run devops ci passes.
  • (person-run) A branch review of the same commit with --no-cache reports about 15 entries where S5 reported 24, with no valid finding lost against S5's classification (section 3.1 of the S5 evaluation).

Key questions

Depends on: none.
Order: after #846 (v0.2.25), which edits the same verification module; #1018 and #996 follow.
Related: #788, #1018, #996, #846, #948 (severity of what remains).

Scope added 2026-10-02 from review session 20261002-214641 (.data/review-evaluation-20261002-s6.md, section 4.1): scanner findings feed the same guard spurious construct tokens from two more sources.

  • Bandit writes its description as "Bandit {test_name} flaw detected at line N" (security/bandit.py:34), so the construct check took the rule name hardcoded_tmp_directory as the cited code and invalidated 3 B108 findings because that "code" is absent. The outcome was right; the reason was wrong.

  • Semgrep's finding on tests/test_pr_cmd.py:1589 was invalidated on the file stem test_pr_cmd.

  • Construct candidates never come from a scanner's rule or test name, or from the stem of the reviewed file. Golden cases: S6's 3 B108 candidates get no deterministic construct verdict from a rule-name token, and test_pr_cmd.py:1589 none from its file stem.

Scope added 2026-10-03 from review sessions 20261003-005122 (S7, at b6847e9) and 20261003-012555 (S8, at 0ce4736) (.data/review-evaluation-20261003-s7-s8.md, sections 3, 6 and 7). Lines are at da50329. The construct guard downgraded 3 INVALIDATED verdicts in S7 and 9 in S8, all on false findings. In S8 it was the largest single cause of UNVERIFIED (9 of 17 candidates). All 9 S8 downgrades reproduce at da50329 through _validate_citation_line (src/devops_cli/ai/review/verification.py:1734-1790). Four of them are cases this issue already names: qdrant.py:18, settings.py:19 twice and test_ai_request_priority.py:201. The settings pair cite the except lines :653 and :655, not the logger calls at :656 and :659, so they clear only because no construct token remains once path tokens are dropped. Four gaps remain.

  • A citation inside the construct's own call. tests/test_scan_outcomes_and_gating.py:322 is a false finding about a test fixture. Both runs refuted it with evidence (S7 cache llm_5a3a2f22…, ledger row 10002; S8 llm_76a0d6bf…, row 10057: "Line 322 constructs a subprocess.TimeoutExpired with a command list…"). The candidates are subprocess.TimeoutExpired, timeoutexpired, subprocess and the test's name. subprocess.TimeoutExpired( is on :321, inside a pytest.mark.parametrize decorator, and the call spans 321-323. Line 322 holds only its arguments. _check_ast_symbol_at_line (verification.py:1713-1731) compares definition symbols only, and the test function's span starts at its def on :328, so the decorator is outside it. collect_ast_constructs (src/devops_cli/ai/review/construct_validator.py:181) already yields a call construct subprocess.TimeoutExpired spanning 321-323, but the guard does not use it. The finding's range is the single line 322, so this issue's "inside the finding's own range" criterion does not reach it.

  • "Cannot verify" refutations. The 4 kube-linter dangling-service findings on k8s/monitoring/service-aliases.yaml that this issue's golden replay names got different replies in S8. qwen3-coder (row 10062, cache llm_baf9dfc4…) refuted all 4 because "the issue cannot be verified from the given code excerpt". The replies matched the prompt's Location rule (src/devops_cli/ai/tasks/verify_finding_system.md:22), although the path resolves, and one reason agrees the Service "lacks matching pod labels". The prompt asks for the opposite when the settling code is not shown: "Unverified is the answer" (verify_finding_system.md:11), and for a claimed absence, "leave the finding unverified" (:41). S5's replies (llm_2741b32c…) carry no evidence either. They call the finding "a configuration concern" and "not a security vulnerability", cite ports: or - name: lines (14, 34, 53, 72) and name no pods. Replayed at da50329 with the withdrawal fixed as this issue specifies, the construct guard still downgrades all 4 S5 replies, because the candidates, each Service's quoted name and its namespace monitoring, are on none of the cited lines. So "the 4 kube-linter findings keep INVALIDATED" can pass only by loosening the guard for replies that hold no evidence. fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024 drops dangling-service from the review's scanners, which would make these 4 cases moot. The same wording appears in 3 other S7/S8 refutations, all applied as INVALIDATED. S7's reply on pyproject.toml:133-134 (llm_f67fcf25…, row 10001) says "this finding cannot be validated or invalidated based on the provided code alone". S8's reply on the same finding (llm_f32dcd98…, row 10049) says "dependency advisories … cannot be verified", about advisories, not the claim. S8's reply on chunker.py:395 (llm_b39f5376…, row 10058) says "we cannot verify against the exact line". No S5 or S6 refutation uses the wording.

  • A rejected verdict still writes. _apply_single_finding_verification (verification.py:1928-1993) applies the verifier's severity and severity_raw (:1984-1985, from _resolve_finding_attributes at :1876-1896), confidence (:1982), location, observed and expected values (:1986-1988) and matched criteria (:1989-1990), whatever status the guards leave. Severity is new with fix(review): grep-only criteria neither verify nor invalidate a finding, and prompt examples stop teaching them #846. Confidence and the matched lists were already written in S5 and S6. S8's qdrant.py:18 shows it: the rejected refutation (llm_dc9a0d9b…, row 10046) took the finding from MEDIUM to LOW with severity_raw MEDIUM, set confidence 0.9 and two matched invalidation criteria, and the report shows it as LOW. Replayed at da50329 with the finding's location made relative, the same rejected verdict also rewrites the location to the verifier's absolute /workspaces/... path. That refutation cites :165, inside the finding's original range 164-166, and its only candidate is the path token devops_cli. Once this issue's path-token fix lands it stands, so it cannot be this defect's golden case.

  • The guard's note has no kind. The note is free text ("Refutation cited line N does not contain cited construct tokens; downgraded to UNVERIFIED", verification.py:1786). _unverified_note_counts (src/devops_cli/ai/review_schema.py:1632-1645) counts it as other, as its docstring documents. S8's profile.json shows other: 9, so S8's largest cause of UNVERIFIED cannot be read from the profile.

  • A refutation's citation also counts when the cited line lies inside the span of a call construct whose name matches a construct token (collect_ast_constructs). A golden replay of tests/test_scan_outcomes_and_gating.py:322 with S7's and S8's verdicts keeps INVALIDATED, and fails on the current code. The same verdict citing :320 or :324, outside the call, is still downgraded. The hallucinated test_review_prompt_consistency refutation still ends UNVERIFIED.

  • A refutation whose reason says the finding, its claim or the issue cannot be verified, validated or confirmed from the code shown is not applied. The finding ends UNVERIFIED with verifier-inconclusive, whatever the citation guard decides. Golden: S8's 4 dangling-service verdicts (llm_baf9dfc4…) and S7's pyproject.toml:133-134 verdict (llm_f67fcf25…), which fails on the current code (INVALIDATED). Not caught: the evidence-based S8 refutations of qdrant.py:18, test_ai_request_priority.py:201 and test_scan_outcomes_and_gating.py:322, and the two S8 replies whose wording is about something else (llm_f32dcd98…, advisories; llm_b39f5376…, the line).

  • The golden expectation for the 4 dangling-service findings changes. The no-withdrawal test on S5's replies stays. A synthetic refutation that cites a line of the Service's selector and names the workload or chart whose pod labels match it keeps INVALIDATED. S5's and S8's replies have neither, and all 8 end UNVERIFIED with a note. If fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024 lands first, these 4 golden cases are dropped instead.

  • A verdict that a guard turns into UNVERIFIED writes only its note. That covers the citation guard, the rule above, the criteria-refutation rule (verification.py:1837-1838), the self-refutation withdrawal and the MITIGATED degradation (:1604-1618, :1855-1857). The finding keeps its severity, severity_raw, confidence, location, citation line, observed and expected values and matched-criteria lists. Golden: S8's qdrant.py:18 verdict (llm_dc9a0d9b…) with its citation_line removed, which the guard still rejects after this fix, on a MEDIUM finding with a relative location. The finding stays MEDIUM with no severity_raw, keeps its location, and its confidence and matched lists are unchanged. It fails on the current code (LOW, raw MEDIUM, confidence 0.9, two matched criteria, absolute location).

  • The citation guard's notes name a kind of their own in CONST_VERIFICATION_NOTE_KINDS (src/devops_cli/config/constants.py:2919-2927), with the detail after : . This covers all four notes _validate_citation_line writes: no cited line, out of range, past the end of the file, and no construct token. A test gives _unverified_note_counts one UNVERIFIED finding per note and counts 4 under that kind and none under other. It fails on the current code, which counts them as other.

Scope added 2026-10-03 from review session 20261003-021501 (S9; .data/review-evaluation-20261003-s9.md, section 4): a fresh refutation of dryrun:99 cited the adjacent line :98 and was downgraded, another case for scope (a). S9's 9 "other" notes were 7 S8 verdicts replayed through the guard, the dryrun refutation and 1 checkout artifact, which supports scope (d): each guard reason gets its own note kind. D2 recurred (qdrant:18 MEDIUM to LOW).

Activity

  1. added
    type/bug
    scope/review
    priority/p1-high
    on Oct 2, 2026
  2. added this to the v0.2.29 milestone on Oct 2, 2026
  3. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    What S10 adds (review session 20261003-034353, release/v0.2.25 at d6ebe97; .data/review-evaluation-20261003-s10.md, section 3).

  4. 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 v0.2.29 slot is freed when it closes; the evidence comment stays as input to #1150. In S5 its guards overturned 10 correct refutations.

    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.

  5. added
    status/blocked
    on Oct 3, 2026
  6. removed this from the v0.2.29 milestone on Oct 8, 2026
  7. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: a Blocked item can't join a starting release (v0.2.29). (devops roadmap reprioritize)

  8. modified the milestones: v0.2.34, v0.2.35 on Oct 9, 2026
  9. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: a Blocked item can't join a starting release (v0.2.35). (devops roadmap reprioritize)

  10. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned in the 2026-10-17 unblocking review: Superseded by #1150. The construct, citation and self-refutation guards are deleted. The kube-linter dangling-service part stays with #1024.

  11. removed
    status/blocked
    on Oct 17, 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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions