Skip to content

test(backend): stub utils.memory.retraction_scope in the conversations isolation fixtures - #11633

Merged
kodjima33 merged 1 commit into
mainfrom
issues-improver/11531-retraction-scope-stubs
Aug 15, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
issues-improver/11531-retraction-scope-stubs

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

What

Five backend unit files have been failing on main since 6316415534 (merged today, 14:44 UTC) with the same error:

ModuleNotFoundError: No module named 'utils.memory.retraction_scope'
  • tests/unit/test_batch_upload_storage.py
  • tests/unit/test_conversation_events_bounds.py
  • tests/unit/test_conversation_search_date_validation.py
  • tests/unit/test_conversations_date_range_validation.py
  • tests/unit/test_merge_validation.py

Red lane on main: run 31890773063.

Why

PR #11627 added a new module, utils/memory/retraction_scope.py, and imported it from both utils/conversations/merge_conversations.py:25 and routers/conversations.py:51.

All five files load their module under test through the stub_modules + load_module_fresh isolation seam, and each stubs utils.memory as 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_scope stub in each fixture, in that file's local idiom, exposing only the symbols its importer binds:

  • the two merge_conversations loaders get canonical_intake_is_fenced, historical_source_conversation_ids, retraction_can_be_skipped
  • the three routers.conversations loaders get retraction_can_be_skipped

Test 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 6316415534 that all nine files it named now pass:

BACKEND_UNIT_TEST_FILE_LIST=<the 9 files> bash test.sh
-> 34 passed in 23.52s

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

# the 5 failing files, before the fix (reproduced locally at 6316415534)
-> ModuleNotFoundError: No module named 'utils.memory.retraction_scope' in all 5

# after
BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-fail5.txt bash test.sh
-> 40 + 9 + 9 + 23 + 27 = 108 passed

# full backend unit suite
bash test.sh
-> the 5 files pass. 14 other files fail; the identical 14 fail on
   unmodified main (stashed, same runner, same machine), so none are
   attributable to this diff. test_sync_v2.py failed only under
   full-suite parallel load and passes standalone (168 passed) both
   before and after.

black --line-length 120 --skip-string-normalization --check
-> 5 files would be left unchanged

scripts/pr-preflight --pr-body-file <this body>
-> PR preflight passed: 24 checks in 117.98s
   (includes backend-module-isolation, backend-import-purity)

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 AutoMockModule submodules instead of failing on an empty __path__. That is a change to the shared testing/import_isolation.py seam 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.

Review in cubic

…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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@kodjima33
kodjima33 merged commit c03d339 into main Aug 15, 2026
43 checks passed
@kodjima33
kodjima33 deleted the issues-improver/11531-retraction-scope-stubs branch August 15, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant