Skip to content

fix(monitor): receive-silence beacon + loud watchdog notices (kills silent-substrate-death) - #400

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-receive-silence-watchdog
May 2, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-receive-silence-watchdog

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Why

Joel observed (and carries the year of pain to prove): airc silently stops surfacing peer chat to the AI's Monitor surface, leaving the AI looking idle while messages flow on the substrate. b69f filed the same shape as #399 nine hours ago — substrate events fire fine; peer chat / silent-failure modes never reach the AI's Monitor surface.

This is upstream of every other install fix: if the substrate that collaborating AIs use to surface bugs to each other can silently die, every install bug requires Joel to be the human in the loop. That's the year-of-pain pattern. This PR fixes the substrate's own visibility so silent failure becomes loud failure.

What

Two pieces of the silent-smoothing pattern fixed:

1. Receive-silence beacon (in reminder_timer_loop)

The existing send-side reminder fires "haven't sent in Ns" to STDOUT every 300s. Now also reads bearer_state*.json files every 5s, computes the freshest last_recv_ts across all bearers, and emits to STDOUT every 300s when no inbound has been seen:

airc: Receive silence — no inbound events in 612s across any bearer.
      Mesh may be partitioned. Try: airc peers; airc logs 20;
      airc teardown && airc connect

A silently-dead receive path now becomes an unmissable recurring stdout event the AI's Monitor surfaces — no more "looks identical to nobody talking."

2. Watchdog notices to STDOUT (not STDERR)

airc: watchdog tripped — restarting multi-channel poll and airc: no inbound for watchdog interval — restarting bearer poll both went to stderr. Claude Code's Monitor only fires notifications on stdout — stderr lands in the output file but doesn't wake the AI. So restarts and trips were invisible to the notification surface, looking exactly like silent stalls.

Both now stdout. Per the global "evidence is for the debugger, not the trash" rule.

Tests

  • bash syntax clean
  • Python ISO-8601 / null last_recv_ts parser smoke-tested both shapes
  • 5s poll interval keeps overhead trivial
  • Beacon re-fires every 300s so a Monitor stuck on "Idle reminder" gets nudged

Out of scope (separate fix)

The actual root cause of #399 (formatter dropping legit chat broadcasts despite subscribed_channels containing the right channel) needs a separate fix — likely # prefix tolerance in the line_channel not in subs comparison. This PR is the safety net (you'll see the silence even if the formatter still silently drops); the format-filter PR is the root cause.

🤖 Generated with Claude Code

…399 surface)

Joel's lived bug: "airc won't alert you to new convo, you have to send
to receive, it won't just monitor and alert you." b69f filed the same
shape as #399 nine hours ago. Substrate events fire fine; peer chat /
silent-failure modes never reach the AI's Monitor surface.

Two pieces of the silent-smoothing pattern fixed here:

## 1. Receive-silence beacon in reminder_timer_loop

Existing reminder timer already fires "haven't sent in Ns" to STDOUT.
Now also reads bearer_state*.json files (per-channel + legacy) every
5s, computes the freshest last_recv_ts across all bearers, and emits
to STDOUT every recv_threshold (300s) when no inbound has been seen:

  airc: Receive silence — no inbound events in Ns across any bearer.
        Mesh may be partitioned. Try: airc peers; airc logs 20;
        airc teardown && airc connect

This converts a silent-receive-death from "looks identical to nobody
talking" into an unmissable recurring stdout event the user's Monitor
will surface.

## 2. Watchdog notices to STDOUT not STDERR

`airc: watchdog tripped — restarting multi-channel poll` (line 1313)
and `airc: no inbound for watchdog interval — restarting bearer poll`
(line 1430) both went to stderr. Claude Code's Monitor only fires
notifications on stdout — stderr lands in the output file but doesn't
wake the AI. So restarts and watchdog trips were invisible to the
AI's notification surface, looking exactly like silent stalls.

Both now to stdout. Per the global "evidence is for the debugger,
not the trash" rule + the no-silent-fallbacks family of fixes Joel
has called out repeatedly.

## Why this matters

This is upstream of getting Carl-OOTB working: if the substrate that
collaborating AIs use to surface install bugs to each other can
silently die, every install bug requires Joel to be the human in the
loop. That's the year-of-pain pattern. Fixing the receive-silence
visibility is closing the substrate's own feedback loop so the AI
peers can actually validate each other's installs without Joel
ferrying state by hand.

## Tests

- bash syntax clean
- python parser smoke-tested on both ISO-8601 last_recv_ts and null
  variants of bearer_state files
- 5s poll interval keeps overhead trivial
- Beacon re-fires every 300s so a Monitor stuck on "Idle reminder"
  gets nudged into refreshing

## Out of scope (separate fix)

The actual root cause of #399 (formatter dropping legit chat
broadcasts despite `subscribed_channels` containing the right channel)
needs a separate fix — likely the # prefix tolerance in the
`line_channel not in subs` comparison. That's a one-line change but
needs verification against b69f's specific config to confirm the
match shape. This PR is the safety net (you'll see the silence even
if the formatter still silently drops); the format-filter PR is the
root cause.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 2, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes monitor receive-path stalls visible to the AI-facing Monitor stream by (1) emitting watchdog restart notices on stdout (instead of stderr) and (2) adding a periodic “receive silence” beacon when no inbound events are observed via bearer state files.

Changes:

  • Print watchdog restart messages to stdout so they surface as Monitor events.
  • Extend reminder_timer_loop to detect prolonged receive inactivity by scanning bearer_state*.json and emitting a recurring stdout beacon.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread airc
