Skip to content

test(review): use PATH stand-ins for scanner tests #2116

Closed

Description

@dan-petty

Friction

tests/test_scanner_tool_executor.py has an autouse fixture of its own, scanners_installed, that patches shutil.which so that the review scanners look installed. docs/TESTING.md says that tests double only process edges, through the shared fakes. Since #1982, scanner_fake puts an executable stand-in for each recorded scanner first on PATH and patches no shutil or subprocess name.

What should happen

tests/test_scanner_tool_executor.py makes the scanners findable with stand-ins on PATH, as scanner_fake does, or with scanner_fake itself, and patches no shutil name.

Evidence

Order

After #1982.

Source: #1982

Proposed design

Problem statement

The test file tests/test_scanner_tool_executor.py makes review scanners appear installed by patching shutil.which. Since #1982, the shared scanner_fake fixture makes scanners findable by putting executable stand-ins on PATH and patches no shutil or subprocess name. The test file violates the convention in docs/TESTING.md that a test doubles only process edges through shared fakes. The fixture must be replaced with stand-ins on PATH so that no shutil name is patched.

Acceptance criteria

  • Criterion 1: The autouse fixture scanners_installed no longer patches shutil.which.
    Verification: Run grep -n 'shutil.which' tests/test_scanner_tool_executor.py and confirm no match. Run uv run pytest tests/test_scanner_tool_executor.py -x and confirm all tests pass.
  • Criterion 2: The scanners are made findable by placing executable stand-in files on PATH, as scanner_fake does.
    Verification: Run uv run pytest tests/test_scanner_tool_executor.py -x -v and confirm all tests pass. Inspect the fixture and confirm it creates files in a temp directory and prepends that directory to PATH, with no monkeypatch.setattr on shutil.
  • Criterion 3: No test in the file patches a shutil or subprocess name.
    Verification: Run grep -n 'monkeypatch.setattr.*shutil|monkeypatch.setattr.*subprocess' tests/test_scanner_tool_executor.py and confirm no match.

