Skip to content

fix(review): a path review of single files runs its criteria from the repository root, not from the file's folder #1038

Closed as not planned

Description

@dan-petty

Problem

devops review path <file> with one target sets target_dir to the file's parent folder: target_dir = target_resolved if target_resolved.is_dir() else target_resolved.parent (src/devops_cli/commands/review.py:333, at 0ce4736). The orchestrator passes it to verification as repo_root (ai/review/pipeline.py:2866), and execute_finding_criteria runs every criterion with that directory as its working directory. Findings and criteria cite repository-relative paths, so each criterion of a single-file path review that names a file fails before it checks anything.

Measured in the #1015 recall runs (.data/measurements/recall, 2026-10-02):

  • docs/VISION.md (session 20261002-232517): both criteria exited 1 with FileNotFoundError: [Errno 2] No such file or directory: 'docs/VISION.md', and the finding was still VERIFIED at 0.95 on the model's reading alone.
  • k8s/otel/networkpolicy.yaml (session 20261002-234825): grep ... k8s/otel/networkpolicy.yaml exited 2 with No such file or directory, and the verifier INVALIDATED a valid finding citing the failed check.

The sandbox is not the cause. Run with the repository root as cwd, the same two commands pass inside the bubblewrap sandbox (python -c "...Path('docs/VISION.md').exists()" prints True; grep -c 0.0.0.0 k8s/otel/networkpolicy.yaml prints 1). Directory targets and several targets keep the working directory's root, and branch and PR reviews use the repository or head checkout, so they are unaffected.

Acceptance criteria

  • A path review of a single file uses the repository root that contains the file (git rev-parse --show-toplevel from the file's folder, or the existing repository-root helper) as target_dir, and falls back to the file's folder only outside a repository.
  • A test reviews one file in a nested folder of a tmp git repository with a stub model and a criterion that reads the file by its repository-relative path; the criterion runs from the repository root and passes. It fails on the current code.
  • Everything else that reads target_dir for a single-file review (conventions, linked files, the static analyzers' file list, the session's recorded paths) still finds what it found before; a test pins the analyzer file list and the conventions digest for that case.
  • Tests run offline, call no model, and each runs well under 1 s.
  • changelog.d/1038.md records the fix under ### Fixed. CHANGELOG.md is not edited.
  • uv run devops ci passes.

Key questions

  • Should a single file outside any repository still review? (proposed) Yes, from its folder, as today.

Depends on: none.
Order: any time. #847 (criteria environment, in v0.2.25) changes how criteria run but not which directory they get.
Related: #847, #846, #1015 (where it was measured).

Activity

  1. added
    type/bug
    scope/review
    priority/p2-medium
    on Oct 3, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Superseded by #1047, re-scoped on 2026-10-03 as the redesign's "a review scans a worktree of the reviewed commit" (#1137). This item's root-resolution half is now a #1047 criterion: a path review of single files resolves its root with git rev-parse --show-toplevel, not the file's parent (commands/review.py:340). Its criteria-runner half is frozen with the verifier (#1150).

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/p2-mediumscope/reviewtype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions