Repository navigation
fix(heartbeat): port bearer_gh.py edit-then-add fallback + classify gh stderr (#348) - #350
Merged
Merged
Conversation
…h stderr (#348) bash heartbeat (cmd_connect.sh:1595) had two issues bearer_gh.py already solved for the message-send path back in #285: 1. `gh gist edit GIST FILE` (no flag) requires the basename to already exist in the gist. After a take-over / fresh-host race, the canonical `airc-room-<channel>.json` may not yet be in the gist. Plain edit then fails with 'unsure what file to edit; either specify --filename or run interactively' (or, per #285, silently no-ops). bearer_gh.py handles this by checking gist contents first and using `-a` (add) when the file isn't there. Port the same defense to bash. 2. When eviction fires after N consecutive heartbeat failures, the raw gh stderr is appended to the airc event log verbatim. Carl sees gh's vocabulary ('unsure what file to edit', '401 Unauthorized', 'API rate limit exceeded') in their airc event stream — opaque, off-vocabulary, no clear next action. Classify into airc-readable buckets (rate-limit / multi-file-disambig / auth / network) before emitting. Bash heartbeat now: - First attempt: `gh gist edit GIST FILE` (replace, happy path) - On failure with disambig stderr: retry as `gh gist edit GIST -a FILE` (add) - If both fail: count toward eviction - On eviction: classify the captured stderr → emit one airc event with human-readable cause (and a #348 self-link for the multi-file case so Carl knows it's a known bug, not their misconfiguration) Doesn't touch the eviction threshold, the local-state cleanup, or the SIGTERM-parent self-heal — those were already correct. Just the gh-call shape and the user-facing event text. Per other-mac's #348 review: classifier covers the four buckets we discussed (rate-limit, multi-file-disambig, auth, network) plus a raw-fallback for unmodeled errors and an empty-stderr branch for defense-in-depth. Test: syntax check passes; behavioral verification will land via the next mesh take-over scenario or a doctor scenario added in a follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 30, 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.
Fixes #348. bash heartbeat (cmd_connect.sh:1595) had two issues that bearer_gh.py already solved for the message-send path back in #285:
1.
gh gist edit GIST FILEdoesn't handle "file not yet in gist"After a take-over / fresh-host race, the canonical
airc-room-<channel>.jsonmay not yet be in the gist. Plaingh gist edit GIST FILEthen fails withunsure what file to edit; either specify --filename or run interactively(or per #285 silently no-ops). bearer_gh.py handles this by checking gist contents first and using-a(add) when the file isn't there. Ported the same defense to bash via a check-edit-then-fallback-to-add pattern.2. Raw gh stderr leaked into the airc event log
On eviction, the
[HOST EVICTED]marker appended the raw gh stderr verbatim. Carl saw gh's vocabulary (unsure what file to edit,401 Unauthorized,API rate limit exceeded) in their airc event stream — opaque, off-vocabulary, no clear next action. Now classified into airc-readable buckets per the #348 comment thread:rate-limit (gh secondary; back off 5-15 min before retry)multi-file gist disambiguation (#348 — airc bug, please report)gh auth failure (run 'gh auth login -h github.com')network errorunknown (no stderr captured)What it doesn't change
AIRC_HB_MAX_FAIL)host_gist_id,room_gist_idstill removed before eviction)Test plan
bash -n cmd_connect.sh)messages.jsonlonly (noairc-room-<channel>.jsonyet) → first heartbeat should hit the disambig stderr → fallback-ashould succeed → no eviction[HOST EVICTED] ... cause: gh auth failure (run 'gh auth login -h github.com')instead of raw401 Unauthorizedtextheartbeat_persists_through_multifile_gist(suggested in Host eviction triggered by 'gh: unsure what file to edit; either specify --filename or run interactively' #348) — separate follow-up PR; not in scope hereOut of scope
The same classifier shape would help in
cmd_send.sh'sauth_failurebranch (still surfaces "your GitHub token is dead" without the rate-limit-vs-auth distinction). Separate follow-up — needs a look at the Python bearer's auth_failure determination first.Ready for review when CI clears.
🤖 Generated with Claude Code