Skip to content

fix(join): three resume bugs from a single dogfooding session - #116

Merged
joelteply merged 1 commit into
canaryfrom
fix/join-resume-three-bugs
Apr 26, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/join-resume-three-bugs

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Three bugs in the airc join resume / discovery flow, all hit back-to-back in one session on 2026-04-26 (vhsm-2c84 dead host → auto-scope siloing into #general instead of #useideem → explicit --room useideem ignored after a part). They compound: each fix surfaces the next.

  1. Auto-scope re-enabled as default. PR fix: airc join defaults to #general, not cwd-derived scope #104 gated git-org-derived rooms behind AIRC_AUTO_SCOPE_ROOM=1 to avoid cross-project siloing, but the converse bug was worse — two tabs in the same useideem/authenticator checkout both fell back to #general instead of converging on #useideem. Re-default to auto-scope; opt out via AIRC_NO_AUTO_ROOM=1 or --room general. Comment captures the trade-off.

  2. Explicit --room discards a stale saved pairing for a different room. Pre-fix: airc join --room foo after pairing into #bar silently resumed #bar. Post-fix: when --room is explicit and saved room_name differs, wipe CONFIG/room_name/room_gist_id and fall through to discovery. Identity (ssh_key, peer records) survives.

  3. Stale-auth resume in room mode self-heals instead of dying. Pre-fix: stale SSH keys (host reinstalled, authorized_keys rotated) died with Resume aborted — re-pair required and demanded teardown --flush + paste invite. Post-fix: with a saved room_name and gh available, wipe stale pair + re-exec with --room <saved> so discovery either finds a live host or we become the new host. The 1:1 invite path (no saved room) keeps die-loud behavior — there's nothing to fall through to.

All three changes live in the platform-agnostic decision layer — no new platform-specific code, so WSL / Git-Bash-on-Windows / POSIX share identical logic with zero divergence.

Test plan

  • bash test/integration.sh auto_scope — 4/4 pass (banner fires, room takes effect, AIRC_NO_AUTO_ROOM=1 opt-out works, falls back to #general)
  • bash test/integration.sh room_overrides_resume — 4/4 pass (discard banner, host new-room, no resume of deadhost, ssh_key preserved)
  • bash test/integration.sh stale_auth_room_selfheal — 6/6 pass (self-heal banner fires, doesn't die, lands in saved room, ssh_key survives re-exec)
  • bash test/integration.sh resume_stale_auth — existing scenario for the 1:1-invite die-path still passes (covers the no-saved-room branch we kept unchanged)
  • WSL dogfood: bare airc join from a cloned repo lands in the org room, not #general
  • Windows native PowerShell + Git Bash dogfood: same as WSL

🤖 Generated with Claude Code

1. **Auto-scope re-enabled as default.** PR #104 gated the git-org-derived
   default room behind AIRC_AUTO_SCOPE_ROOM=1, citing that two tabs in
   different cwds would silently land in different rooms. The converse
   bug was worse: two tabs in the SAME project (useideem/authenticator)
   both fell back to #general and never converged on #useideem — directly
   contradicting the /join skill contract. Re-default to auto-scope; opt
   out via AIRC_NO_AUTO_ROOM=1 or `--room general`. Comment captures the
   trade-off so the next person reverting this knows the history.

2. **Explicit `--room` no longer silently resumes a stale pairing for a
   different room.** Pre-fix: `airc join --room foo` after pairing into
   #bar resumed #bar's host blindly; the flag was ignored. User had to
   manually `airc teardown --flush` first. Post-fix: when --room is
   explicit AND saved room_name differs, discard CONFIG/room_name/
   room_gist_id and fall through to discovery for the requested room.
   Identity (ssh_key, peer records) survives.

3. **Stale-auth resume in room mode self-heals instead of dying.**
   Pre-fix: stale SSH keys (host reinstalled, authorized_keys rotated)
   on a saved room-mode pairing died with "Resume aborted — re-pair
   required" and demanded `airc teardown --flush` + paste an invite.
   Post-fix: when there's a saved room_name and gh is available, wipe
   the stale pair and re-exec with --room <saved> so discovery either
   finds a live host or we become the new host. The 1:1 invite path
   (no saved room) keeps its die-loud behavior — there's nothing to
   fall through to.

Hit all three back-to-back in one session on 2026-04-26 (vhsm-2c84
dead host, then auto-scope siloing into #general instead of #useideem,
then explicit --room useideem ignored after a part). The bugs compound:
each fix surfaces the next.

Tests: three new scenarios (auto_scope, room_overrides_resume,
stale_auth_room_selfheal) covering the default-on auto-scope + opt-out,
the --room override + identity preservation, and the room-mode self-heal
path. 14 new assertions, all green. Existing scenario_resume_stale_auth
keeps testing the legacy 1:1-invite die-path (still correct for that case).

All changes are in the platform-agnostic decision layer — no new
platform-specific code, so WSL/Git-Bash-on-Windows/POSIX share the
same logic with no divergence.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 26, 2026 16:44
@joelteply
joelteply merged commit bc52b67 into canary Apr 26, 2026
3 checks passed
@joelteply
joelteply deleted the fix/join-resume-three-bugs branch April 26, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes several issues in airc join/airc connect resume + room discovery flow so that room selection is consistent, explicit --room overrides stale saved state, and room-mode resume can self-heal from stale SSH auth instead of forcing a manual flush.

Changes:

  • Re-enable default room auto-scoping (with AIRC_NO_AUTO_ROOM=1 / --room general opt-out) and update the banner text.
  • When --room is explicit and differs from saved room_name, discard stale saved pairing state and fall through to discovery/host for the requested room.
  • Add integration scenarios covering auto-scope default, --room overriding resume, and stale-auth room self-heal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
airc Updates join defaults (auto-scope) and improves resume behavior for room overrides and stale-auth recovery.
test/integration.sh Adds new integration scenarios to validate auto-scope, room override behavior, and stale-auth room self-heal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread airc
room_name="${_inferred%|*}"
local _source="${_inferred#*|}"
echo " Auto-scoped: #${room_name} (AIRC_AUTO_SCOPE_ROOM=1, from git ${_source})"
echo " Auto-scoped: #${room_name} (from git ${_source}; override with --room or AIRC_NO_AUTO_ROOM=1)"
Comment thread airc
# discovery succeeds, just like the non-auth self-heal does.
rm -f "$CONFIG" "$AIRC_WRITE_DIR/room_name" "$AIRC_WRITE_DIR/room_gist_id"
echo ""
exec env ${_preserved_name_a:+AIRC_NAME="$_preserved_name_a"} "$0" connect --room "$_saved_auth_room"
Comment thread test/integration.sh
Comment on lines +1734 to +1740
grep -qE 'Hosting as|Auto-scoped' /tmp/airc-it-auto-h.log 2>/dev/null && break
done

grep -qE 'Auto-scoped: #useideem \(from git org' /tmp/airc-it-auto-h.log \
&& pass "auto-scope banner: 'Auto-scoped: #useideem (from git org)'" \
|| fail "auto-scope banner MISSING (got: $(head -3 /tmp/airc-it-auto-h.log | tr '\n' '|'))"

Comment thread test/integration.sh
Comment on lines +1917 to +1921
# --room ${rname}. AIRC_NO_DISCOVERY is NOT inherited across the
# re-exec, but with no real gh probe configured here the discovery
# path will silently no-op and fall through to host mode — beta
# becomes the new host of #${rname}. We just need to verify it
# DIDN'T die and DID land in the room.
Comment thread test/integration.sh
# this gh-free).
AIRC_HOME="$home" AIRC_NAME=alpha AIRC_PORT=7563 AIRC_NO_DISCOVERY=1 \
"$AIRC" connect --room new-room --no-gist > /tmp/airc-it-ror.log 2>&1 &
local pid=$!
joelteply added a commit that referenced this pull request Apr 26, 2026
When a joiner's saved room_gist_id refers to a gist that's been
deleted (host teardown'd), the resume path's gist-probe runs
'gh api gists/<id>' under 'set -euo pipefail' with no '||' guard.
A 404 — which is the EXPECTED signal that the host wiped the gist
and we should self-heal — trips set -e instead. The script exits 1
silently, BEFORE the 404 classification + self-heal logic below it
can run. The very signal the code uses to detect "gist gone" was
also the trigger that killed the script before processing it.

Symptom: 'airc canary && airc teardown && airc join' from the
joiner side, after the host re-hosted, prints 'Resuming as joiner
of...' and then exits 1 with no stderr in the user's event stream.
Hit 2026-04-26 by vhsm-Claude during PR #116/#117 verification —
wasted ~10 minutes thinking it was a Bug-3 self-heal regression
before tracing to set-e on the gh api call.

Fix: pre-declare '_gist_probe_rc=0' and use '|| _gist_probe_rc=\$?'
on the 'gh api' line. set -e no longer trips on 404; the existing
classification correctly self-heals into discovery for the saved
room_name.

Test: scenario_resume_404_gist_no_silent_exit synthesizes joiner
state with a known-bogus gist_id and saved room_name, asserts
neither silent-exit nor missing self-heal banner. Skipped when gh
isn't authed or lacks gist scope (the gh-health gate would short-
circuit before the bug fires).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants