Repository navigation
fix(tests): eliminate order-dependent sys.modules pollution (unblocks v0.8.0 release) - #1530
Merged
Merged
Conversation
vybe
enabled auto-merge (squash)
July 8, 2026 20:15
…unit files
The base/head regression matrix (which only runs on PRs, not dev pushes) surfaced
16 order-dependent failures in test_fork_to_own / test_73_stats_cache /
test_186_enumeration_uniformity — all new-on-dev files that pass in isolation but
fail under full-suite ordering. Three distinct sys.modules-pollution vectors, all
test-harness bugs (product code is intact); each fix only restores real modules:
1. test_voice_auth.py stubbed services.{docker_service,template_service,
platform_audit_service} at module level and never restored them. The stubs are
incomplete (no is_trinity_compatible / execute_command_in_container), so later
files importing those symbols hit "ImportError: ... (unknown location)". Now
snapshots + restores them after voice.py imports (mirrors test_voice_tools.py).
2. test_fork_to_own.py's crud_env teardown ran a manual
"del sys.modules['services.agent_service.*']" AFTER patch.dict.stop() — which
had already restored the pre-test snapshot. The delete left
services.agent_service.stats absent, so test_73's module-level "stats_mod"
reference went stale and its monkeypatch missed. Removed the redundant/harmful
delete; patch.dict owns restore.
3. test_self_hosted_git_url.py's _reload_github_service() deletes+reimports
services.github_service without restoring, leaking a fresh OwnerType enum;
test_fork_to_own's owner-guard then compares OwnerType by identity across the two
modules and silently skips ("DID NOT RAISE HTTPException"). Added an autouse
fixture that snapshots/restores services.github_service* per test.
Verified: full unit suite green under all three CI seeds (12345/67890/99999),
3646 passed / 15 skipped each (locally on py3.14; CI runs py3.11).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
vybe
force-pushed
the
fix/sys-modules-pollution-order-dependent-tests
branch
from
July 8, 2026 20:25
73a84e1 to
9cf6ec6
Compare
5 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.
Why
Cutting v0.8.0, the
dev → mainrelease PR (#1529) is the first time the backend-unit base/head regression matrix ran over the full payload (it only fires on PRs, not dev pushes). It surfaced 16 order-dependent failures in three new-on-dev unit files:test_fork_to_own.py(9 —ImportError: … (unknown location))test_73_stats_cache.py(6 — monkeypatch missed → assertion)test_186_enumeration_uniformity::test_tier4_config_gets_are_access_gated(1)All three pass in isolation but fail under full-suite ordering — classic
sys.modulespollution. These are test-harness bugs, not product bugs: the product code (is_trinity_compatible, the fork-to-own owner guard, the #73 stats-cache invalidation) is intact.The three vectors (each fix only restores real modules)
test_voice_auth.pystubbedservices.{docker_service,template_service,platform_audit_service}at module level and never restored them. The stubs are incomplete (nois_trinity_compatible/execute_command_in_container), so later files importing those symbols hitImportError … (unknown location). → snapshot + restore aftervoice.pyimports (mirrors the existing pattern intest_voice_tools.py).test_fork_to_own.py'scrud_envteardown ran a manualdel sys.modules['services.agent_service.*']afterpatch.dict.stop()— which had already restored the pre-test snapshot. The delete leftservices.agent_service.statsabsent, sotest_73's module-levelstats_modwent stale and its monkeypatch silently missed. → removed the redundant/harmful delete;patch.dictowns restoration.test_self_hosted_git_url.py's_reload_github_service()deletes+reimportsservices.github_servicewithout restoring, leaking a freshOwnerTypeenum;test_fork_to_own's owner guard then comparesOwnerTypeby identity across the two module copies and skips (DID NOT RAISE HTTPException). → autouse fixture snapshots/restoresservices.github_service*per test.Verification
Full unit suite green under all three CI seeds (12345 / 67890 / 99999): 3646 passed, 15 skipped each (locally on Python 3.14; CI runs 3.11 — the release PR re-run is the authoritative check).
Test-only changes (+60/-3). Merges into
dev; unblocks the v0.8.0 release PR #1529.