fix(gateway): enforce chat_id isolation for all DM sessions

This commit is contained in:
heyyyimmax 2026-03-12 16:21:49 +01:00 committed by teknium1
parent 779f8df6a6
commit 34e120bcbb
2 changed files with 21 additions and 14 deletions

View file

@ -338,7 +338,7 @@ class TestSessionStoreRewriteTranscript:
class TestWhatsAppDMSessionKeyConsistency:
"""Regression: all session-key construction must go through build_session_key
so WhatsApp DMs include chat_id while other DMs do not."""
so DMs are isolated by chat_id across platforms."""
@pytest.fixture()
def store(self, tmp_path):
@ -369,15 +369,15 @@ class TestWhatsAppDMSessionKeyConsistency:
)
assert store._generate_session_key(source) == build_session_key(source)
def test_telegram_dm_omits_chat_id(self):
"""Non-WhatsApp DMs should still omit chat_id (single owner DM)."""
def test_telegram_dm_includes_chat_id(self):
"""Non-WhatsApp DMs should also include chat_id to separate users."""
source = SessionSource(
platform=Platform.TELEGRAM,
chat_id="99",
chat_type="dm",
)
key = build_session_key(source)
assert key == "agent:main:telegram:dm"
assert key == "agent:main:telegram:dm:99"
def test_discord_group_includes_chat_id(self):
"""Group/channel keys include chat_type and chat_id."""