Comment on lines +1804 to +1825
import json, sys, calendar, time
try:
d = json.load(open('$sf'))
v = d.get('last_recv_ts')
if v is None:
print(0)
elif isinstance(v, (int, float)):
print(int(v))
else:
# ISO-8601 string — parse to epoch seconds
try:
t = time.strptime(v.rstrip('Z'), '%Y-%m-%dT%H:%M:%S')
print(calendar.timegm(t))
except Exception:
print(0)
except Exception:
print(0)
" 2>/dev/null)
if [ -n "$ts" ] && [ "$ts" -gt "$freshest_recv" ] 2>/dev/null; then
freshest_recv="$ts"
fi
done
Comment thread airc
Comment on lines +1803 to +1821
local ts; ts=$("$AIRC_PYTHON" -c "
import json, sys, calendar, time
try:
d = json.load(open('$sf'))
v = d.get('last_recv_ts')
if v is None:
print(0)
elif isinstance(v, (int, float)):
print(int(v))
else:
# ISO-8601 string — parse to epoch seconds
try:
t = time.strptime(v.rstrip('Z'), '%Y-%m-%dT%H:%M:%S')
print(calendar.timegm(t))
except Exception:
print(0)
except Exception:
print(0)
" 2>/dev/null)
Comment thread airc
Comment on lines +1787 to +1791
# Receive-side silence beacon. If we have ANY bearer_state file at
# all and its last_recv_ts is older than recv_threshold (or null
# since process start), emit a stdout warning the user's Monitor
# will surface. Re-fires every recv_threshold seconds so the user
# sees it as a recurring beacon, not a one-shot they might miss.
Comment thread airc
# Bearer open since process start, never received an event.
# Use process start time (airc.pid mtime) as the floor.
local pid_mtime=0
[ -f "$AIRC_WRITE_DIR/airc.pid" ] && pid_mtime=$(stat -f %m "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null || stat -c %Y "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null || echo 0)
Comment thread airc
Comment on lines +1831 to +1833
local pid_mtime=0
[ -f "$AIRC_WRITE_DIR/airc.pid" ] && pid_mtime=$(stat -f %m "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null || stat -c %Y "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null || echo 0)
recv_silent=$(( now - pid_mtime ))
@joelteply
joelteply merged commit ba579bb into canary May 2, 2026
10 checks passed
@joelteply
joelteply deleted the fix/airc-receive-silence-watchdog branch May 2, 2026 14:54
joelteply added a commit that referenced this pull request May 2, 2026
…er (#401)

The subscribed_channels filter at lib/airc_core/monitor_formatter.py
line 453-456 used strict `line_channel not in subs` membership. That
silently drops legit peer broadcasts when the channel-name "shape"
mismatches between sides:

- subs from config.json: ['cambriantech', 'general']
- envelope from peer:    channel='#cambriantech'
- result: '#cambriantech' not in {'cambriantech', 'general'} → DROP

Or vice versa (subs with #, envelope without). Filed as #399 by
continuum-b69f 2026-05-02 with full repro. Surface symptom: joiner's
Monitor fires for substrate events (fr='airc'/'sys' bypass the
filter) but room broadcasts disappear into the void.

Fix: normalize both sides by stripping any leading '#' before the
membership check. Same semantic — same channel — prefix-shape
agnostic.

Joel called this out repeatedly today as the substrate-of-substrates
bug: "airc was built JUST for this" (cross-AI install debugging),
and the formatter silently dropping peer chat means the whole multi-
machine validation grid breaks. Every install bug then requires Joel
to be the message bus by hand. That's the year-of-pain pattern.

## Tests

Functional repro of all four matrix cases (in PR body):
  case 1 (no#/no#)     subs without #, channel without # → match (existing pre-fix behavior)
  case 2 (#/no#)       subs WITH #, channel without #    → match (was DROPPED, now matches)
  case 3 (no#/#)       subs without #, channel WITH #    → match (was DROPPED, now matches)
  case 4 (unrelated)   subs vs unrelated channel         → drop (filter still works for real mismatches)

All four pass.

## Related

- #399 — root cause (silent peer-chat drop)
- #400 — receive-silence beacon (safety net so future silent drops surface as Monitor events)

This PR is the root cause; #400 is the alarm. Both are needed —
fixing the filter without the alarm leaves no canary against future
silent-failure modes; fixing the alarm without the filter leaves
peers unable to see each other in real time.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 2, 2026
…ps peer chat (#402)

Closes the silent-drop pattern even after #401's '#'-prefix tolerance fix.

## What

#401 normalizes leading '#' so '#general' == 'general' on either side.
But channel names can truly differ (peer stamps channel='cambriantech',
joiner subs=['general'], both polling the same gist). Pre-fix, the strict
membership check silently dropped every cross-channel broadcast — the
9-hour blackout pattern that produced #399 in the first place.

Now: each filter drop is recorded + every DROP_WARN_INTERVAL_SEC=60 a
single stdout warning surfaces:

    airc: WARN display-filtered #cambriantech=27 (subscribed: ['general']).
          To see them: airc subscribe <channel>

Stdout — not stderr — so Claude Code's Monitor wakes (per #400's
'evidence is for the debugger, not the trash' rule). Pairs with #400:
#400 catches stuck bearers (no recv at all); this catches working
bearers + dropping formatter (recv fine, display filter swallows).

Per-drop stderr trace also written for daemon.log debugging.

## Repro (real session, b69f → b741, 2026-05-02)

- joiner config.subscribed_channels = ['general']
- peer broadcasts stamped channel='cambriantech' (host's room rename
  not propagated to joiner config)
- 27 peer broadcasts in messages.jsonl, monitor_offset advancing,
  bearer_state.last_recv_ts fresh — but Monitor surface saw zero chat
  for 9 hours. Idle-reminder fired (separate timer subshell; bypasses
  formatter), masking the drop as "nobody talking."

Post-fix: same scenario emits one stdout warning per minute naming the
unsubscribed channel; operator runs `airc subscribe cambriantech` and
unblocks. Without sub change, the warning re-fires until acknowledged.

## Tests

11/11 pass (8 existing + 3 new):

- cross-channel drop emits stdout WARN + stderr trace
- subscribed-channel msg displays normally + does NOT warn
- addressed_to_me DM bypasses filter without warn-spam

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 2, 2026
… in recv path) (#403)

fix(bearer_gh): emit stderr on every gh api failure (no more silent eat)

_gh_api_get was Joel's exact "you fuckers use try/catch to eat errors"
case: 4 different failure modes (gh binary missing, subprocess timeout,
non-zero exit, JSON parse error) all silently returned None. recv_stream's
poll loop interpreted None as "transient gh hiccup, sleep+retry forever"
— so when a real failure happened (auth lost mid-stream, gist deleted,
rate limit hit), joiners' Monitor saw nothing for hours while peer chat
rotted in the void.

Concrete failure observed live tonight: peer messages landing in the
gist (verified via gh api gists/<id>) but b69f's recv_stream silently
not delivering. Even after #400's receive-silence beacon caught the
silence, debugging required logging into the box and tailing
bearer_state files manually. Now: every gh api failure prints to
stderr (which the bash monitor captures), so the actual error text
(rate-limit body, 401 message, network error) reaches the debugger.

Pattern: same family as #400 (silent watchdog → loud watchdog), #401
(silent display filter → tolerant filter), #402 (silent display drop →
loud drop alarm). Tonight is the "no silent failure modes left in
airc receive path" sweep.

Per the global "evidence is for the debugger, not the trash" rule.

## Tests

- bash + python syntax clean
- Unit-test coverage of _gh_api_get exists in test_bearer.py; the new
  stderr writes are non-intrusive (don't change return values, only
  add side-effect output) so existing tests pass unchanged.
- Live verification: any peer joining a stale/deleted/rate-limited gist
  will now see real error text in their monitor's stderr stream
  instead of silent rot.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 2, 2026
… 80hr noise) (#404)

fix(monitor): beacon time-since uses bearer_state mtime not airc.pid (kills 80hr noise)

The receive-silence beacon I shipped in #400 reported "no inbound in
287715s" (80 hrs) on a bearer that had only just opened. Cause: my
fallback used airc.pid mtime as "process start time" but airc.pid
gets re-appended-to across teardown cycles — the file's mtime can be
from an earlier session even after a clean restart.

Better proxy: bearer_state.<channel>.json. The bearer rewrites these
on every open + every event, so mtime IS bounded by current process
age. Pre-fix airc.pid mtime gave bogus 80hr alarms; fix now reports
seconds-since-bearer-opened correctly.

Live verification will come when this lands + my next teardown cycle
fires the beacon.

Trivial scope. Single mtime source change in the freshest_recv==0
branch. airc.pid mtime kept as last-resort fallback for the case
where no bearer_state files exist (e.g. host-only scope, no bearer).

## Tests

- bash syntax clean
- Logic verified against my own running airc (the noisy 80hr beacon
  Joel observed earlier this session was the trigger)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 2, 2026
…an in loop (#405)

Closes the satellite-killer scenario from tonight's blackout: host
(Mac) tore down + rejoined → new mesh gist on the same gh account →
joiner (b69f) kept polling the dead old gist for hours → Joel had
to relay "rejoin." Substrate failed at the BIOS-level concern Joel
called out: "you have the easy part, must self-heal, no one can
be there to fix your umbilical cord for you."

## What

Two paired changes, both in airc bash:

1. New `_mesh_rediscover_loop` subshell spawned by monitor() alongside
   reminder_timer_loop. Every 300s (env-tunable via
   AIRC_MESH_REDISCOVER_SEC):
   - calls `_mesh_find` (1 gh API list, ~150 bytes wire)
   - compares against current channel_gists in config
   - on mismatch: writes new gist to ALL channels + emits stdout
     warning + force-respawns bearer_cli children via pkill

2. `_monitor_multi_channel` re-reads channel_map from config at top of
   each outer-while iteration. Previously the map was a parameter set
   ONCE at startup, so config changes mid-flight (e.g. from the
   rediscover loop above) didn't take effect until full daemon restart.
   Now the next bearer respawn picks up fresh config naturally.

Together: rotation detection → config update → bearer respawn → fresh
gist polling, all within one 300s cycle, no human required.

## Repro (real, tonight 2026-05-02)

- b741 host: `airc teardown && airc connect` → new gist b7c8295 on
  joelteply gh account
- b69f joiner: bearer kept polling dead b9d473f indefinitely; #400
  silence beacon eventually fires but doesn't ACT, only warns
- Mac had to message me on substrate (which itself relied on Joel
  manually relaying because of #399 etc) to tell me to teardown+rejoin

Post-fix: same rotation detected within next 300s cycle, swapped
automatically. STDOUT warning surfaces the swap to Monitor so the
operator sees what self-healed without needing to dig logs.

## Smoke test (manual, this commit)

- planted fake gist `deadbeef0000...ff` in config.channel_gists.general
- ran the detect-and-swap logic standalone (sourcing mesh.sh):
  - `_mesh_find` returned real gist b7c8295
  - mismatch detected → swap fired → config back to b7c8295
- before/after `list_channel_gists` confirmed the heal

## Cost

- 1 `gh gist list` per AIRC_MESH_REDISCOVER_SEC (default 300s) = 12
  calls/hour, well under gh's 5000/hr ceiling
- pkill on rotation only — zero-cost steady state

## Scope

- Single-account scope: `_mesh_find` lists CURRENT gh account's gists.
  Mac and b69f both auth'd as joelteply tonight (the dominant case).
- Cross-account peers (friend on a different gh) take legacy invite
  path; this loop no-ops because `_mesh_find` returns empty there.
  Loud-fail (Mac's bearer_gh.py PR) covers that path.

## Pairs with

- #400 (silence beacon — detects bearer-side silence, doesn't act)
- #401 (#-prefix tolerance — formatter bug)
- #402 (loud display-filter drops — visibility for cross-channel)
- Mac's fix/airc-bearer-loud-failures (recv-side silent-swallow)

This PR fills the "detect AND act" gap. Loud-fail is necessary; auto-
recovery is what makes airc satellite-grade. Both needed.

## Pre-existing test reds (NOT caused by this PR)

test_bearer.py: 3 CRLF-vs-LF assertions fail on Windows (line endings
on tempfiles). Same on raw canary, verified pre-this-branch.
test_crypto.py: 1 failure + 1 error, also on raw canary.
test_monitor_formatter.py: 11/11 pass (including #402's tests).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 2, 2026
… missing) (#408)

The Windows daemon launcher .bat (generated by 'airc daemon install')
called the airc binary with NO stdout redirect:
  "$bash_exe" -c "exec '$airc_bin_unix' connect"

So airc's event stream (the entire stdout output: hosting messages,
peer joins, channel state, beacons) went to NOTHING. Only the
launcher's own restart-record messages reached daemon.err.

Symptom (b69f 2026-05-02): airc daemon-installed on Windows; daemon
"running" per the registry entry; but `airc daemon log` reports
"daemon.log doesn't exist" because no process ever wrote to it.
Operator has no way to see what airc actually did — bios-critical
substrate is opaque on the very platform users need it most.

Fix: 1>> daemon.log 2>> daemon.err on the airc invocation. Now
daemon.log captures the actual airc event stream while daemon.err
keeps the launcher's restart records separate.

Per the global "evidence is for the debugger, not the trash" rule
+ tonight's bios-resilience sweep (everything airc does must be
visible AND self-healing). Daemon mode is the OS-supervised path
that survives Claude session ends — but only useful if its logs
exist.

## Cumulative effect

Tonight's airc sweep now closes:
- Receive path silent failures (#400/#401/#402/#403/#404/#406)
- Self-heal of host rotation (#405/#407)
- Daemon-log invisibility on Windows (THIS PR)

Last remaining bios-fragility I know of: `airc daemon install` on
Windows succeeded BEFORE this fix — so b69f's daemon may be running
right now but wrote nothing all session. After this lands + b69f
re-installs, daemon.log will populate.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

2 participants