Skip to content

refactor(review): the pr review and the scanner entry points take their directory from the caller, not from a default that reads the working directory #2127

Closed

Description

@dan-petty

What happened

#2098 removed every direct Path.cwd() and os.getcwd() read from ai/review/, review/ and security/, and the ast-grep rule review-cwd-read keeps them out. Some reads of the working directory still happen through a default, outside what that rule sees:

  • core.repo.get_repo_origin_name() with no path names the repository of the process's working directory. The PR review calls it to name the reviewed repository.
  • run_trivy_scan, run_kubelinter_scan, run_pluto_scan, run_bandit_scan and run_dive_scan take the relative path . as their default target, so a call with no target scans the process's working directory.

A caller that runs in another directory (a test, the MCP server, a worktree) thus reviews or scans the wrong tree when it gives no path.

What should happen

The command layer reads the working directory one time and gives it down, as #2098 does for the orchestrator and the other scanners. get_repo_origin_name and each scanner entry point require their directory, and a rule or a test fails when one of them takes a relative default again.

Evidence

Acceptance criteria

  • get_repo_origin_name and the five scanner entry points take no relative default for their directory, and every caller gives one.
  • A rule or a test fails when one of them gets a default that reads the working directory again.

Source: #2098

Proposed design

Problem statement

The PR review and five scanner entry points read the working directory through a default parameter. A caller that runs in another directory reviews or scans the wrong tree. The command layer must read the working directory once and pass it down. A guard must fail when a relative default returns.

Acceptance criteria

  • Criterion 1: get_repo_origin_name and the five scanner entry points take no relative default for their directory, and every caller gives one.
    Verification: Inspect the signatures in src/devops_cli/core/repo.py and src/devops_cli/security/*.py. Confirm no parameter defaults to '.' or to a value that resolves to the working directory. Run the full test suite and confirm all callers pass an explicit path.
  • Criterion 2: A rule or a test fails when one of these functions gets a default that reads the working directory again.
    Verification: Add a default of '.' to one scanner function. Run the guard rule or test. Confirm it fails. Remove the default. Confirm it passes.

Key questions

  • Where is get_repo_origin_name defined and what is its current signature?: It is in src/devops_cli/core/repo.py. It takes no path argument and reads the working directory via git remote get-url origin. [sources: src/devops_cli/core/repo.py]
  • What are the current default targets of the five scanner entry points?: run_trivy_scan, run_kubelinter_scan, run_pluto_scan, run_bandit_scan and run_dive_scan all default their target to the relative path '.'. [sources: src/devops_cli/security/dive.py:240]
  • Which callers invoke these functions without giving a path?: The command layer, the PR review pipeline, and tests. The pipeline at src/devops_cli/ai/review/pipeline.py:1981 calls run_bandit_scan. The agent scan adapters also call the run_*_scan functions over a workspace path. [sources: src/devops_cli/ai/review/pipeline.py:1981, openspec/changes/archive/2026-10-24-1435-agent-scan-tools-run-the-adapters/proposal.md]
  • Should the guard be an extension of the existing review-cwd-read ast-grep rule or a new unit test?: The existing review-cwd-read rule covers ai/review/, review/ and security/ but not core/repo/. The issue states 'a rule or a test' without specifying which. The implementer chooses the mechanism. A test that asserts no default of '.' in the six signatures is the simplest option and covers all locations. (proposed)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/refactor
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/refactor. The candidate proposes a refactor to improve how directory paths are handled in review and scanner entry points.
    • Priority: P2-Medium. The change improves correctness of directory handling but does not fix a bug or add new functionality.
    • Value: Medium. The change prevents incorrect behavior when running reviews or scans from different directories, which affects test reliability and user experience.
    • Effort: Medium. The change requires modifying multiple entry points and updating callers to pass directory paths explicitly, but does not introduce new logic.
    • Related: fix(review): a path review of single files runs its criteria from the repository root, not from the file's folder #1038, which asks for a different change. Both items deal with directory handling in reviews, but the candidate focuses on removing default working directory reads while item #1038 addresses path review directory resolution.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at bb46660 (see proposed design in issue body).

  4. added
    priority/p2-medium
    status/ready
    value/medium
    effort/medium
    on Oct 28, 2026
  5. removed
    status/ready
    on Oct 30, 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

    effort/mediumpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions