From 2a2ae3bca1473e90b35d5ca404fb2245d6ab6df6 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sun, 26 Jul 2026 13:13:47 -0700 Subject: [PATCH] test(kanban): assert DM wake resumes the creator's real DM session key Strengthen the salvaged regression test to prove the end-to-end claim in #56580/#68874: a DM-created task's terminal wake must build the creator's ':dm:' session key via build_session_key(), not a group-scoped key that forks a fresh session. Sabotage-verified: reverting the watcher to the hardcoded chat_type='group' fails this test. --- tests/gateway/test_kanban_notifier.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/gateway/test_kanban_notifier.py b/tests/gateway/test_kanban_notifier.py index b0764e24a9c9..4f3d771722d8 100644 --- a/tests/gateway/test_kanban_notifier.py +++ b/tests/gateway/test_kanban_notifier.py @@ -330,6 +330,16 @@ def test_notifier_wakeup_uses_subscription_chat_type(tmp_path, monkeypatch): assert len(adapter.handled) == 1 assert adapter.handled[0].source.chat_type == "dm" + # The wake must resume the creator's real DM session key — the whole bug + # was that a hardcoded chat_type="group" made build_session_key() produce + # a group-scoped key (a NEW session) instead of the ":dm:" shape + # the original conversation runs under (#56580 / #68874). + from gateway.session import build_session_key + + wake_key = build_session_key(adapter.handled[0].source) + assert wake_key == "agent:main:telegram:dm:chat-dm" + assert ":group:" not in wake_key + def test_auto_subscribe_persists_session_chat_type(tmp_path, monkeypatch): db_path = tmp_path / "auto-sub-chat-type.db"