Skip to content

feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions #871

Closed

Description

@dan-petty

Problem

Re-scoped on 2026-10-03 as phase P1a of the evidence-first review (#1137). The original scope, that every finding records its producer (scanner rule or serving model), is kept: the producer is the anchor below. Producer-split precision, which replaced the original review stats --by producer, is #1138's; model findings and their served_by fields go with #1151.

  • No finding records its producer. Scanner output is stamped persona="devsecops" [code: ai/review/pipeline.py:463-472], and calibration recognizes secret scanners by title prefix [code: ai/review/calibration.py:80-91].
  • Model claims reach the top of the report. app/shell.py:4 names no file in the tree, yet it was VERIFIED and row 1 in 11/11 runs (D13) [measured: loop §5].
  • Models set severity, state and location:
    • the verifier dropped 47/125 valid tool candidate-runs;
    • D2 lowered 49/49 kept read-only-root-fs findings;
    • D18 moved 8 findings to other files without recording it [measured: loop §4–5].
  • A change can suppress its own findings. An inline marker (# noqa, # nosec, # nosemgrep) added by the change itself hides that change's finding [inference].
  • The profile and the report disagree on counts (D6).

Acceptance criteria

  • A frozen Finding is built only by review/admission.py::admit().
    • A test asserts that no other module constructs one.
    • The test reads source text first and parses only files containing Finding(, as test_no_module_runs_python_in_process does [code: tests/test_architectural_invariants.py:214-234]. A full parse of 504 files takes 1.63 s [measured: c-feasibility].
  • Anchors: ToolAnchor(run_id, result_index, rule_id) and AdvisoryAnchor(db, snapshot, advisory_id, purl, locked_version), behind an Anchor protocol (kind, location, recheck).
  • Location check:
    • Regions: the path is in git ls-tree -r <commit>, the lines are within the file, and region_sha256 is stored.
    • Logical locations: the object (kind/namespace/name) exists in the manifest at the commit, or the package@version exists in the lockfile.
    • Absolute paths: made relative when inside the worktree; otherwise rejected.
    • Typed rejections are counted in profile.json: path-not-in-commit, line-out-of-range, object-not-in-commit, file-not-scanned, tool-not-run, canary-failed and no-anchor.
    • A fixture tree without app/shell.py rejects a result that cites it.
  • fix(review): location parsing keeps placeholder, prose-laden and truncated locations #788's persona-location half (placeholder, prose and truncated locations) is covered by the location check above; its scanner-path half lands in P0 as fix(review): location parsing keeps placeholder, prose-laden and truncated locations #788.
  • Recording a new known false positive is one edit (refactor(review): one rulebook for known false positives #770's constraint): one .devops/review.toml suppression with a reason and an expiry.
  • Severity is a pure function of the SARIF level, rule severity, security-severity or CVSS, and a policy table in .devops/review.toml (path-class caps). The derivation is stored and covered by a table-driven test.
  • State: OPEN, SUPPRESSED, FIXED or CONFIRMED.
    • OPEN comes from a tool run.
    • FIXED means the finding is absent from a later run of the same tool version and config.
    • SUPPRESSED comes from .devops/review.toml read at the base revision (by fingerprint, rule or path glob, each with a reason and an expiry), or from an inline marker that exists on the matching line at the base revision.
    • CONFIRMED comes only from a person's valid verdict (feat(review): feedback export counts each review subject once and keeps every human verdict #877) or a replayed observation (P6).
    • A transition-table test follows assert_verdict_invariants [code: ai/review/verdicts.py:145-191].
  • Inline markers.
    • Tools run with their inline suppressions ignored: ruff --ignore-noqa and bandit --ignore-nosec [measured: help output]; Semgrep --disable-nosem [code: semgrep/commands/scan.py:243, via c-fidelity].
    • Markers added by the change are listed as "suppressed by this change", and the finding stays OPEN.
  • The test-path policy from fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024 is a set of suppressions with reasons. It covers B103 at test_crypto_tls.py:243 (VERIFIED 10/10, false).
  • Branch and PR reviews: introduced when the fingerprint is absent from the base revision's run of the same tool version and config, otherwise preexisting.
  • findings.sarif (security/sarif.py) carries tool, version, rule, fingerprint v2, logicalLocations, partialFingerprints and baselineState. from_sarif keeps the tool version, partialFingerprints and rule properties [code: security/sarif.py:395-414]. findings.sarif never contains model output.
  • review.md sections: introduced findings; pre-existing findings in changed files; suppressed (with expiry, and suppressed by this change).
  • profile.json and findings.json counts agree.
  • Two runs on a fixture tree with recorded outputs and equal input digests produce byte-identical findings.json and findings.sarif, apart from the run id and timestamps.
  • (person-run) On the S11 and loop inputs, every row names tool, version and rule, and 0 rows fall outside the tree.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
  • changelog.d/<n>.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Key questions

Strategic alignment

Activity

  1. added
    type/feature
    scope/review
    priority/p2-medium
    on Oct 1, 2026
  2. changed the title [-]feat(review): findings record their producer: scanner rule or serving model[/-] [+]feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions[/+] on Oct 3, 2026
  3. added
    priority/p1-high
    and removed
    priority/p2-medium
    on Oct 3, 2026
  4. added this to the v0.2.28 milestone on Oct 6, 2026
  5. dan-petty-bot commented on Oct 6, 2026

    @dan-petty-bot
    Collaborator

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

  6. dan-petty-bot commented on Oct 7, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1278, merged into release/v0.2.28 as fca29e9.

    Problem

    Prior to this change, review findings did not record their producer anchor, scanner output was stamped with generic personae, and model hallucinations or invalid file paths (such as app/shell.py) could reach the top of review reports. Furthermore, inline markers added by a change could inadvertently suppress that change's own findings, and profile.json and findings.json could disagree on counts.

    Closes #871.

    22 file(s) changed.

    How it was verified

    Check runs at aa3a9c8:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-871-finding-admission.md:

    • A frozen Finding is built only by review/admission.py::admit(), verified by AST architectural invariant test (test_finding_is_constructed_only_by_admission).
    • Anchors: ToolAnchor(run_id, result_index, rule_id) and AdvisoryAnchor(db, snapshot, advisory_id, purl, locked_version) satisfy Anchor protocol (test_anchor_protocol_and_implementations).
    • Location check: paths verified in commit tree, line bounds enforced, region_sha256 stored, logical locations verified against manifests/lockfiles, absolute paths normalized or rejected (test_location_check_and_typed_rejections).
    • Typed rejections counted in profile.json: path-not-in-commit, line-out-of-range, object-not-in-commit, file-not-scanned, tool-not-run, canary-failed, and no-anchor.
    • Fixture tree without app/shell.py rejects a result citing it (test_location_check_and_typed_rejections).
    • Severity is a pure function of SARIF level, rule severity, CVSS, and .devops/review.toml caps with derivation recorded (test_severity_derivation_table).
    • State transitions follow lifecycle invariants (OPEN, SUPPRESSED, FIXED, CONFIRMED) and valid confirmation rules (test_state_transitions_and_invariants).
    • Tools run with inline suppressions ignored (--ignore-nosec, --disable-nosem); markers added by change stay OPEN with suppressed_by_change=True (test_suppressions_and_inline_markers).
    • Test-path policy suppression from fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024 configured in .devops/review.toml covering B103 on test suites with reason and expiry.
    • Branch and PR reviews distinguish introduced vs preexisting based on base revision fingerprint presence (test_introduced_vs_preexisting_branch_reviews).
    • findings.sarif carries tool version, fingerprint v2, partialFingerprints, rule_properties, and never contains model output (test_sarif_roundtrip_preserves_version_and_properties).
    • review.md renders ## Introduced Findings, ## Pre-existing Findings in Changed Files, and ## Suppressed Findings (test_review_markdown_sections).
    • profile.json and findings.json counts agree (test_profile_and_findings_counts_agree).
    • Two runs on fixture tree with equal input digests produce byte-identical findings.json and findings.sarif (test_two_runs_fixture_tree_byte_identical).
    • Offline tests with recorded tool outputs execute under 1 second without network or model calls.
    • Changelog fragment changelog.d/871.md added under ### Added.
    • Pending a person: On the S11 and loop inputs, verify every row names tool, version and rule, and 0 rows fall outside the tree.
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/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions