fix(tools,gateway): format watch_overflow events instead of dropping them
format_process_notification had no case for watch_overflow_tripped / watch_overflow_released, so a watch-pattern notification flood surfaced as '[IMPORTANT: Background process exited (exit code ?)]' — a phantom exit notification for a process that never existed — while the actual 'watch flood, N notifications suppressed' summary in the event's message field was silently dropped. The gateway delivery path was worse: _drain_gateway_watch_events retained only watch_match and watch_disabled, discarding overflow events entirely before formatting. Route both event types through the message field in the shared formatter and the gateway formatter, and retain them in the gateway drain.
This commit is contained in:
@@ -336,3 +336,32 @@ class TestGlobalCircuitBreaker:
|
||||
admitted = True
|
||||
assert released
|
||||
assert admitted
|
||||
|
||||
|
||||
class TestOverflowNotificationFormatting:
|
||||
"""watch_overflow_* events must surface their summary, not fall through
|
||||
to the completion formatter as a phantom 'process exited (exit code ?)'."""
|
||||
|
||||
def test_overflow_tripped_formats_message(self):
|
||||
from tools.process_registry import format_process_notification
|
||||
|
||||
evt = {
|
||||
"type": "watch_overflow_tripped",
|
||||
"message": "watch flood detected: 47 notifications suppressed for pattern 'ERROR'",
|
||||
"session_id": "proc_a1b2",
|
||||
}
|
||||
out = format_process_notification(evt)
|
||||
assert "47 notifications suppressed" in out
|
||||
assert "exit code" not in out
|
||||
|
||||
def test_overflow_released_formats_message(self):
|
||||
from tools.process_registry import format_process_notification
|
||||
|
||||
evt = {
|
||||
"type": "watch_overflow_released",
|
||||
"message": "watch flood released: notifications resumed for pattern 'ERROR'",
|
||||
"session_id": "proc_a1b2",
|
||||
}
|
||||
out = format_process_notification(evt)
|
||||
assert "notifications resumed" in out
|
||||
assert "exit code" not in out
|
||||
|
||||
Reference in New Issue
Block a user