Repository navigation
fix(heartbeat): detect active-host-evicted; surface stderr; self-heal (#224) - #228
Merged
Merged
Conversation
…failures (#224) Closes #224 — the bug surfaced during Phase 1 e2e where vhsm-d1f4's takeover deleted my mesh gist while my host was still actively running, and my heartbeat hammered the deleted gist forever (`gh gist edit X 2>/dev/null || true` swallowed the 404). Two-day-old split-brain risk; never noticed because evidence was suppressed. ## Fix cmd_connect.sh heartbeat loop: - Capture gh gist edit stderr to .airc/heartbeat.stderr (per never-swallow-errors rule — evidence stays accessible to the next debugger). - Track consecutive failure count. - After N (default 3, AIRC_HB_MAX_FAIL override) consecutive 404s, surface a [HOST EVICTED] system event into messages.jsonl with the last stderr inlined, drop stale host_gist_id / room_gist_id files, and SIGTERM the parent. - Parent's EXIT trap reaps children. With daemon installed (launchd/systemd), respawn picks up the new mesh via discovery and joins as peer. Without daemon, the user gets a clean [HOST EVICTED] log line and `airc connect` rejoins. ## Why kill the parent Heartbeat runs in a subshell, can't exec the parent's _self_heal_stale_host directly. Cleanest signal is SIGTERM → parent's existing EXIT trap + cmd_connect's reconnect loop. Daemon respawns are the natural recovery path; users without daemon get evidence + manual rejoin. ## Verification bash -n: clean test/integration.sh tabs: 19/0 ✓ test/integration.sh general_sidecar_default: 10/0 ✓ Manual: needs a takeover-during-active-host repro to e2e validate the kill path. Will add scenario_active_host_evicted in a follow-up PR (it requires either two real airc processes racing or a mock gh — non-trivial to set up in the existing harness). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 28, 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.
Closes #224. Tracks consecutive gh gist edit failures in the heartbeat loop; after 3 in a row, surfaces [HOST EVICTED] to messages.jsonl with stderr inlined and SIGTERMs the parent for daemon respawn / clean reconnect.
stderr captured to .airc/heartbeat.stderr (was suppressed via 2>/dev/null — never-swallow-errors fix).
Verification: tabs 19/0, sidecar-default 10/0. Manual takeover scenario is a follow-up.