The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pairing): purge revoked users from live allowlist sets in place
kshitijk4pooreafbe60bf958
diff --git a/gateway/pairing.py b/gateway/pairing.pyindex 95d357e7438..cd01cd35179 100644--- a/gateway/pairing.py+++ b/gateway/pairing.py@@ -216,11 +216,13 @@ def _sync_live_adapter_allowlist_remove(platform: str, user_id: str) -> None:for attr in ("_allow_from", "_allowed_user_ids"):if hasattr(adapter, attr):with contextlib.suppress(Exception):- setattr(- adapter,- attr,- _purge_allowlist_entries(getattr(adapter, attr), platform_name, user_id),- )+ current = getattr(adapter, attr)+ purged = _purge_allowlist_entries(current, platform_name, user_id)+ if isinstance(current, set):+ # In place: Discord approval views / VoiceReceiver hold this same set.+ current.intersection_update(purged)+ else:+ setattr(adapter, attr, purged)extra = getattr(getattr(adapter, "config", None), "extra", None)if isinstance(extra, dict):for key in ("allow_from", "allowed_users"):diff --git a/tests/gateway/test_pairing_allowlist_bypass.py b/tests/gateway/test_pairing_allowlist_bypass.pyindex c30c09ed32d..12aeb351700 100644--- a/tests/gateway/test_pairing_allowlist_bypass.py+++ b/tests/gateway/test_pairing_allowlist_bypass.py@@ -397,9 +397,7 @@ def test_whatsapp_live_allowlist_denies_when_env_key_removed(monkeypatch):@pytest.mark.asyncio-async def test_matrix_pairing_revoke_denies_live_message_and_approval_without_restart(- store, monkeypatch,-):+async def test_matrix_pairing_revoke_denies_live_message_and_approval_without_restart(store):"""The runner's live pairing verdict must gate both Matrix messages and approvals."""from unittest.mock import AsyncMock, patch@@ -460,9 +458,7 @@ async def test_matrix_pairing_revoke_denies_live_message_and_approval_without_reassert before_prompt.resolved is Truebefore_resolve.assert_called_once_with("session-$before", "once")- adapter_identity = id(adapter)assert store.revoke("matrix", user_id) is True- assert id(adapter) == adapter_identityassert store.is_approved("matrix", user_id) is Falseassert runner._is_user_authorized(source) is False@@ -504,6 +500,7 @@ def test_matrix_pairing_revoke_purges_live_allowlist_snapshot(store, monkeypatch))assert adapter._is_authorized_user(paired_id) is True+ held = adapter._allowed_user_ids # e.g. a Discord approval view's referencerunner = SimpleNamespace(adapters={Platform.MATRIX: adapter},@@ -514,4 +511,5 @@ def test_matrix_pairing_revoke_purges_live_allowlist_snapshot(store, monkeypatchassert store.revoke("matrix", paired_id) is Trueassert os.environ["MATRIX_ALLOWED_USERS"] == owner_idassert paired_id not in adapter._allowed_user_ids+ assert paired_id not in heldassert adapter._is_authorized_user(paired_id) is False