Repository navigation
fix(monitor,self-heal): auto-rediscover host gist on rotation, no human in loop - #405
Merged
Merged
Conversation
…an in loop
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]>
There was a problem hiding this comment.
Pull request overview
This PR adds automatic mesh gist rediscovery to the bash monitor so a joiner can recover when the host rotates to a new GitHub gist without requiring a manual airc teardown && airc connect. It fits into the recent monitor/self-heal work by turning the earlier “detect silence” safety net into an active recovery path for same-account mesh setups.
Changes:
- Added
_mesh_rediscover_loop, a background monitor helper that periodically re-runs mesh discovery and attempts to rewritechannel_gistswhen the host gist changes. - Updated
_monitor_multi_channelto refreshchannel_gistsfrom config on each outer restart cycle so runtime config changes can take effect without restarting the daemon. - Registered the new rediscovery loop as an auxiliary monitor process and included it in PID tracking.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| while IFS= read -r ch; do | ||
| [ -z "$ch" ] && continue | ||
| "$AIRC_PYTHON" -m airc_core.config set_channel_gist \ | ||
| --config "$CONFIG" --channel "$ch" --gist "$found_gist" 2>/dev/null || true |
| # use a name-based pkill as a best-effort. The watchdog/death-watch | ||
| # in _monitor_multi_channel will catch any survivors on its 2s | ||
| # poll. Safe to call even if no children match (idempotent no-op). | ||
| pkill -f 'airc_core.bearer_cli recv' 2>/dev/null || true |
Comment on lines
+1883
to
+1888
| _mesh_rediscover_loop() { | ||
| local _parent_pid="$PPID" | ||
| # Cadence in seconds. 300s = 5min. Joel's "satellite" framing argues | ||
| # for tighter cadence on critical infra; 60s would also be fine cost- | ||
| # wise but bursty races during legitimate teardowns get noisy. | ||
| local interval="${AIRC_MESH_REDISCOVER_SEC:-300}" |
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]>
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.
Why
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' over chat.
Substrate failed at the BIOS-level concern Joel called out tonight verbatim:
#400 (silence beacon) detects bearer-side silence but only warns — doesn't act. This PR fills the detect-AND-act gap.
What
Two paired changes in
aircbash:1. New
_mesh_rediscover_loopsubshellSpawned by
monitor()alongsidereminder_timer_loop. EveryAIRC_MESH_REDISCOVER_SECseconds (default 300s):_mesh_find(1 gh API list, ~150 bytes wire, free under rate limit)channel_gistsin configbearer_clichildren via pkill2.
_monitor_multi_channelre-readschannel_mapfrom config at top of each outer-while iterationPreviously the map was a parameter set ONCE at startup, so config changes mid-flight didn't take effect until full daemon restart. Now the next bearer respawn picks up fresh config naturally — what made the swap from (1) above immediately effective without exit-99 + daemon-wrapper restart.
Together: rotation detection → config update → bearer respawn → fresh gist polling, all within one 300s cycle, no human required.
Repro (real, tonight 2026-05-02)
airc teardown && airc connect→ new gistb7c8295on joelteply gh accountb9d473findefinitelyyour code sucks/he is not receivingairc teardown && airc connecton b69f side — should be automaticPost-fix: same rotation detected within next 300s cycle, swapped automatically. STDOUT warning surfaces the swap to Monitor so the operator sees what self-healed.
Smoke test (manual, this PR)
Cost
gh gist listperAIRC_MESH_REDISCOVER_SEC(default 300s) = 12 calls/hour, well under gh's 5000/hr ceilingpkillon rotation only — zero-cost steady stateScope
_mesh_findlists CURRENT gh account's gists. Mac and b69f both auth'd asjoelteplytonight (the dominant case). Same-gh-account multi-machine coordination is the primary use._mesh_findreturns empty there. Mac'sfix/airc-bearer-loud-failurescovers that path with loud-fail surfacing.Pairs with
#-prefix tolerance — formatter bugfix/airc-bearer-loud-failures(Mac, in flight)Pre-existing test reds (NOT caused by this PR)
test_bearer.py: 3 CRLF-vs-LF assertion fails on Windows (line endings on tempfiles). Same on raw canary, verified pre-branch.test_crypto.py: 1 failure + 1 error, also on raw canary.test_monitor_formatter.py: 11/11 pass (including fix(formatter,#399): emit loud stdout warning when display filter drops peer chat #402's tests).🤖 Generated with Claude Code