Skip to content

fix(connect): tailscale-state pre-check on fresh-pair + gist-discovery paths (closes #78) - #84

Merged
joelteply merged 2 commits into
canaryfrom
fix/tailscale-state-check-fresh-pair
Apr 25, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/tailscale-state-check-fresh-pair

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Closes #78. The resume path already gates on advise_tailscale_if_down (bash) / Advise-TailscaleIfDown (ps1) before SSH-pair, but the cold-start airc join <invite> and gist-discovery paths land at the same SSH-pair point WITHOUT the gate. A logged-out Tailscale on those paths produces silent unreachable-host + self-heal cascade — Memento's case from 2026-04-25.

Symmetric one-block addition in both bash (airc) and PowerShell (airc.ps1) at the universal pair-attempt point, just before the "Connecting to" line. Reuses existing helpers — no new detection logic.

Why both languages

Per pure-shell-cross-platform discipline + Joel: don't neglect Windows. Bash and ps1 ship in lockstep on this PR. green @green-022a — please validate on your native PS port.

Test plan

  • test/integration.sh — 133/133 pass on canary HEAD with this change
  • bash syntax check
  • ps1: visual review (pwsh not on dev machine; relying on review + your test)
  • Live verify on a Tailscale-logged-out Mac (cd into tailnet repo, tailscale logout, airc join <CGNAT-host invite>, expect loud message)
  • Live verify on Windows native (green's lane)

Out of scope (filed as follow-ups)

🤖 Generated with Claude Code

…y paths (#78)

The resume path already calls advise_tailscale_if_down (bash) /
Advise-TailscaleIfDown (ps1) before SSH-pair, but that gate doesn't
cover the cold-start `airc join <invite>` from a fresh scope OR the
gist-discovery resolution that lands at the same SSH-pair point with a
tailnet host_target. Without this guard, a logged-out Tailscale
produced a silent unreachable-host + self-heal cascade — Memento's
case 2026-04-25, surfaced as airc issue #78.

Symmetric one-line addition to the universal-pair-attempt point in
both bash (cmd_connect, just before "Connecting to") and PowerShell
(cmd_connect, same spot). Reuses the existing
advise_tailscale_if_down / Advise-TailscaleIfDown helpers — no new
detection logic, just extends the call site to the path that bypassed
it.

Both languages stay in lockstep per pure-shell-cross-platform
discipline; bash and ps1 ship together.

133/133 integration tests pass (no regression on existing pair flows;
test for the down-state itself filed as a follow-up since it requires
mocking tailscale-status output cleanly).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 25, 2026 16:51

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

Adds a Tailscale “down/logged-out” pre-flight check to the fresh-pair and gist-discovery join paths so users get actionable guidance before hitting unreachable-host/self-heal behavior (issue #78).

Changes:

  • Add advise_tailscale_if_down gate just before the TCP pair handshake in airc (bash).
  • Add Advise-TailscaleIfDown gate at the equivalent point in airc.ps1 (PowerShell).

Reviewed changes

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

File Description
airc Adds Tailscale-down pre-check before attempting the join/pair handshake.
airc.ps1 Mirrors the same Tailscale-down pre-check in the PowerShell connect flow.

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

Comment thread airc
Comment on lines +1652 to +1662
# Tailscale-down pre-flight on fresh-pair / gist-discovery paths.
# Resume path (line ~1241) already calls advise_tailscale_if_down, but
# that gate doesn't cover (a) cold-start `airc join <invite>` from a
# fresh scope or (b) the gist-discovery resolution that lands here
# with a tailnet host_target. Without this check, a logged-out
# Tailscale produced a silent unreachable-host + self-heal cascade
# (issue #78, Memento's case 2026-04-25). Same call site shape as the
# resume path: detect-and-instruct, do not auto-tailscale-up.
if ! advise_tailscale_if_down "$peer_host_only"; then
die "Re-run airc join after starting Tailscale."
fi
Comment thread airc.ps1
Comment on lines +2027 to +2037
# Tailscale-down pre-flight on fresh-pair / gist-discovery paths.
# Resume path (line ~1877) already calls Advise-TailscaleIfDown, but
# that gate doesn't cover (a) cold-start `airc join <invite>` from a
# fresh scope or (b) the gist-discovery resolution that lands here
# with a tailnet host_target. Without this check, a logged-out
# Tailscale produces a silent unreachable-host + self-heal cascade
# (issue #78, Memento's case 2026-04-25). Same call shape as resume
# path: detect-and-instruct, do not auto-tailscale-up.
if (Advise-TailscaleIfDown -TargetHost $peerHostOnly) {
Die 'Re-run airc join after starting Tailscale.'
}
…84)

Copilot caught the bigger bug under #78: advise_tailscale_if_down /
Advise-TailscaleIfDown only matched CGNAT against strings starting
with `100.`, but `host_target` is stored in config.json as `user@host`
(e.g. `[email protected]`). The resume path was passing the full
`user@host` form directly into the helper, the case match never hit,
the function returned 0 (proceed), and the silent-tailscale-down bug
fired anyway. The check existed but was structurally broken for its
exact use case.

Fix the helper itself rather than every call site: strip `${var##*@}`
(bash) / `($var -split '@')[-1]` (PowerShell) at function entry,
before the CGNAT pattern match. All call sites become safe — resume
path included.

Same fix applied to is_peer_offline_in_tailnet / Test-PeerOfflineInTailnet
since they share the identical pattern (called via host_target from
cmd_send's send-fast-path).

133/133 tests pass on this branch with both fixes.

Credit: copilot-pull-request-reviewer caught the user@ prefix issue
on PR #84 review — important catch, the headline bug was a symptom
of this deeper structural issue.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply
joelteply merged commit e3c3664 into canary Apr 25, 2026
1 check passed
@joelteply
joelteply deleted the fix/tailscale-state-check-fresh-pair branch April 25, 2026 17:21
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