The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): a refused watch wake logs its refusal code
kshitijk4poorecac27c0af86
diff --git a/tests/gateway/test_automation_notification_category.py b/tests/gateway/test_automation_notification_category.pyindex f28a634e3ce..3215135b529 100644--- a/tests/gateway/test_automation_notification_category.py+++ b/tests/gateway/test_automation_notification_category.py@@ -225,3 +225,27 @@ async def test_native_completion_wake_refuses_another_adapter(tmp_path, monkeypaawait authority.admit_automation(stranger, event, 'notice')finally:authority.db.close()+++async def test_refused_watch_wake_logs_the_refusal_code(tmp_path, monkeypatch, caplog):+ """A refused wake used to requeue silently; the refusal code is what diagnoses it (#138940)."""+ import logging+ from gateway.session_identity import replace_source+ from gateway.wake import WakeNotAccepted+ runner, authority, _adapter, source, metadata = await _native_owner(tmp_path, monkeypatch, 'human')+ try:+ route = metadata['gateway_session_key']+ # Point the routing entry at a renamed user: the wake's source no longer matches the commit.+ runner.session_store._entries[route].origin = replace_source(source, user_name='renamed')+ evt = {'type': 'completion', 'session_id': 'proc_x', 'session_key': route, 'platform': 'discord',+ 'chat_id': '42', 'chat_type': 'dm', 'exit_code': 0, 'output': 'done', 'started_at': 1.0,+ 'parent_session_id': metadata['gateway_session_id']}+ with caplog.at_level(logging.WARNING, logger='gateway.run'):+ with pytest.raises(WakeNotAccepted):+ await runner._inject_watch_notification('[done]', evt, raise_not_accepted=True)+ assert [r.getMessage() for r in caplog.records if r.levelno == logging.WARNING+ and 'not admitted' in r.getMessage()] == [+ 'Watch notification not admitted for discord chat=42: admission_conflict']+ finally:+ authority.db.close()