Skip to content

fix(cmd_connect): fall back to host channel when intent bootstrap fails - #536

Merged
joelteply merged 2 commits into
canaryfrom
fix/cmd-connect-intent-bootstrap-fallback
May 6, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/cmd-connect-intent-bootstrap-fallback

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

cmd_connect's JOIN MODE diverged-intent path (user wants channel A, host's mesh advertises channel B) called ensure_channel_subscribed_with_gist on the user's intent FIRST and die'd the entire join when that one call failed (cmd_connect.sh:1496). The host's channel was warning-only when it failed (line 1498). The asymmetry made one recoverable hiccup fatal.

Observed today on continuum-8e97 (Windows):

Found mesh on your gh account → joining (df40c8ae...)
Resolving gist df40c8ae... ...
✓ Resolved invite from gist.
✓ Multi-address pick: 192.168.1.223:7547 (from host.addresses)
⚠  Could not resolve gist for #general:
ERROR: Could not bootstrap #general; refusing to join with broken state

User's auto-scope intent was #general; host advertised #cambriantech. #general gist resolution hiccupped (gh API returned empty stdout with no stderr — likely transient sub-bucket throttling). The mesh was reachable. The host's channel was reachable. No reason to refuse the join.

Same shape as the two recently-fixed identity leaks (#511 / #521 / #534): a single recoverable failure mode hard-coded as fatal, surfacing as an inexplicable airc exit.

Fix

Try both channels; fall back to whichever bootstraps. Three success paths:

_intent resolved_room_name Outcome
✓ ✓ Joined mesh — both subscribed
✓ ✗ Joined intent only (warn about host channel)
✗ ✓ NEW: fallback to host channel as primary (warn user)
✗ ✗ die — no viable subscription

Test

Adds scenario_join_intent_failure_falls_back_to_host to test/integration.sh. Coverage is structural — full behavioral coverage of the diverged path requires a live gh account + room gist fixture, out of scope for offline integration tests. The scenario locks in:

  • cmd_connect.sh parses clean
  • Test hook AIRC_TEST_FAIL_ENSURE_CHANNEL is wired (lets future tests force the failure path deterministically)
  • Fallback message is present in source
  • The unconditional intent die (refusing to join with broken state) is gone

Local run on Windows WSL2 (canary base):

$ bash test/integration.sh join_intent_failure_falls_back_to_host
─ join_intent_failure_falls_back_to_host: diverged intent failure no longer dies the join ─
  ✓ cmd_connect.sh parses with no syntax error
  ✓ test hook AIRC_TEST_FAIL_ENSURE_CHANNEL is wired into cmd_connect.sh
  ✓ fallback path is present in cmd_connect.sh
  ✓ intent-only die was replaced (no unconditional fatal)
4 passed, 0 failed

Related

🤖 Generated with Claude Code

Pre-fix the JOIN MODE diverged-intent path (user wants channel A, host's
mesh advertises channel B) called `ensure_channel_subscribed_with_gist`
on the user's intent FIRST and `die`'d the entire join when that one
call failed (cmd_connect.sh:1496). The host's channel was warning-only
when it failed (line 1498), so the asymmetry made one recoverable
hiccup fatal while leaving the actual failure mode it should have
guarded against silent.

Observed in the wild today (continuum-8e97 on Windows):

  Found mesh on your gh account → joining (df40c8ae...)
  Resolving gist df40c8ae... ...
  ✓ Resolved invite from gist.
  ✓ Multi-address pick: 192.168.1.223:7547 (from host.addresses)
  ⚠  Could not resolve gist for #general:
  ERROR: Could not bootstrap #general; refusing to join with broken state

The user's auto-scope intent was #general; host advertised #cambriantech.
#general gist resolution hiccupped (gh API path returned empty without
stderr — likely transient sub-bucket throttling on a busy session).
The mesh was reachable. The host's channel was reachable. There was no
reason to refuse the join — but `die` exited 1 with no recovery.

Same shape as the two recently-fixed identity leaks (#511/#521/#534):
a single recoverable failure mode hard-coded as fatal, surfacing as
an inexplicable airc exit.

Fix: try both intent and host channels, fall back to whichever
bootstraps. Joined-mesh / joined-intent-only / joined-host-only-fallback
are the three success paths; only `die` when BOTH are gone (no viable
subscription either way).

Adds AIRC_TEST_FAIL_ENSURE_CHANNEL — a test-only env hook the structural
regression scenario uses to deterministically lock in the fix without
needing a real gh-rate-limit reproducer. Behavioral coverage is
limited by the integration suite's offline constraints (the diverged
path requires a real gist), so the scenario is structural: parses
clean, hook is wired, fallback message present, the unconditional
intent die is gone. Manual reproducer at /tmp/repro.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 6, 2026 17:28
@joelteply

Copy link
Copy Markdown
Contributor Author

Codex review pass: the fallback direction is right, but I found one load-bearing gap and pushed a hardening commit (e428364).

Issue: the PR originally tried the host channel fallback by calling ensure_channel_subscribed_with_gist "$resolved_room_name" before the already-resolved host gist id was persisted. Under the exact GH transient/rate-limit condition this fix targets, that could force another GitHub discovery call and still die even though _resolved_gist_id was already known.

Fix pushed: preseed channel_gists[resolved_room_name] = _resolved_gist_id before subscribing to the host channel, so fallback uses the gist we already resolved instead of rediscovering it.

Validation after my commit:

  • bash -n airc lib/airc_bash/cmd_connect.sh test/integration.sh
  • ./test/integration.sh join_intent_failure_falls_back_to_host → 5 passed
  • ./test/integration.sh join_rejects_unknown_flag → 4 passed

LGTM from Codex with that patch included. Watching CI next.

@joelteply
joelteply merged commit 4b79342 into canary May 6, 2026
6 checks passed
@joelteply
joelteply deleted the fix/cmd-connect-intent-bootstrap-fallback branch May 6, 2026 17:56
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.

1 participant