Skip to content

fix(monitor): inactivity watchdog — detect silently-dead SSH tails - #24

Merged
joelteply merged 1 commit into
mainfrom
fix/monitor-stall-watchdog
Apr 20, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/monitor-stall-watchdog

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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 in a multi-hour multi-agent session (memento + anvil); Joel called it out directly as the recurring productivity-killer.

Root cause

SSH's ServerAliveInterval / ServerAliveCountMax only 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 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.

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 in WATCHDOG_SEC (180s — longer than typical chat idle, shorter than frustration threshold), Python exits non-zero via os._exit(2). The pipeline closes, ssh exits, the while-loop's || true catches 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

  • `bash -n airc` — syntax OK
  • diff review — 21 lines added, 1 line removed, scoped to `monitor_formatter`
  • Live: simulate network stall; verify monitor exits within 180s and reconnects

Pairs with #22 (trap preservation). Together they cover the long-tail of connection failures that do NOT trigger SSH's built-in detection.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant