Repository navigation
test: stop the agentrc probe from poisoning the git executable cache - #4123
Merged
Daniel Meppiel (danielmeppiel) merged 9 commits intoNov 20, 2026
Merged
Conversation
… inventory skips root apm_modules TestInitAgentrcSuggestion patched the global shutil.which, so apm init's git resolution cached /usr/bin/agentrc process-wide and broke every later test on the xdist worker (84 macOS-arm64 release-validation failures). The patch now answers only for agentrc. An autouse fixture resets the git/gh executable caches after each test, and a regression test pins the leak (it fails with the old blanket patch). The architecture inventory excludes the gitignored root apm_modules and skips a directory that vanishes mid-walk (FileNotFoundError only), so a concurrent test's scratch output cannot crash the real-tree guard. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 07:58
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The inventory traversal silently omits disappearing source subtrees, allowing architecture checks on incomplete data, while the cache-pollution regression can miss the bug on Windows.
2 open issues
What changed in this PR
This PR addresses release-validation test pollution by isolating executable lookup mocks and clearing cached paths between tests. It also adjusts the architecture linter’s handling of generated output and disappearing directories.
Changes:
- Limit agentrc mocks to agentrc lookups and add a cache-pollution regression test.
- Reset git and gh executable caches after each test.
- Exclude root
apm_modulesfrom architecture scans and add coverage for traversal-error handling.
| File | Description |
|---|---|
tests/unit/test_init_command.py |
Narrows agentrc mocks and adds a cache-pollution regression. |
tests/unit/scripts/test_architecture_inventory.py |
Tests generated-root exclusion and traversal-error handling. |
tests/conftest.py |
Clears executable caches after each test. |
scripts/architecture_linter/inventory.py |
Excludes root install output and skips missing-directory errors. |
Review effort: Balanced
… clearing them Clearing left a cold cache that tests relying on a warm, already-resolved git path observe differently on Windows (test_auth_scoping). Restoring the pre-test value still undoes any leak a test causes. Co-authored-by: Copilot App <[email protected]>
Tests that clear PATH (test_auth_scoping on Windows) relied on an earlier test having warmed the git cache. The fixture now resolves the real git before each test when the cache is cold, so every test sees the same warm cache, and still restores it afterwards so no test leaks a value. Co-authored-by: Copilot App <[email protected]>
…olved path Fold Copilot review: a vanished source subtree must fail the inventory (root apm_modules exclusion already covers the install-output race), and the agentrc regression now requires a populated git cache and compares resolved paths so it detects pollution on Windows too. Co-authored-by: Copilot App <[email protected]>
tests/unit/core/test_output_mode.py invokes `cli ... --format=json`, which calls set_console_stderr(True). That routing is process-global, and only tests/integration/conftest.py reset it, so a later unit test on the same xdist worker read empty stdout through capsys. Example: test_targets_phase.py::test_config_default_target_provenance_names_config_source on Windows units (1/3), run 44705583099. Promote _reset_console_state to the root tests/conftest.py so every suite starts and ends each test with default console routing. The integration cwd repair keeps running after each test, now in _integration_process_cwd_guard. Co-authored-by: Copilot App <[email protected]>
…tion" This reverts commit 9bfdc2d. It duplicated other work: the console-routing pollution is owned by a separate PR (Part of #4115). #4123 stays scoped to the git executable cache. Co-authored-by: Copilot App <[email protected]>
5 of 10 tasks
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-test-pollution-git-cache
branch
November 20, 2026 09:58
7 of 14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Release validation of main (run 44695495012) failed 84 macOS-arm64 unit tests. The cause is test pollution; there is no product impact. This PR fixes it in tests only, plus a hardening of the architecture linter's inventory walk.
TestInitAgentrcSuggestionpatchedapm_cli.commands.init.shutil.which, which is the globalshutil.which.apm initresolves git during the run, sogit_env._git_executablecached/usr/bin/agentrcfor the whole process.GitUrlRewriteProbeError,FileNotFoundError '/usr/bin/agentrc', and'agentrc' == 'git'.agentrcand delegates everything else (_agentrc_on_path).tests/conftest.pyresets the git/gh executable caches (reset_git_cache) after each test.test_agentrc_probe_never_poisons_the_git_executable_cachefails with the old blanket patch and passes now.test_real_tree_is_cleancrashed on a vanishedapm_modules.apm_modules.FileNotFoundErroronly). Every other walk error still fails closed, and tracked source is still walked.I did not pinpoint which test creates and removes
apm_modulesat the repo root. A local run leaves none behind, and the inventory change removes the failure mode either way.Issue and approved scope
Issue: Refs #3983. This is a release-validation repair requested by the 0.37 delivery manager and coordinator.
Human scope-approval comment: coordinator-directed release mechanics (test-only).
Does this PR complete the issue, or what remains? It restores release validation. #3983 remains the umbrella issue.
Type of change
Testing
Tested locally
All existing tests pass (CI)
Added tests for new functionality (if applicable)
pytest -n 0 -p no:randomly tests/unit/test_init_command.py tests/unit/test_version.py tests/unit/test_list_remote_refs.py(polluting order): 163 passed.pytest -n 2over those files plustests/unit/scripts/test_architecture_inventory.pyandtests/unit/scripts/test_architecture_skill_layout_guard.py: 191 passed.Leak probe: with the old patch, the git cache ends up as
/usr/bin/agentrc; with the new patch it does not.uvx [email protected] checkandformat --checkare clean, andscripts/lint-architecture-boundaries.shexits 0.Changelog
## [Unreleased]Spec conformance (OpenAPM v0.1)
No behaviour change.