Repository navigation
fix(monitor): inactivity watchdog — detect silently-dead SSH tails - #24
Merged
Merged
Conversation
Symptom: airc status reports monitor "running" while last_recv climbs into the minutes. Messages stop being delivered. Teardown + airc connect restores flow. Observed repeatedly on 2026-04-20, multiple times per multi-hour session. Root cause: SSH's ServerAliveInterval / ServerAliveCountMax only detects "no ACKs to keepalives" — but some middleboxes / sleeping hosts silently drop the TCP payload channel while still ACKing keepalives at the TCP layer. SSH thinks the connection is healthy and doesn't close; the remote tail -F keeps running but its output never reaches the local ssh pipe. The local monitor_formatter's Python `for line in sys.stdin:` blocks on read forever. Pipeline stays open, bash while-loop never iterates, status check sees a live PID and reports "running." Fix: application-level inactivity watchdog inside monitor_formatter. If no line arrives in WATCHDOG_SEC (180s — longer than normal chat idle, shorter than anyone's frustration threshold), Python exits non-zero. The pipeline closes, ssh exits, the while-loop's `|| true` catches it, sleep 3, reconnect. Clean restart. Normal traffic resets the alarm on every inbound line — zero penalty for healthy channels. A stderr line surfaces the event so operators can see why the tail restarted, instead of the previous invisible silent hang. Pairs with #22 (trap preservation) as the two fixes needed to make monitor_formatter robust across the long-tail of connection failures that do NOT trigger SSH's built-in detection.
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
airc statusreportsmonitor: runningwhilelast_recvclimbs into the minutes. Messages stop being delivered. Teardown +airc connectrestores flow. Observed repeatedly on 2026-04-20 in a multi-hour multi-agent session (memento + anvil); Joel called it out directly as the recurring productivity-killer.Root cause
SSH's
ServerAliveInterval/ServerAliveCountMaxonly catches "no ACKs to keepalive packets." Some middleboxes / sleeping hosts / long-idle tailscale paths silently drop the TCP payload channel while still ACKing SSH keepalives at the TCP layer. SSH thinks the connection is healthy and does not close; the remotetail -Fkeeps running but its output never reaches the local ssh pipe. The localmonitor_formatter's Pythonfor line in sys.stdin:blocks on read forever. Pipeline stays open, bash while-loop never iterates, status check sees a live PID and reportsrunning.The existing SSH keepalive options help but are insufficient for this class of failure.
Fix
Application-level inactivity watchdog inside
monitor_formatter. If no line arrives inWATCHDOG_SEC(180s — longer than typical chat idle, shorter than frustration threshold), Python exits non-zero viaos._exit(2). The pipeline closes, ssh exits, the while-loop's|| truecatches it, `sleep 3`, reconnect.Normal traffic resets the alarm on every inbound line — zero penalty for healthy channels. A stderr line surfaces the event so operators can see why the tail restarted, instead of the previous invisible silent hang.
Test plan
Pairs with #22 (trap preservation). Together they cover the long-tail of connection failures that do NOT trigger SSH's built-in detection.