Repository navigation
HOTFIX: cmd_send silently queued auth failures — memento couldn't reach host after reinstall - #17
Merged
Merged
Conversation
…lently queue auth errors ## The bug #12 (send queue on wire failure) introduced a regression that bit cross-mesh coordination today. After memento reinstalled airc (regenerating identity keys), their SSH key was no longer in the host's authorized_keys. But the joiner's saved pairing state made `airc connect` work. Their subsequent `airc send` attempts: 1. SSH'd to host with new key → "Permission denied (publickey)" 2. cmd_send saw the lack of __APPENDED__ marker → queue-on-failure branch 3. Appended to pending.jsonl 4. Printed "Host unreachable — message queued for retry" 5. Exited 0 Memento thought their sends succeeded. Nothing reached the host's messages.jsonl. No one on the mesh saw the messages. They were invisibly destined to retry-fail forever because every retry uses the same bad key. ## Root cause cmd_send treated ALL wire failures the same — transient network error (queue + retry is correct) and authentication failure (re-pair required, retry will never help) went through the identical code path. And the SSH stderr containing "Permission denied" was stuffed into a JSON marker in messages.jsonl, never shown to the user's terminal. The only user-visible message was the misleading "Host unreachable" line. ## Fix Detect auth-class failures via stderr substring match: permission denied | publickey | host key verification | authentication fail | identification has changed | no supported authentication If matched: - Write [AUTH FAILED to X — repair required, NOT queued] marker - Print the actual SSH stderr to the user's terminal - Print the fix: "airc teardown --flush && airc connect <invite-string>" - die() with exit 1 If not matched (genuinely transient wire failure): - Queue to pending.jsonl as before - Print "Network error reaching host — message queued for retry" - ALSO print the SSH stderr so the user can see WHY it queued (the prior generic "Host unreachable" was hiding real info) ## Tests New scenario_auth_failure (6 assertions) simulates memento's exact setup: 1. Spawn host + joiner, baseline send works (proves pairing) 2. Regenerate joiner's identity keys in-place (simulates reinstall) 3. Joiner's config still has saved host_target (resume path) 4. Joiner calls `airc send` → expected: die loudly Asserts: - exit non-zero - stderr mentions auth/permission/publickey - stderr includes repair instructions - message NOT written to pending.jsonl - host's messages.jsonl unchanged Validated against pre-fix binary (git show main:airc) — test FAILS on 4 of 6 assertions pre-fix, proving it catches the exact regression. Passes on current branch. Full suite: 68/68 (was 62/62). ## Why this test didn't exist before The existing scenario_tabs test spawns host+joiner in one process with pair-handshake going cleanly — happy path. It never exercised a fresh joiner identity against a stale authorized_keys, which is the real failure mode. Adding it now; class of test was missing. Refs #12, airc-96dd host reachability issue surfaced during cross-mesh coordination with memento (/Volumes/FlashGordon scope).
joelteply
added a commit
that referenced
this pull request
Apr 15, 2026
…le auth ## The default-broken path `airc teardown` (no --flush) + `airc connect` (no args = resume) is the reflex sequence every user does. If the saved SSH key is stale (key rotation, reinstall, authorized_keys change), the old resume path: 1. printed "Resuming as joiner of 'X' (host)..." 2. jumped straight into monitor() 3. which ran `while true; do ssh ... tail -F ... || true; sleep 3; done` 4. SSH returned 255 on auth failure silently 5. `|| true` swallowed the exit 6. loop retried forever, stderr discarded Net: mesh was dead, user had no visible error, no clue how to recover. This is the literal "broken by default" that bit memento during cross- mesh coordination and cost us hours. ## Fix Probe SSH auth BEFORE entering the monitor loop in the resume path. `ssh -o ConnectTimeout=5 -o BatchMode=yes <host> "echo __AUTH_OK__"`. If probe succeeds → continue to monitor as before. If probe fails with an auth-class stderr (same detector as the cmd_send fix from #17: permission denied, publickey, host key verification, authentication fail, identification has changed, no supported authentication): - Surface the actual SSH stderr - Print the fix command: `airc teardown --flush && airc connect <invite>` - Reconstruct the saved invite string from config.json so the user doesn't have to hunt for it - die() with exit 1 If probe fails with a non-auth stderr (timeout, DNS, etc): - Warn but fall through to monitor() — transient outages are what the retry loop is actually designed for ## New scenario: scenario_resume_stale_auth Simulates the exact user flow: 1. Fresh pair + baseline send works (proves clean state) 2. `airc teardown` (no --flush, state preserved) 3. Regenerate the joiner's ssh_key in-place (any cause of stale key) 4. `airc connect` (resume) 5. Assert: exits <= 10s (not silently looping), exit non-zero, stderr mentions auth, stderr contains repair command, stderr has reconstructed invite string Validated against pre-fix (git show main:airc): 4 of 6 assertions FAIL, including "connect still running after 10s — silent retry loop (pre-fix bug)". On fix: 6/6 green, resume dies in 1 second with full diagnostic. Full suite: 74/74 (was 68/68). ## What this PR does NOT do (acknowledged gaps) - Does not auto-re-pair. User still has to type the command. Safer for now (auto-repair would paper over legitimate host-side changes the user should know about), but the code has everything needed to add it later. - Tests still pollute the caller's ~/.ssh/authorized_keys — every pair handshake appends a pubkey and nothing cleans it up. Separate concern; see follow-up work on sandboxed test harness (test-only sshd on alt port or Docker containers). Refs #17.
joelteply
added a commit
that referenced
this pull request
Apr 15, 2026
…le auth (#18) ## The default-broken path `airc teardown` (no --flush) + `airc connect` (no args = resume) is the reflex sequence every user does. If the saved SSH key is stale (key rotation, reinstall, authorized_keys change), the old resume path: 1. printed "Resuming as joiner of 'X' (host)..." 2. jumped straight into monitor() 3. which ran `while true; do ssh ... tail -F ... || true; sleep 3; done` 4. SSH returned 255 on auth failure silently 5. `|| true` swallowed the exit 6. loop retried forever, stderr discarded Net: mesh was dead, user had no visible error, no clue how to recover. This is the literal "broken by default" that bit memento during cross- mesh coordination and cost us hours. ## Fix Probe SSH auth BEFORE entering the monitor loop in the resume path. `ssh -o ConnectTimeout=5 -o BatchMode=yes <host> "echo __AUTH_OK__"`. If probe succeeds → continue to monitor as before. If probe fails with an auth-class stderr (same detector as the cmd_send fix from #17: permission denied, publickey, host key verification, authentication fail, identification has changed, no supported authentication): - Surface the actual SSH stderr - Print the fix command: `airc teardown --flush && airc connect <invite>` - Reconstruct the saved invite string from config.json so the user doesn't have to hunt for it - die() with exit 1 If probe fails with a non-auth stderr (timeout, DNS, etc): - Warn but fall through to monitor() — transient outages are what the retry loop is actually designed for ## New scenario: scenario_resume_stale_auth Simulates the exact user flow: 1. Fresh pair + baseline send works (proves clean state) 2. `airc teardown` (no --flush, state preserved) 3. Regenerate the joiner's ssh_key in-place (any cause of stale key) 4. `airc connect` (resume) 5. Assert: exits <= 10s (not silently looping), exit non-zero, stderr mentions auth, stderr contains repair command, stderr has reconstructed invite string Validated against pre-fix (git show main:airc): 4 of 6 assertions FAIL, including "connect still running after 10s — silent retry loop (pre-fix bug)". On fix: 6/6 green, resume dies in 1 second with full diagnostic. Full suite: 74/74 (was 68/68). ## What this PR does NOT do (acknowledged gaps) - Does not auto-re-pair. User still has to type the command. Safer for now (auto-repair would paper over legitimate host-side changes the user should know about), but the code has everything needed to add it later. - Tests still pollute the caller's ~/.ssh/authorized_keys — every pair handshake appends a pubkey and nothing cleans it up. Separate concern; see follow-up work on sandboxed test harness (test-only sshd on alt port or Docker containers). Refs #17.
joelteply
added a commit
that referenced
this pull request
Apr 16, 2026
… docs Today's production story crammed years of user pain into one day: two hosts fighting over port 7547, memento paired with the wrong host for hours, sends that "succeeded" into a different mesh, resume silently retrying forever on stale auth. The code fixes landed in #17/#18; this PR fixes the DOCUMENTATION + SKILLS so future users/agents don't rediscover the same footguns. ## New skill: /repair One-command nuclear re-pair. Reconstructs the saved invite string from config, then runs `airc teardown --flush && airc connect <invite>`. Replaces the error-prone "teardown (forgot --flush) + resume (silent auth fail)" dance that bit memento today. Takes optional invite argument to repair onto a new host (useful when you discover you were on the wrong mesh). ## Updated skills - /connect: paste invite VERBATIM including `:port` — trimming silently pairs with whoever's on default 7547. Troubleshooting section now covers the resume-auth-probe failure mode + the wrong-host-on-shared- machine case. - /teardown: explicit --flush vs plain-teardown decision rule. "Rule of thumb: if anything about your pairing feels uncertain, use --flush." - /resume: documents the new auth probe. Failure mode now says follow the repair command verbatim from the stderr output. - /invite: warns to include the port in the pasted string when non-default. Tells the user to call out `:7548` explicitly so the recipient doesn't trim it. - /send: replaced the misleading "try teardown and re-pair" guidance. Now lists the three exit-class behaviors (auth fail / network queue / pending cap) with the correct repair for each. ## Updated integrations All six integration READMEs (claude-code, cursor, generic, openai-codex, opencode, windsurf) now document: - Auth vs network error distinction on send failure - `/repair` or equivalent nuclear re-pair sequence - Port-collision symptom ("peers look right but nobody responds — check host name in `airc peers`") - New lifecycle markers ([joined], [left], [QUEUED], [DRAINED], [AUTH FAILED]) in the generic JSONL protocol doc ## Why this matters The error-class evidence and the re-pair sequence existed in the code after today's hotfixes, but the user-facing docs still said "try teardown and re-pair" with no --flush — which is EXACTLY the wrong advice. A user following the old docs would land right back in the broken-by-default state that cost us hours. Refs #17, #18, #19, and the airc-96dd / vhsm-2c84 port collision on [email protected] — 2026-04-15 eval.
joelteply
added a commit
that referenced
this pull request
Apr 16, 2026
… docs (#20) Today's production story crammed years of user pain into one day: two hosts fighting over port 7547, memento paired with the wrong host for hours, sends that "succeeded" into a different mesh, resume silently retrying forever on stale auth. The code fixes landed in #17/#18; this PR fixes the DOCUMENTATION + SKILLS so future users/agents don't rediscover the same footguns. ## New skill: /repair One-command nuclear re-pair. Reconstructs the saved invite string from config, then runs `airc teardown --flush && airc connect <invite>`. Replaces the error-prone "teardown (forgot --flush) + resume (silent auth fail)" dance that bit memento today. Takes optional invite argument to repair onto a new host (useful when you discover you were on the wrong mesh). ## Updated skills - /connect: paste invite VERBATIM including `:port` — trimming silently pairs with whoever's on default 7547. Troubleshooting section now covers the resume-auth-probe failure mode + the wrong-host-on-shared- machine case. - /teardown: explicit --flush vs plain-teardown decision rule. "Rule of thumb: if anything about your pairing feels uncertain, use --flush." - /resume: documents the new auth probe. Failure mode now says follow the repair command verbatim from the stderr output. - /invite: warns to include the port in the pasted string when non-default. Tells the user to call out `:7548` explicitly so the recipient doesn't trim it. - /send: replaced the misleading "try teardown and re-pair" guidance. Now lists the three exit-class behaviors (auth fail / network queue / pending cap) with the correct repair for each. ## Updated integrations All six integration READMEs (claude-code, cursor, generic, openai-codex, opencode, windsurf) now document: - Auth vs network error distinction on send failure - `/repair` or equivalent nuclear re-pair sequence - Port-collision symptom ("peers look right but nobody responds — check host name in `airc peers`") - New lifecycle markers ([joined], [left], [QUEUED], [DRAINED], [AUTH FAILED]) in the generic JSONL protocol doc ## Why this matters The error-class evidence and the re-pair sequence existed in the code after today's hotfixes, but the user-facing docs still said "try teardown and re-pair" with no --flush — which is EXACTLY the wrong advice. A user following the old docs would land right back in the broken-by-default state that cost us hours. Refs #17, #18, #19, and the airc-96dd / vhsm-2c84 port collision on [email protected] — 2026-04-15 eval.
joelteply
added a commit
that referenced
this pull request
Apr 21, 2026
* skills+integrations: repair flow, port-collision warning, error-class docs Today's production story crammed years of user pain into one day: two hosts fighting over port 7547, memento paired with the wrong host for hours, sends that "succeeded" into a different mesh, resume silently retrying forever on stale auth. The code fixes landed in #17/#18; this PR fixes the DOCUMENTATION + SKILLS so future users/agents don't rediscover the same footguns. ## New skill: /repair One-command nuclear re-pair. Reconstructs the saved invite string from config, then runs `airc teardown --flush && airc connect <invite>`. Replaces the error-prone "teardown (forgot --flush) + resume (silent auth fail)" dance that bit memento today. Takes optional invite argument to repair onto a new host (useful when you discover you were on the wrong mesh). ## Updated skills - /connect: paste invite VERBATIM including `:port` — trimming silently pairs with whoever's on default 7547. Troubleshooting section now covers the resume-auth-probe failure mode + the wrong-host-on-shared- machine case. - /teardown: explicit --flush vs plain-teardown decision rule. "Rule of thumb: if anything about your pairing feels uncertain, use --flush." - /resume: documents the new auth probe. Failure mode now says follow the repair command verbatim from the stderr output. - /invite: warns to include the port in the pasted string when non-default. Tells the user to call out `:7548` explicitly so the recipient doesn't trim it. - /send: replaced the misleading "try teardown and re-pair" guidance. Now lists the three exit-class behaviors (auth fail / network queue / pending cap) with the correct repair for each. ## Updated integrations All six integration READMEs (claude-code, cursor, generic, openai-codex, opencode, windsurf) now document: - Auth vs network error distinction on send failure - `/repair` or equivalent nuclear re-pair sequence - Port-collision symptom ("peers look right but nobody responds — check host name in `airc peers`") - New lifecycle markers ([joined], [left], [QUEUED], [DRAINED], [AUTH FAILED]) in the generic JSONL protocol doc ## Why this matters The error-class evidence and the re-pair sequence existed in the code after today's hotfixes, but the user-facing docs still said "try teardown and re-pair" with no --flush — which is EXACTLY the wrong advice. A user following the old docs would land right back in the broken-by-default state that cost us hours. Refs #17, #18, #19, and the airc-96dd / vhsm-2c84 port collision on [email protected] — 2026-04-15 eval. * feat(teardown): --all flag — nuke every airc process on this machine, ignore scope Joel 2026-04-21: airc kept "going down" between sessions. Root cause: two airc-connect bash processes from a previous session (Wed) survived every teardown for 2 days because they ran from `/tmp/airc-prefix connect` (the curl|bash bootstrap variant) and were tracked by a PID file in a scope dir that no longer existed when later teardowns ran. The default `airc teardown` is scope-aware by design (so it won't touch other tabs' sessions), but that means it can't recover from the case where state is so messy that we've lost track of where the pidfiles SHOULD be. `airc teardown --all` covers that case. It's additive (still does the scope-aware path too) and surgical: - pgrep `(airc|airc-prefix)\s+connect` for THIS user → kill - For each port in 7547-7559: lsof for python listeners → if the command line shows `socket.SOCK_STREAM`/`AF_INET` (i.e. it's an airc listener, not some unrelated python), kill it - pgrep `\.airc/messages\.jsonl` for stale ssh/tail subprocesses reading scope message logs → kill them too - Then falls through to scope-aware path so this scope's pidfile + flush also happen if `--flush` was passed alongside Doesn't touch processes outside the airc port range or anything that isn't clearly airc-shaped. The "for this user" filter (`pgrep -u`) keeps it safe on shared machines. Help text updated to mention `--all`.
joelteply
added a commit
that referenced
this pull request
Apr 25, 2026
docs: REFCONTRACT.md — trunk-leaf contract for bash + PS impls Single source of truth for the ~10 primitives that airc (bash) and airc.ps1 (PowerShell) must both implement with identical names, argument shapes, and return shapes. Implementation differences (background workers, JSON parse, exit hooks, machine-id sources) live in the language-specific leaves table at the bottom — not duplicated in two places. Goal: replace today's "inline blob in cmd_connect, mirror by hand to Invoke-Connect, drift on every fix" pattern with "edit the function, both leaves stay aligned." No code changes yet — this is the spec the upcoming refactor (tasks #17–22) builds against. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
The bug
#12 queued ALL wire failures identically. After memento reinstalled airc today (regenerating keys), their SSH key wasn't in the host's authorized_keys. Every send:
Permission denied (publickey)__APPENDED__marker → wire-failure branchMemento thought sends succeeded. Host never saw any of them. Retries would fail the same way forever (same bad key). Every ping I was waiting for was invisibly destined to bounce.
Fix
Detect auth-class failures via stderr substring match (
permission denied,publickey,host key verification,authentication fail,identification has changed,no supported authentication). If matched:[AUTH FAILED]marker (not[QUEUED])airc teardown --flush && airc connect <invite-string>diewith exit 1Non-auth wire failures (timeout, refused) still queue + retry. But now they also print the SSH stderr to the user so the error surface is honest.
New test:
scenario_auth_failureSimulates memento's exact setup:
airc sendAsserts: exit non-zero, stderr mentions auth, stderr has repair command, message NOT queued, host's log unchanged.
Validated against pre-fix binary — 4 of 6 assertions FAIL pre-fix, proving it catches the regression.
Why this wasn't caught before
scenario_tabsspawns host + joiner in the same process with clean pair-handshake. Happy path. It never exercised a fresh joiner identity against stale authorized_keys. That was the gap. The class of test was missing — this PR adds it.Suite
Ship?
Yes, urgent — coordination between me + memento via airc is broken until this merges. Self-merging unless you say hold.
🤖 Generated with Claude Code