The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): name every gone-pin cause in the watch drop warning
Kurt VanDusen321907145f08
diff --git a/gateway/run_notifications_ownership.py b/gateway/run_notifications_ownership.pyindex d03f57b68bc..eeb84435220 100644--- a/gateway/run_notifications_ownership.py+++ b/gateway/run_notifications_ownership.py@@ -155,9 +155,9 @@ class GatewayNotificationOwnershipMixin:if verdict != "terminal":return Falselogger.warning(- "Dropping %s notification of process %s: pinned session %s is permanently gone (user "- "boundary such as /new); the route now runs %s and refuses it (%s). Output remains "- "available via process(action='log').",+ "Dropping %s notification of process %s: pinned session %s is permanently gone (closed "+ "at a user boundary such as /new, or no longer an owner); the route now runs %s and "+ "refuses it (%s). Output remains available via process(action='log').",evt.get("type") or "watch", evt.get("session_id") or "<unknown>", pinned,cast(Any, self).session_store.peek_session_id(session_key) or "<none>", refusal,)diff --git a/tests/gateway/test_background_process_notifications.py b/tests/gateway/test_background_process_notifications.pyindex e0847aee885..694fc629b8a 100644--- a/tests/gateway/test_background_process_notifications.py+++ b/tests/gateway/test_background_process_notifications.py@@ -17,11 +17,10 @@ from unittest.mock import AsyncMockimport pytest-from tests.module_clock import install_module_clock-from gateway.config import GatewayConfig, Platformfrom gateway.run import GatewayRunner, _parse_session_keyfrom gateway.run_notifications import INTERNAL_NOTIFICATION_FOOTER+from tests.module_clock import install_module_clock# ---------------------------------------------------------------------------@@ -361,10 +360,11 @@ async def test_post_turn_watch_drain_refused_event_backs_off_then_drops(monkeypabreakassert len(attempt_times) == _MAX_COMPLETION_INJECTION_ATTEMPTS- # Backoff, not one attempt per drain tick: each retry waits twice the last, up to the cap.+ # Backoff, not one attempt per drain tick: the wait starts at the base, grows, and stops at the cap.gaps = [b - a for a, b in itertools.pairwise(attempt_times)]- assert gaps == [min(_WATCH_INJECTION_RETRY_BASE_DELAY * 2 ** n, _COMPLETION_INJECTION_RETRY_MAX_DELAY)- for n in range(_MAX_COMPLETION_INJECTION_ATTEMPTS - 1)]+ assert gaps[0] >= _WATCH_INJECTION_RETRY_BASE_DELAY+ assert all(b >= a for a, b in itertools.pairwise(gaps)) and gaps[-1] > gaps[0]+ assert max(gaps) <= _COMPLETION_INJECTION_RETRY_MAX_DELAYassert completion_queue.empty()drops = [r for r in caplog.recordsif r.levelno >= logging.WARNING and "dropping the queued event" in r.message]diff --git a/tests/gateway/test_watch_notification_reset_pin.py b/tests/gateway/test_watch_notification_reset_pin.pyindex 62a3ac3fa9a..f2c0ad7b9aa 100644--- a/tests/gateway/test_watch_notification_reset_pin.py+++ b/tests/gateway/test_watch_notification_reset_pin.py@@ -139,6 +139,37 @@ async def test_durable_caller_still_gets_the_refusal_for_a_gone_pin(monkeypatch,authority.db.close()+async def test_refused_notice_pinned_to_a_compression_ancestor_is_retried(monkeypatch, caplog):+ """A compression ancestor is not gone: whatever refused its notice, the notice stays queued."""+ from gateway import session_automation+ from hermes_state_runtime import RuntimeStoreError+ runner, authority, entry = await _gateway(monkeypatch)+ try:+ parent, child = entry.session_id, entry.session_id + '-compressed'+ runner.session_store._db_for_key(entry.session_key).publish_compression_child(+ parent_session_id=parent, child_session_id=child, source='discord',+ require_compression_lease=False, model='offline', model_config={},+ system_prompt='offline', messages=[{'role': 'user', 'content': 'retained'}],+ )+ assert runner.session_store.advance_compression_session(entry.session_key, parent, child)++ async def refuse(*_args):+ raise RuntimeStoreError('admission_conflict')+ monkeypatch.setattr(session_automation, 'admit_process_notice', refuse)+ notice = _notice(entry, parent)+ pending = queue.Queue()+ pending.put(notice)++ with caplog.at_level(logging.WARNING, logger='gateway.run'):+ await runner._drain_watch_notifications(pending)++ assert pending.get_nowait() is notice+ assert not [r for r in caplog.records if 'permanently gone' in r.getMessage()]+ finally:+ authority.db.close()++async def _foreign_pin(runner):"""A live session of another chat: the authority refuses the notice, but nothing proves the pingone, so the refusal stays retryable."""