Skip to content

fix(review): a review scans a worktree of the reviewed commit, never hands a deleted file to a tool, and reports which files each tool scanned #1047

Closed

Description

@dan-petty

Problem

Re-scoped on 2026-10-03 as phase P1a of the evidence-first review (#1137). The original live defect stays the core of this item: a branch review read the checkout, not the reviewed commit, for metadata, scanners, verifier context and the citation guard (S9: 2 verdicts changed and 9 wrong cited_code records). The verifier and the citation guard are deleted by #1150; metadata and scanners now read a worktree of the commit. Until this lands, the tools-only review (--no-persona-review --no-verification) on a clean checkout is the interim.

Acceptance criteria

  • The change set comes from git diff --name-status -M <base>...<commit>. D entries are never targets, and renames keep the old path (fix(analyze): renamed files keep their removed symbols in branch analysis #901).
  • Worktrees:
    • A detached worktree of the commit, and of the base for branch and PR reviews, lives under the user data root, outside every repository, and is removed with the session.
    • PR heads come from refs/pull/N/head; when that is not possible, the run is marked "partial context".
    • Path reviews of uncommitted work scan in place and say so.
  • From fix(review): a path review of single files runs its criteria from the repository root, not from the file's folder #1038: a path review of single files resolves its root with git rev-parse --show-toplevel, not the file's parent (commands/review.py:340). 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's location check against git ls-tree needs it.
  • Pre-analysis of the worktree reuses the checkout's cached metadata for every file whose content hash matches the commit's blob, and analyzes only the others (from the original body: 1,668 files took 121 s serially without reuse, against 9.6 s cached).
  • The original regression test passes: in a tmp_path repository with a base commit, a branch commit that changes app.py and an uncommitted edit that adds a function extra, the branch review's metadata for app.py has the commit's content_hash (sha256 of git show <commit>:app.py) and no extra in key_symbols.
  • Path classes (src, test, fixture, iac, docs) come from .devops/review.toml at the base revision. Fixtures and golden sets go to the secret scanner only.
  • A coverage matrix per (tool, file) records scanned, skipped(reason), failed(reason), timed out after N s, not installed or canary failed. It goes into profile.json and a review.md "Coverage" section.
    • Where a tool reports what it scanned, its list is compared with its targets: Semgrep paths.scanned, Bandit per-file metrics, osv-scanner sources.
    • Other tools: the targets are pre-parsed by devops-cli (YAML for kube-linter and Pluto, readability for gitleaks), and coverage is marked "inferred".
    • One unreadable file fails only itself.
  • The gitleaks regex fallback is deleted. A missing binary reads "not installed".
  • (person-run) On the S11 and loop inputs, kube-linter and Pluto show "ran" with per-file counts, and every applicable tool ran or is listed.
  • 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/bug
    scope/review
    priority/p2-medium
    on Oct 3, 2026
  2. added
    priority/p1-high
    and removed
    priority/p2-medium
    on Oct 3, 2026
  3. changed the title [-]fix(review): a branch review reads the commit it reviews, not the checkout, for metadata, scanners, verifier context and the citation guard[/-] [+]fix(review): a review scans a worktree of the reviewed commit, never hands a deleted file to a tool, and reports which files each tool scanned[/+] 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

    #1277, merged into release/v0.2.28 as 97b27fc.

    Resolves #1047

    19 file(s) changed.

    How it was verified

    Check runs at 80dd8ac:

    • 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-1047-review-worktree.md:

    • Worktree isolation: In a git repo with base commit, branch commit changing app.py, and uncommitted working tree edit adding extra(), branch review metadata for app.py has commit content_hash and does not contain extra in key_symbols.
    • Deleted files excluded: Deleted files in a change set are marked deleted and excluded from all_files, never passed to static analyzers.
    • Rename tracking: Renamed files keep the old path in old_path and track the target path at head for analysis.
    • Pre-analysis cache reuse: Pre-analysis reuses cached metadata when content hash matches commit blob even if mtime is newer.
    • PR head fetching: PR heads are fetched from refs/pull/N/head; if unavailable, marked with partial_context=True and a clear console warning.
    • Path classes: Path classes loaded from .devops/review.toml; fixtures and golden sets are scanned by Gitleaks only.
    • Coverage matrix: Coverage matrix per (tool, file) recorded in profile.json and rendered in review.md under ## Coverage.
    • Gitleaks fallback removed: Missing binary yields status not installed without regex fallback.
    • Architectural invariants: Nesting depth $\le 5$ and complexity $\le 10$ across all modules.
    • Pending a person: uv run devops ci on the delivering tree.
    • Not checked when merged: remote GitHub Actions CI workflows.
  7. added a commit that references this issue on Oct 7, 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