Key questions

  • What does scanner_fake do to make scanners findable on PATH?: It puts an executable stand-in for each recorded scanner first on PATH. It patches no shutil or subprocess name. [sources: docs/TESTING.md:179, openspec/changes/archive/2026-10-24-1982-scanner-fake-through-tool-executor/design.md]
  • Should the test use scanner_fake directly or create its own stand-ins on PATH?: The test uses tool_executor_fake (a plain ToolExecutorFake) in most cases, not scanner_fake (which carries recorded answers). The test needs only the PATH stand-ins so that shutil.which finds the tool. It should create its own stand-ins on PATH, the same mechanism scanner_fake uses internally, without requiring the recorded answers of scanner_fake. (proposed) [sources: tests/test_scanner_tool_executor.py:55, docs/TESTING.md:179]
  • Is there a dependency on another issue?: Yes. The issue states it must come after test(review): scanner_fake answers the review scanners through the ToolExecutor fake, not through patched subprocess calls #1982, which rebuilt scanner_fake over ToolExecutorFake and established the stand-in-on-PATH pattern. [sources: openspec/changes/archive/2026-10-24-1982-scanner-fake-through-tool-executor/tasks.md:23]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/test
    source/agent
    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/test. The candidate changes how tests are written, focusing on testing patterns.
    • Priority: P2-Medium. This improves test consistency and maintainability but does not block other work or introduce new features. The failed run 1982 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 on the board.
    • Value: Medium. Improves test reliability by aligning with established patterns used in other tests.
    • Effort: Low. Requires minimal changes to replace one patch with another approach using PATH stand-ins.
  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/low
    scope/review
    on Oct 28, 2026
  5. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Staged: branch test/2116-the-scanner-executor-tests-find-the, draft pull request #2977. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Replace shutil.which patch with PATH stand-ins: 2346 tokens

    These paths of the plan are no file on the default branch, and no group creates them: tests/test_scanner_tool_executor.py. A person checks that the plan names them right.

  6. 401 remaining items

  7. added
    status/in-progress
    and removed
    status/planned
    on Nov 4, 2026
  8. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Stopped at push.

    Failure class: ci_infra.
    Action taken: none.
    Action left: retry: run the item again.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 2 1798523/8305 -
    push stopped 1 0/0 -

    Reason:

    The title of the pull request does not pass the check `Semantic PR title`: The summary has 98 characters (an emoji counts as two). The limit is 60. Write a shorter summary. The title is `test(review): the scanner executor tests find the scanners through stand-ins on PATH, not a patched shutil.which`.
    

    Last message of the agent (a claim that no check verified): none.

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service also clears the stop one time when a new runner image rolls out.

  9. added
    status/blocked
    and removed
    status/in-progress
    on Nov 4, 2026
  10. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261104-213648-3fbc ended: succeeded.
    Image digest: sha256:ff7f81f8f5902c5ae4e48ed334bc83f842b51afb639ab71be65cb4240daadf01

    The last lines of its log:

    Tool call: shell, started: uv run devops ci lint --check
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci format --check
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -x
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci lint --check ...
    Tool call: shell, program uv, refused.
    Tool call: shell, started: uv run devops ci lint --check
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci format --check
    Tool call: shell, program uv, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: grep -n shutil.which tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: grep -n monkeypatch.setattr tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: write_file, retry (Parent directory '.data/agent/scratch' does not exist. Create the parent directory first.).
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -x --tb=<masked>
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n shutil tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n monkeypatch.setattr tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: edit_file, ok.
    Failure class ci_infra. Action left: retry.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 8m 59s
    
  11. removed
    owner/service
    on Nov 4, 2026
  12. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at push by the rule digest: the runner image changed since the stop, from sha256:ff7f81f8f5902c5ae4e48ed334bc83f842b51afb639ab71be65cb4240daadf01 to sha256:e7f20c7f4265aecf32baeb064817eca07bffedc9fd3f31cdfd450a2d20e9abba. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a comment implement: retry.

  13. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Stopped at push.

    Failure class: ci_infra.
    Action taken: none.
    Action left: retry: run the item again.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 2 1584867/5803 -
    push stopped 1 0/0 -

    Reason:

    The title of the pull request does not pass the check `Semantic PR title`: The summary has 98 characters (an emoji counts as two). The limit is 60. Write a shorter summary. The title is `test(review): the scanner executor tests find the scanners through stand-ins on PATH, not a patched shutil.which`.
    

    Last message of the agent (a claim that no check verified): none.

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service also clears the stop one time when a new runner image rolls out.

  14. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261104-220133-8bd9 ended: succeeded.
    Image digest: sha256:e7f20c7f4265aecf32baeb064817eca07bffedc9fd3f31cdfd450a2d20e9abba

    The last lines of its log:

    Tool call: shell, started: uv run devops ci lint --check
    Tool call: shell, program uv, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -x
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n shutil tests/security/test_scanner_tool_executor.py || echo ...
    Tool call: shell, program grep, refused.
    Tool call: shell, started: grep -n shutil tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run devops ci format --check
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -x
    Tool call: shell, program uv, ok.
    Tool call: write_file, retry (Parent directory '.data/agent/scratch' does not exist. Create the parent directory first.).
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: uv run python -c __import__('pathlib').Path('.data/agent/scratch').mkdir(parents=<masked>
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: grep -c shutil\\|subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, refused.
    Tool call: shell, started: grep -c shutil tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -c subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Failure class ci_infra. Action left: retry.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 11m 47s
    
  15. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at push by the rule digest: the runner image changed since the stop, from sha256:e7f20c7f4265aecf32baeb064817eca07bffedc9fd3f31cdfd450a2d20e9abba to sha256:d36abcebefae7c845fd29aca7f7b5257ae4b219b58b3ff74d43ec1b0726dc508. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a comment implement: retry.

  16. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Stopped at push.

    Failure class: ci_infra.
    Action taken: none.
    Action left: retry: run the item again.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 1 1391011/6565 -
    push stopped 1 0/0 -

    Reason:

    The title of the pull request does not pass the check `Semantic PR title`: The summary has 98 characters (an emoji counts as two). The limit is 60. Write a shorter summary. The title is `test(review): the scanner executor tests find the scanners through stand-ins on PATH, not a patched shutil.which`.
    

    Last message of the agent (a claim that no check verified): none.

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service also clears the stop one time when a new runner image rolls out.

  17. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261104-221949-b8f2 ended: succeeded.
    Image digest: sha256:d36abcebefae7c845fd29aca7f7b5257ae4b219b58b3ff74d43ec1b0726dc508

    The last lines of its log:

    Tool call: shell, started: grep -n shutil\\|subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, refused.
    Tool call: shell, started: grep -n shutil tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n <masked> tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -A 15 <masked> tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run devops ci lint --check
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci format --check
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -x
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci format --check
    Tool call: shell, program uv, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: git grep -n shutil tests/security/test_scanner_tool_executor.py
    Tool call: shell, program git, ok.
    Tool call: shell, started: git grep -n subprocess tests/security/test_scanner_tool_executor.py
    Tool call: shell, program git, ok.
    Tool call: shell, started: grep -n <masked> tests/security/test_scanner_tool_executor.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run pytest tests/security/test_scanner_tool_executor.py -v
    Tool call: shell, program uv, ok.
    Tool call: write_file, retry (Parent directory '.data/agent/scratch' does not exist. Create the parent directory first.).
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: uv run python -c __import__(\\"pathlib\\").Path(\\".data/agent/scratch\\").mkdir(parents=<masked>
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Failure class ci_infra. Action left: retry.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 8m 14s
    
  18. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at push by the rule digest: the runner image changed since the stop, from sha256:d36abcebefae7c845fd29aca7f7b5257ae4b219b58b3ff74d43ec1b0726dc508 to sha256:bf609edd0c01ca1c27bdc7e5d0f9e7385ff29934887b4e531bc648ef36301351, and the class ci_infra of the stop is one that a new attempt can fix. The item is Planned again, and the Service takes it in the next round. The Service clears at most 1 for each class and 3 for each item by digest. A stop of another class, a new stop on this image, and a stop over a limit wait for a comment implement: retry.

  19. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 98 characters, and the limit is 60. The type and the scope stay.

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/lowpriority/p2-mediumscope/reviewsource/agenttype/testvalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions