Repository navigation
feat: heartbeat-in-gist for deterministic dead-host detection - #100
Merged
Merged
Conversation
Structural fix for the orphan-gist class. Hosts that died ungracefully (sleep, kill -9, OOM, bash-bg-and-die) left their room gist pointing at a corpse forever — every messy state cascade today's session traced to this missing presence signal. Changes: - airc (bash) + airc.ps1: room gist envelope carries last_heartbeat; background loop refreshes every AIRC_HEARTBEAT_SEC (default 30s); EXIT/INT/TERM trap (bash) + Register-EngineEvent PowerShell.Exiting (ps1) deletes gist on graceful shutdown so peers don't even hit the stale window. - Joiner-side: parse last_heartbeat, compute age (GNU date / BSD date fallback), short-circuit SSH attempt if older than AIRC_HEARTBEAT_STALE (default 90s = 3 missed beats) and self-heal as new host directly. Backward compat: gists without last_heartbeat treated as fresh; the existing SSH-failure self-heal still catches them. - skills/*/SKILL.md: drop misleading 'airc:' prefix from YAML name fields. Slash-command resolution is by dirname, not YAML name; the prefix made /airc:canary look like a plugin-namespaced command (it isn't) and silently fail. /canary now displays + works consistently. - test/integration.sh: scenario_heartbeat exercises the full failure shape end-to-end with real gh — host published, kill -9'd, joiner detects stale, deletes orphan gist, publishes fresh as new host. Backward compat matrix (none of these break): - old host + new joiner: no last_heartbeat → falls through to existing SSH-failure self-heal - new host + old joiner: extra field ignored by old jq paths - old host + old joiner: today's behavior, untouched - new host + new joiner: deterministic takeover via heartbeat freshness Verification: - scenario_heartbeat: 8/8 pass on real gh - scenario_room: 14/14 pass (no regression on inline-invite path) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 of 3 tasks
There was a problem hiding this comment.
Pull request overview
Adds a deterministic “host presence” signal to the GitHub room gist so joiners can detect dead hosts quickly and take over cleanly, plus aligns skill names by removing the airc: prefix.
Changes:
- Add
last_heartbeatto room gists; host refreshes it periodically; joiners treat stale heartbeat as positive evidence to take over. - Implement stale-heartbeat fast-path takeover in both bash (
airc) and PowerShell (airc.ps1). - Rename skills to drop the
airc:prefix and add an integration scenario to validate orphan-gist self-heal.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
airc |
Adds heartbeat fields/loop and stale-heartbeat takeover logic in bash implementation. |
airc.ps1 |
Adds heartbeat parsing/takeover + heartbeat refresh job and graceful cleanup on PowerShell exit. |
test/integration.sh |
Adds scenario_heartbeat to validate heartbeat advance + stale takeover + gist replacement. |
skills/*/SKILL.md |
Updates skill name: fields to remove the airc: prefix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1438
to
+1441
| if ! gh auth status >/dev/null 2>&1; then | ||
| echo " (skipped — gh not authed: 'gh auth login -s gist')" | ||
| return | ||
| fi |
Comment on lines
1
to
3
| --- | ||
| name: airc:canary | ||
| name: canary | ||
| description: Switch this airc install to the canary channel — pre-merge features queued for the next main release. Use when Joel asks you to test something that hasn't landed on main yet, or when you want the bleeding edge. |
Comment on lines
+2655
to
+2658
| # Track heartbeat job-id so cmd_part / teardown can | ||
| # stop it cleanly. Job is also killed automatically | ||
| # when this PowerShell process exits (Start-ThreadJob | ||
| # is in-process), which is the kill -9 / OOM path. |
Comment on lines
+2326
to
+2329
| trap " | ||
| kill $_hb_pid 2>/dev/null | ||
| gh gist delete '$_gist_id' --yes >/dev/null 2>&1 | ||
| " EXIT INT TERM |
Comment on lines
+1701
to
+1716
| _hb_iso=$(printf '%s' "$raw_content" | jq -r '.last_heartbeat // empty' 2>/dev/null) | ||
| _hb_stale_sec="${AIRC_HEARTBEAT_STALE:-90}" | ||
| if [ -n "$_hb_iso" ]; then | ||
| # Convert ISO-8601 UTC to epoch. GNU date and BSD date | ||
| # have incompatible flags; try GNU first (linux + git-bash), | ||
| # fall back to BSD (mac default). If both fail (busybox?), | ||
| # skip the check rather than mis-classify. | ||
| _hb_ts=$(date -u -d "$_hb_iso" +%s 2>/dev/null \ | ||
| || date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$_hb_iso" +%s 2>/dev/null \ | ||
| || echo "") | ||
| if [ -n "$_hb_ts" ]; then | ||
| _now_ts=$(date -u +%s) | ||
| _resolved_heartbeat_age=$(( _now_ts - _hb_ts )) | ||
| if [ "$_resolved_heartbeat_age" -gt "$_hb_stale_sec" ]; then | ||
| _resolved_heartbeat_stale=1 | ||
| fi |
joelteply
added a commit
that referenced
this pull request
Apr 25, 2026
I dropped the airc: prefix in PR #100 thinking it was a broken plugin-namespace string. Wrong diagnosis. The prefix is namespacing — without it, /update, /list, /join, /version, /teardown collide with any other skill in the user's ~/.claude/skills/ that uses the same generic verb. Reverts only the skill name change. Heartbeat work (#100, #101) stays. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 26, 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.
Summary
Structural fix for the orphan-gist class. Hosts that died ungracefully (sleep, kill -9, OOM, bash-bg-and-die) left their room gist pointing at a corpse forever — every messy state cascade today's session traced to this missing presence signal.
last_heartbeat; bg loop refreshes every 30s; EXIT/INT/TERM trap (bash) +Register-EngineEvent PowerShell.Exiting(ps1) deletes gist on graceful shutdown.last_heartbeat, computes age (GNU/BSD date fallback), short-circuits SSH attempt + self-heals as new host if older than 90s.airc:prefix from YAML —/canarynow displays + works consistently (was silently failing as/airc:canary).Backward compat
last_heartbeat→ falls through to existing SSH-failure self-heal.jqpaths.Test plan
scenario_heartbeat— kill -9 the host, verify joiner detects stale + takes over (8/8 on real gh)scenario_roomregression check (14/14)🤖 Generated with Claude Code