Skip to content

refactor(review): scanners and the origin lookup take the caller's directory - #2619

Merged
dan-petty merged 2 commits into
mainfrom
refactor/2127-scan-dirs-from-caller
Oct 29, 2026
Merged

dan-petty merged 2 commits into
mainfrom
refactor/2127-scan-dirs-from-caller

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The scanner entry points and get_repo_origin_name no longer read the working directory through a default. The command layer reads it one time and gives it down, as #2098 does for the review.

  • Eleven entry points in security/ take their target with no . default: the five that the issue names, and six more that had the same default.
  • get_repo_origin_name requires the root of its repository and reads only its origin remote. The GITHUB_REPOSITORY fallback is gone: each workflow checks out the repository, so none reaches it.
  • devops pr, gh, roadmap and review pr give find_repo_root(Path.cwd()) when they get no --repo. The check fallback and the PR review helper take that checkout. resolve_branch_pr_number requires the owner and the repository.
  • The ast-grep rule review-cwd-read fails DEFAULT_CURRENT_PATH and a Path(".") parameter default in the review and scanner modules. An invariant test holds the root of the origin lookup to no default.

Closes #2127

Change: openspec/changes/archive/2026-10-29-2127-scan-dirs-from-caller/

…rectory

The scanner entry points take their target with no '.' default, and get_repo_origin_name requires the root of its repository. The commands give find_repo_root(Path.cwd()) when they get no --repo. The rule review-cwd-read and an invariant test hold both (#2127).
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results

Fail first, on a0165a1:

  • tests/invariants/test_source_tree.py::test_the_origin_lookup_takes_its_repository_root_from_the_caller reported the default None of get_repo_origin_name. The first form of the test also reported the DEFAULT_CURRENT_PATH default of the five scanners that the issue names.
  • tests/test_review_runner.py::test_a_pr_review_with_no_repo_names_the_origin_of_the_checkout_it_gets read the origin in the worktree that the process ran in, not in the checkout that it gave.
  • tests/test_pr_check_verdict.py::test_with_no_repo_the_fallback_reads_the_origin_of_the_checkout_it_gets failed with TypeError: fetch_pr_check_verdicts took no checkout.
  • tests/test_repos.py::test_a_directory_with_no_repository_has_no_origin_whatever_the_environment passes before and after. It holds the decision on GITHUB_REPOSITORY.

Guard: ast-grep test --skip-snapshot-tests passes, with 4 new invalid and 2 new valid cases. With target: Path = Path(".") put back in security/trivy.py, ast-grep scan --filter review-cwd-read names it at trivy.py:215. Without it, the scan reports nothing.

After the change:

  • The full suite passed: 12,643 tests in 5 m 29 s, before the rebase onto 38a0a44.
  • ruff, mypy (45 source files), devops docs check and devops openspec check pass.
  • After the rebase, an AST walk of src/ and tests/ found no call of a changed function that gives no directory.

Fail-to-pass skips a refactor pull request.

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 04:03
@dan-petty
dan-petty merged commit 9da12df into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the refactor/2127-scan-dirs-from-caller branch October 29, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant