Skip to content

refactor(cli): source modules keep no accommodation for tests - #4053

Merged
dan-petty merged 6 commits into
mainfrom
refactor/1333-source-keeps-no-accommodation-for-tests
Nov 7, 2026
Merged

dan-petty merged 6 commits into
mainfrom
refactor/1333-source-keeps-no-accommodation-for-tests

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Source modules no longer change their behavior for a test. The async process start goes through the active process runner and tells a replaced subprocess.run from the stdlib one no more. The settings cache key holds no config path. Repository state gets public seams: install_own_source_dir, reset_own_source_dir and reset_repo_caches. The floor installs and resets them. Tests use these seams in place of patches of private names.

Two invariant tests keep it so: no read of an attribute of subprocess.run in src/, and a ceiling of 2 on reads of PYTEST_CURRENT_TEST. Both remaining reads are in commands/ci.py and go with the tests of the ci command.

Closes #4021

Change: openspec/changes/archive/2026-11-07-4021-source-keeps-no-accommodation-for-tests/

The async runner goes through the active process runner and no longer
starts the sync path when a test replaces subprocess.run. The child
environment passes no PYTEST_CURRENT_TEST. The settings cache key holds
no config path, so no test rebinds CONFIG_PATH. reset_repo_caches is the
public reset of the origin cache, and install_own_source_dir replaces the
patch of a private name.
reset_repo_caches clears the caches only. reset_own_source_dir removes
the directory that install_own_source_dir named, and the floor calls it.
The async start test no longer patches subprocess.run, and the invariant
also flags a direct attribute read of subprocess.run.
@dan-petty dan-petty added type/refactor Type refactor: a new structure, same behavior scope/cli Core CLI framework, Typer subcommands, options, and tables labels Nov 7, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check results at the push:

  • Focused runs pass: tests/invariants, tests/core, tests/config, tests/git, tests/commands/test_repos.py, tests/review/test_review_untrusted_tree.py and the other touched test files (more than 1,100 tests).
  • mypy strict passes. The pre-push static checks pass.
  • The full local devops ci run is queued behind other agents on the CI gate. Its earlier run timed out in the test row at 1,800 s on this loaded host, over the 5-minute budget. I will add its result to this thread.

Independent review: all six findings were minor. Fixed: the async runner test no longer patches subprocess.run; reset_repo_caches keeps the installed source directory and reset_own_source_dir removes it (the floor calls it); the invariant also flags a direct attribute read of subprocess.run.

Left for follow-up items (not in this PR):

  1. Tests still assign the GitHub token privates: tests/conftest.py (_github_token), tests/support/github_identity.py (_github_token, _lookup_github_token), tests/github/test_github_session.py and tests/github/test_github_rate_limiter.py. The floor should answer gh auth token through the process fake.
  2. The two reads of PYTEST_CURRENT_TEST in src/devops_cli/commands/ci.py. They need the ci command tests of test(cli): command tests patch no devops_cli names #3769. Then the ceiling in tests/invariants/test_source_tree.py goes to 0.

@dan-petty
dan-petty marked this pull request as ready for review November 7, 2026 19:35
@dan-petty

Copy link
Copy Markdown
Owner Author

Result of the full local devops ci run on the final code (commit 945d7a0):

  • All static rows pass: lint, format, mypy strict, security, docs, openspec, test tree, startup imports, swallowed failures, and the rest.
  • Tests: 20,837 passed, 1 failed, 2 skipped. The test row took 14m 31s, over the 5-minute budget on this loaded host. The slowest tests are in tests/roadmap/stage/test_roadmap_stage_eval_*.
  • The one failure is tests/roadmap/test_roadmap_alternatives.py::test_the_decisions_are_cut_by_whole_entries_the_oldest_go_first_and_a_warning_says_so. It reads all warning records, and eight records of an OpenTelemetry processor that an earlier test shut down in the same worker came with it. My change does not touch telemetry state or this test. The file passes alone (166 passed), and the four GitHub test shards pass. Filed as fix(roadmap): alternatives ADR cap test reads logs of other loggers #4062.
  • Coverage was 94.84% (above the 85% floor).

@dan-petty
dan-petty merged commit 33b57a9 into main Nov 7, 2026
25 checks passed
@dan-petty
dan-petty deleted the refactor/1333-source-keeps-no-accommodation-for-tests branch November 7, 2026 20:18
dan-petty pushed a commit that referenced this pull request Nov 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.84.0](v0.83.2...v0.84.0)
(2026-11-07)


### Features

* **k8s:** alert when Crawl4AI fetches fail
([#4037](#4037))
([49f0f14](49f0f14))
* **k8s:** run SearXNG in the devops namespace
([#4033](#4033))
([9d223f4](9d223f4)),
closes [#3924](#3924)
* **research:** add GitHub advisories and KEV to research advisories
([#4032](#4032))
([61e6936](61e6936)),
closes [#3987](#3987)
* **research:** add research sweep that files intake candidates
([#4055](#4055))
([11ddee9](11ddee9))
* **roadmap:** add a test-first manifest kind to the stage plan
([#3981](#3981))
([8476163](8476163))
* **roadmap:** check a plan number against its constant
([#4073](#4073))
([324a3a5](324a3a5))
* **roadmap:** name every caller of a changed function
([#4047](#4047))
([24e9138](24e9138))
* **roadmap:** the stage probe routes prompt changes to prompt rule
tests ([#3989](#3989))
([4aebde2](4aebde2))


### Code Refactoring

* **cli:** source modules keep no accommodation for tests
([#4053](#4053))
([33b57a9](33b57a9))
* **roadmap:** remove the dead plan and review step classes
([#4074](#4074))
([526834f](526834f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/cli Core CLI framework, Typer subcommands, options, and tables type/refactor Type refactor: a new structure, same behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(cli): source modules keep no accommodation for tests

1 participant