Repository navigation
test(backend): stub utils.memory.retraction_scope in the conversations isolation fixtures - #11633
Merged
Merged
Conversation
…s isolation fixtures Five unit files have failed on main since 6316415 with ModuleNotFoundError: No module named 'utils.memory.retraction_scope'. PR #11627 added utils/memory/retraction_scope.py and imported it from utils/conversations/merge_conversations.py and routers/conversations.py. All five files load their module under test through the stub_modules + load_module_fresh seam and stub utils.memory as a package with an empty __path__ plus a hand-listed set of submodules, so a submodule that is not on that list cannot resolve at all and the import fails at fixture setup. Register the missing stub in each fixture, in that file's local idiom, exposing only the symbols its importer binds. None of these files exercise retraction; no assertion changed. Verification: BACKEND_UNIT_TEST_FILE_LIST=<the 5 files> bash test.sh -> 108 passed full backend unit suite -> the 5 pass; the 14 other failures are byte-identical on unmodified main (test_sync_v2 was a full-suite flake and passes standalone) black --line-length 120 --skip-string-normalization --check -> unchanged fixes #11531
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.
What
Five backend unit files have been failing on
mainsince6316415534(merged today, 14:44 UTC) with the same error:tests/unit/test_batch_upload_storage.pytests/unit/test_conversation_events_bounds.pytests/unit/test_conversation_search_date_validation.pytests/unit/test_conversations_date_range_validation.pytests/unit/test_merge_validation.pyRed lane on
main: run 31890773063.Why
PR #11627 added a new module,
utils/memory/retraction_scope.py, and imported it from bothutils/conversations/merge_conversations.py:25androuters/conversations.py:51.All five files load their module under test through the
stub_modules+load_module_freshisolation seam, and each stubsutils.memoryas a package with an empty__path__plus a hand-listed set of submodules (memory_service,memory_system,canonical_activation). An empty__path__means any submodule that is not on that list cannot resolve at all — so the new import fails at fixture setup rather than falling through to the real module.Nothing in these five files exercises retraction; they cover audio-copy helpers, merge validation, event index bounds, and search/date validation. The stubs simply had not caught up with a new import in the graph they load.
Fix
Register a
utils.memory.retraction_scopestub in each fixture, in that file's local idiom, exposing only the symbols its importer binds:merge_conversationsloaders getcanonical_intake_is_fenced,historical_source_conversation_ids,retraction_can_be_skippedrouters.conversationsloaders getretraction_can_be_skippedTest files only — no production code changes, and no assertion in any of the five was touched.
On #11531
The issue's original cause (the customer-Firestore split, #11522) was fixed by #11535 and the issue was left open. Verified at
6316415534that all nine files it named now pass:The lane was red again for the unrelated cause above. With this change the lane is green, so the issue's condition is resolved.
Tested
Local runner is Python 3.12 / pytest 9.1.1 against CI's 3.11 / 8.4.1, which accounts for some of the 14 pre-existing local failures.
Follow-up (not in this PR)
This is the second time in two weeks that a new import into the conversations/memory graph broke hand-listed stub sets (#11531 was the same shape). The durable fix is to derive the stub set rather than hand-list it — e.g. letting a stubbed package auto-provide
AutoMockModulesubmodules instead of failing on an empty__path__. That is a change to the sharedtesting/import_isolation.pyseam with a much wider blast radius than a red-lane repair, so it is deliberately left out here.Auto-generated from issue feedback by the mini issues-improver — tested and merged.