From f761fb9d6a00347b86ac21acdbc38f6044333392 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sun, 5 Jul 2026 20:27:09 -0700 Subject: [PATCH] test(gateway): pin source.profile=None on MagicMock fixtures hitting _adapter_for_source The routing sweep sends these paths through _adapter_for_source, which reads source.profile. A bare MagicMock auto-attribute is truthy, so the fixtures looked like stamped secondary profiles and hit the new fail-closed branch. Real SessionSource.profile is None or str (AGENTS.md pitfall #17). --- tests/gateway/test_notice_rendering.py | 4 ++++ tests/gateway/test_queue_consumption.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/gateway/test_notice_rendering.py b/tests/gateway/test_notice_rendering.py index 89a5435a507..3ba731f32e4 100644 --- a/tests/gateway/test_notice_rendering.py +++ b/tests/gateway/test_notice_rendering.py @@ -107,6 +107,10 @@ def _make_source(platform_value="telegram", chat_id="555", user_id="u1"): src.platform = plat src.chat_id = chat_id src.user_id = user_id + # Real SessionSource.profile is None (single-profile) or a str; a MagicMock + # auto-attribute would read as a truthy "stamped profile" and trip the + # fail-closed path in _adapter_for_source (see AGENTS.md pitfall #17). + src.profile = None return src diff --git a/tests/gateway/test_queue_consumption.py b/tests/gateway/test_queue_consumption.py index ec1b0dedc83..857da98da71 100644 --- a/tests/gateway/test_queue_consumption.py +++ b/tests/gateway/test_queue_consumption.py @@ -382,7 +382,9 @@ class TestBusyInputModeQueueFifo: return runner, adapter def _text_event(self, text: str) -> MessageEvent: - source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM) + # profile=None: a MagicMock auto-attribute reads as a truthy stamped + # profile and trips fail-closed adapter resolution (AGENTS.md #17). + source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM, profile=None) return MessageEvent( text=text, message_type=MessageType.TEXT, @@ -433,7 +435,7 @@ class TestBusyInputModeQueueFifo: runner, adapter = self._make_runner_and_adapter() session_key = "telegram:user:burst" - source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM) + source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM, profile=None) for i in range(3): runner._queue_or_replace_pending_event( session_key,