Repository navigation
fix(monitor): isolate failed channel bearer restarts - #452
Merged
Merged
Conversation
joelteply
force-pushed
the
fix/channel-monitor-heal
branch
from
May 4, 2026 16:43
eb18985 to
d65fae9
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates airc’s multi-channel monitor so an individual bearer_cli recv failure is handled per-channel instead of tearing down the entire multi-channel monitor. It fits into the monitor/self-heal path by trying to preserve healthy channel delivery while retrying only the failed subscription.
Changes:
- Replaced the “one child dies → restart everything” watch loop with per-channel restart logic.
- Re-read
channel_gistsfor the failed channel before respawning, so gist rotation can be picked up without rebuilding the whole formatter pipe. - Leave channels with missing mappings offline instead of killing other active channel bearers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1366
to
+1373
| if [ -n "$gid" ]; then | ||
| sleep 3 | ||
| "$AIRC_PYTHON" -u -m airc_core.bearer_cli recv "self" \ | ||
| --room-gist-id "$gid" \ | ||
| --offset-file "$AIRC_WRITE_DIR/monitor_offset.${ch}" \ | ||
| --state-file "$AIRC_WRITE_DIR/bearer_state.${ch}.json" \ | ||
| 2>>"$AIRC_WRITE_DIR/bearer_recv.${ch}.log" & | ||
| _alive+=("$!:$ch") |
Comment on lines
+1374
to
+1375
| else | ||
| echo "airc: #${ch} has no channel_gists mapping; leaving it offline while other channels continue" >&2 |
Comment on lines
+1352
to
+1356
| echo "airc: bearer recv for #${ch} died — see ${AIRC_WRITE_DIR}/bearer_recv.${ch}.log; restarting that channel only" >&2 | ||
| # Surface the last-error tail so the user sees WHY without | ||
| # having to know to read the log file. | ||
| if [ -s "$AIRC_WRITE_DIR/bearer_recv.${ch}.log" ]; then | ||
| tail -3 "$AIRC_WRITE_DIR/bearer_recv.${ch}.log" | sed 's/^/airc: /' >&2 |
This was referenced May 4, 2026
Merged
Merged
joelteply
added a commit
that referenced
this pull request
May 4, 2026
…inite respawn loop when channels share a gist (#458) fix(monitor): dedup bearer spawns by gist, not by channel Real-world repro Joel hit 2026-05-04: channel_gists collapsed useideem and general onto the SAME gist (host advertising one mesh gist for both subscribed channels). #452's per-(scope, gist) lock correctly admitted only ONE bearer for that gist — but the bash supervisor in _monitor_multi_channel iterated channels and spawned one bearer per channel REGARDLESS of gist sharing. Result: the lock-loser bearer exits 0 cleanly with "another bearer for gist X already running"; supervisor sees the exit as a death, respawns, loses lock again, ad infinitum. bearer_recv.<ch>.log filled with identical exit-cleanly lines, the channel's events_total stayed at 0, and inbound messages on that channel never reached the user. This was the third bearer-related design-mismatch bug in the same session (#451 was process lifecycle, #452 was the lock-key mismatch, this is the supervisor-key mismatch). Fixing at the supervisor: dedup by gist BEFORE spawning. Same invariant in both paths: - Initial spawn (channel_map iteration): track _served_gists set; skip channels whose gist already has a bearer from earlier in the iteration. - Live-refresh add path: build _live_gists from current _pids (resolving each entry's channel→gist via the current map); skip channels whose gist is already covered by another live bearer. The bearer reads the gist once and yields each line; monitor_formatter routes to subscribed channels via the envelope's `channel` field downstream. State files stay per-channel for now (per-gist state- files would be a deeper refactor that touches status/doctor/cmd_send; not blocking tonight's Toby remote-conn test). 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.
Summary
Why
Two common monitor failures were found live:
Verification
bash -n aircgit diff --check./test/integration.sh inboxpython3 -m py_compile lib/airc_core/bearer_cli.pypython3 test/test_bearer.py(90 tests OK)QA ask
Please test both common scenarios: