Skip to content

canary→main: fresh-Mac install fixed + cryptography migration + CI honesty + UX cleanups (#341) - #349

Merged
joelteply merged 8 commits into
mainfrom
canary
Apr 30, 2026
Merged

joelteply merged 8 commits into
mainfrom
canary

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Triggered by Carl's fresh-Mac QA pass on #341 — airc join was silently exit-1 on a clean Mac because LibreSSL doesn't implement Ed25519 and the openssl call had 2>/dev/null. Pulling that thread surfaced 8 real bugs across the install path, the CI rig, and the post-3c cleanup tail.

Bundled fixes (8 PRs, oldest → newest)

Themes

  1. Never swallow errors. fix(openssl): detect LibreSSL, auto-install brew openssl@3, loud die instead of silent exit (#341) #342, feat(identity): migrate Ed25519 to venv cryptography (closes #341) #343, fix(gh): distinguish secondary rate limit from auth failure + skill scope-doc correction (#341) #344 — three of the eight PRs were unblocked by removing a 2>/dev/null or distinguishing a "shouldn't happen" error from a routine one. Joel's hard rule, justified again here.
  2. Native-truth, thin-SDK-per-language. feat(identity): migrate Ed25519 to venv cryptography (closes #341) #343 moved Ed25519 from shell openssl to Python cryptography. Identity is a security primitive; truth lives in the venv module the rest of the codebase already trusts, not in whatever libcrypto flavor /usr/bin/openssl happens to be.
  3. CI must test the PR, not main. fix: connect find-first _now/_machine_id + test pidfile parsing #338 surfaced that install.sh's "I'm on a non-channel branch, let me pull main" recovery path silently overwrote the staged tree on every CI run. Every PR for the past N weeks was effectively a no-op against the CI matrix. AIRC_INSTALL_NO_PULL=1 escape hatch fixes it.
  4. Drop Phase 3c residue. fix(doctor): drop sshd probe — post-3c the gist IS the wire (#341) #345, cleanup(install): drop dead sshd-on-by-default comment block #346 — sshd is gone from the wire path; doctor + install no longer pretend it isn't.

End-to-end proof

This bundle was coordinated peer-to-peer over airc on canary itself — both Macs paired via the gist substrate in #general, ran airc msg --channel general to exchange status, merged each other's PRs, all on the code being shipped here. The substrate fixed itself enough during the session to be the comm channel for shipping the fix.

Test plan

  • Carl: full fresh-Mac validation (LibreSSL only, no brew openssl) → airc join succeeds, doctor reads [ok] cryptography and all-green
  • Both Macs paired in #general via airc itself (this PR coordinated over the wire)
  • CI clean-install matrix passing on each merged PR
  • CI clean-install matrix passing on this bundle
  • Post-merge: curl ... | bash from a fresh shell on the test rig produces a working install end-to-end

Known followups (post-bundle)

🤖 Generated with Claude Code

joelteply and others added 8 commits April 29, 2026 18:37
* fix: populate _now/_machine_id on find-first; multi-line airc.pid in test

cmd_connect.sh: when adopting an existing canonical gist via find-first
convergence, we skip the create-new block — but downstream heartbeat
setup uses _now and _machine_id, which were only initialized inside
that skipped block. Fresh joiners crashed with "_now: unbound variable"
right at the moment they should have been completing pairing. Populate
both in the adopt branch too.

integration_smoke.sh: post-#328 airc.pid has multiple entries (parent
on line 1, appended subshells below). The orphan_loops_self_reap test
was extracting parent_pid with `awk '{print $1}'`, which returns every
line and broke the test's PID logic. Restrict to NR==1 + exit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(connect): gate gh-auth pre-flight on use_room=1

The gh-auth pre-flight from #331 was unconditional at the top of
cmd_connect, so any caller running --no-room (legacy 1:1 invite
mode, no substrate, no gh dependency) on a machine without gh auth
got killed before the host loop could start. CI's clean-install
smoke matrix runs exactly that path on fresh runners, so it broke
clean-install-{linux,macos} on this branch.

Move the pre-flight below flag parsing and gate on use_room=1.
Substrate users (the common path) still get the early, actionable
error. Legacy/offline users (--no-room) skip it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(install,ci): AIRC_INSTALL_NO_PULL escape hatch for staged trees

CI's clean-install matrix stages the PR's tree at $HOME/.airc-src via
'cp -r .' then runs install.sh. install.sh sees the .git checkout,
notices the branch isn't 'main' or 'canary', and "recovers" by
fetching + checking out main. Result: every PR's CI was running
origin/main's code, not the PR's. Mine of #338's pre-flight gating
fix never executed in CI — the symptom that surfaced this.

Add AIRC_INSTALL_NO_PULL=1 — when set, install.sh trusts CLONE_DIR's
checked-out tree exactly as-is and skips the branch-switch + pull.
Wire it into the three CI install invocations so the smoke matrix
actually exercises the PR's code.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(monitor): only track flush_pending_loop PID when it'll persist

flush_pending_loop returns immediately when host_target is empty
(legacy host mode, no peer paired, nothing to flush). monitor() was
spawning it unconditionally and recording its PID in airc.pid — but
the subshell exited within the same tick, so kill -0 on that PID
failed seconds later. clean-install-{macos,linux} smoke caught this:
'PID <X> in airc.pid is not alive' moments after connect started.

Gate the spawn on host_target presence. When empty, don't spawn,
don't track. Next monitor invocation will pick it up if pairing has
happened in the meantime.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(teardown): swallow pgrep-empty-match in scope-path orphan sweep

The orphan-sweep step ran:
  _scope_path_pids=$(pgrep -f "$AIRC_WRITE_DIR" 2>/dev/null | sort -un)

pgrep returns 1 when nothing matches. With pipefail + set -e (airc
top-level uses set -euo pipefail), the pipe surfaces that 1, the
assignment fails non-zero, set -e dies the whole airc binary — but
HALFWAY through cmd_teardown, after the kill but before "Teardown
complete". The CI smoke runner saw 'killing scope ...' then nothing,
then the test step exited 1 from set -e propagating up via airc's
own exit code.

Why dev machines didn't catch this: prior test runs leave AIRC_HOME-
tagged zombies on disk, so pgrep always finds something and returns
0. Fresh runners (and Carl's laptop) have nothing — pgrep returns 1
on the first invocation. `|| true` swallows the empty-match case;
the if-block below handles the empty-result case cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…instead of silent exit (#341) (#342)

fix(openssl): detect LibreSSL, prefer brew openssl@3, loud die instead of silent exit (#341)

Carl on a fresh Mac ran 'airc join' after the documented curl install and
got 'No mesh found on your gh account → becoming the host.' followed by
exit 1, no error, no diagnostic. The whole stack was working — gh authed,
gist about to be created — except 'openssl genpkey -algorithm Ed25519'
silently failed because /usr/bin/openssl on macOS is LibreSSL 3.3.6, and
LibreSSL doesn't implement Ed25519. The 2>/dev/null on the openssl call
swallowed the actual error; set -e killed the script with no trap.

Two-part fix:

airc binary: resolve openssl with Ed25519 capability at startup
(_resolve_openssl), prefer brew openssl@3 / openssl over PATH default
on Mac (so /usr/bin/openssl LibreSSL is bypassed when a working brew
binary is present), expose as AIRC_OPENSSL. init_identity + sign_message
gate on AIRC_OPENSSL non-empty; if empty, _die_no_ed25519_openssl prints
a clear actionable error pointing the user at 'brew install openssl@3'
or AIRC_OPENSSL=/path env override, plus the issue link. AIRC_OPENSSL
env var is also the user override for non-standard layouts.

install.sh: 'openssl --version' is not enough — LibreSSL passes that
probe. Add a real 'openssl genpkey -algorithm Ed25519' probe after the
existing prereq install loop. On Mac, if the probe fails AND brew is
available AND brew openssl@3 isn't already keg-installed, auto-install
it. Brew openssl@3 is keg-only (doesn't shadow /usr/bin/openssl) but
airc's runtime resolver locates it at /opt/homebrew/opt/openssl@3/bin/.
On Linux/Windows the probe failing is rare; emit a warning with manual
fix guidance.

Tested both paths on this Mac:
  * with only LibreSSL → loud actionable error, exit 1
  * after 'brew install openssl@3' → 'airc join' succeeds, hosts #general

Doesn't change the bigger question (raised by Joel: do we need shell
openssl at all when the venv already has python-cryptography?). That's
a follow-up — this PR just stops Carl from hitting a silent failure
on every fresh Mac install.

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
)

Identity gen (genpkey) and message signing (pkeyutl -sign) used to
shell out to system openssl. macOS LibreSSL doesn't implement Ed25519
via genpkey, which silently broke fresh-Mac installs (the 2>/dev/null
ate the error — exactly the error-suppression antipattern that "Never
swallow errors" exists to forbid). #342 made the failure loud and
auto-installed brew openssl@3; this PR removes the dependency on
system openssl entirely by routing both ops through the venv
python-cryptography module that's already installed for envelope
encryption.

What changed:
- lib/airc_core/crypto.py: add generate_ed25519_keypair_pem,
  load_ed25519_priv_pem, sign_ed25519_pem, save_ed25519_keypair_pem.
  PEM format (PKCS#8 priv, SPKI pub) matches openssl byte-for-byte —
  existing scopes that paired under shell-openssl load + verify
  cleanly here. Cross-checked: signing a Python-gen key via openssl
  pkeyutl -sign and signing the same message via the new path
  produces byte-identical base64 output.
- lib/airc_core/identity.py: bootstrap_ed25519 + sign_ed25519
  siblings to the existing X25519 functions, plus bootstrap-ed25519
  and sign-ed25519 CLI subcommands so bash invokes via
  $AIRC_PYTHON -m airc_core.identity ...
- airc top-level: sign_message and init_identity now route through
  the python CLI. Removed _resolve_openssl, AIRC_OPENSSL,
  _die_no_ed25519_openssl — all dead code post-migration. ssh-keygen
  remains (it's an OpenSSH client tool, not a libcrypto consumer,
  and ships working on every supported platform).
- install.sh: drop openssl from the prereq list; drop the
  LibreSSL-detect + brew-install-openssl@3 dance (no longer needed
  since shell openssl isn't called). cryptography stays a hard dep
  via the existing venv pip-install step.
- cmd_doctor.sh: replace the openssl probe with a cryptography
  import probe ("import cryptography.hazmat.primitives.asymmetric
  .ed25519"). Surfaces "re-run install.sh" if the venv didn't
  finish setting up.

Backward compat: existing scopes' private.pem / public.pem files
(generated by shell openssl in any prior version) continue to work
unchanged. The PEM wrapping format is the same; load_pem_private_key
parses both. No identity rotation triggered by upgrade.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
* docs(install): drop redundant gh auth login + walk to /join

README told users to run 'gh auth login' as a separate step, but install.sh
already detects unauthed gh and runs 'gh auth login -s gist' interactively
when there's a TTY. Drop the README line and lean on install.sh, then walk
the user through opening their agent and running /join.

install.sh: skip the interactive gh auth path when running as root/sudo
(the token would attach to root's keyring, but airc runs as the real user
and would read an empty token); print an explicit warning instead. Also
update the post-install Next block to point at 'claude' (or any other
supported agent) and the /join skill, with the raw 'airc join' as the
fallback for shell-only users.

Joel hit this on a fresh canary install where he was already gh-authed
from past work — the README's redundant 'gh auth login' was just noise,
and the post-install block didn't tell him to open his agent.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ux(install): green '==>' headline + Enter pause before gh auth login

Without a break between install.sh's progress output and gh's device-
code flow, the browser popup looks mid-install — user has no signal
they're being handed off to a different tool. Match Claude Code's
installer convention: bold green '==>' headline, bold action line,
explicit Press Enter / Ctrl+C prompt. Honor AIRC_INSTALL_YES=1 for
power users who curl|bash repeatedly.

Already gated on TTY (the existing elif), so CI / non-interactive
installs are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
feat(uninstall): airc uninstall verb + /uninstall skill, fleshed-out script

Replaces the four-line uninstall.sh stub (only removed the airc symlink
and skill symlinks) with a full uninstall flow + a first-class verb on
the binary + an agent-invocable skill. Single source of truth: airc
uninstall execs uninstall.sh, /uninstall wraps the same path.

uninstall.sh now:
  1. airc teardown --all to stop running processes (idempotent if none)
  2. airc daemon uninstall to remove launchd / systemd-user / Task
     Scheduler unit (no-op if not installed)
  3. removes binary forwarders ~/.local/bin/{airc, relay, airc.cmd,
     airc.ps1} — symlinks unconditionally, real .cmd/.ps1 only when
     their contents reference the clone (don't blow away an unrelated
     binary at the same name)
  4. drops every skill symlink under ~/.claude/skills/ that resolves
     into the clone — covers current names + any stale ones
  5. rm -rf the clone dir (incl. .venv)

Per-project .airc/ state (identity keys, peer records, chat logs) is
left alone by default — that's user data. --purge prints a 'remove
manually if you want' list scoped to common project roots
($HOME/{Development,Projects,work,src}, max-depth 6) instead of
walking the whole filesystem.

Confirmation prompt asks the user to type 'yes'. Non-interactive runs
(curl|bash without a TTY) require --yes; refusing rather than silently
proceeding. -y and --yes both work.

The verb (airc uninstall|self-uninstall) resolves the clone via
_airc_lib_dir (lib path → strip /lib → clone root), execs the script
in-place. uninstall is a real word — added to the dispatch case + the
help block.

The /uninstall skill (skills/uninstall/SKILL.md) is built for agents:
emphasizes the destructive nature, tells the AI not to pass --yes
without explicit user confirmation, lists the leave-alone surface so
the agent can answer 'will this nuke X?' questions correctly.

install.sh: removed 'uninstall' from the stale-symlink cleanup loop
(it was there from when the skill didn't exist; now the per-skill
symlink loop recreates it).

README: added airc uninstall to the command list and the skill table.

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…cope-doc correction (#341) (#344)

* fix(gh): distinguish secondary rate limit from real auth failure (#341)

`gh auth status` calls /user, which returns 403 during a GitHub secondary
rate limit (abuse detection). gh interprets that 403 as 'token invalid'
and prints exactly that. airc surfaced it verbatim — Carl saw 'GitHub
token is invalid' during a rate-limit cooldown, ran 'gh auth login'
fruitlessly, and got nowhere because the token was actually fine.

The /rate_limit endpoint is reachable during secondary rate limits. If
it works, the token works. Use it as the discriminator.

Three sites use 'gh auth status' as a preflight or status check; all
three got the same fix shape:

- cmd_connect.sh (airc join preflight): instead of dying with 'token
  invalid' and pointing at gh auth login, dies with 'rate-limited;
  wait 5-15 min' when /rate_limit is reachable. Includes a brief
  explanation of why gh misreports.

- cmd_doctor.sh: '[BLOCKED] gh authenticated' becomes
  '[BLOCKED] gh secondary rate limit (abuse detection) — token is
  fine' under the same condition, with 'wait then re-run' guidance
  instead of 'gh auth login -s gist'. Same fix applied to the
  downstream gist-API-reachable check.

- cmd_status.sh: 'gh auth: ✗ INVALID' becomes 'gh auth: RATE-LIMITED'
  under the same condition, so a user inspecting status mid-cooldown
  gets accurate information.

Hit on this Mac mid-Carl-QA pass: a 15-second issue-comment polling
Monitor combined with rapid PR/issue/comment activity tripped GitHub's
secondary rate limit. 'gh auth status' said 'token invalid'. 'airc
join' surfaced the same. Both wrong.

Doesn't touch cmd_send.sh's auth_failure path — that runs off a bearer
report, not a direct gh probe, and needs a separate look at the Python
bearer's auth_failure logic. Filed as a follow-up under #341.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(join skill): correct scope state location ($PWD/.airc/ not ~/.airc/)

The /join skill claimed non-git-repo cwds put state in ~/.airc/. Code
actually writes to $PWD/.airc/ (detect_scope in airc:162). README is
correct on three different lines (256, 375, 501) — only the skill
disagrees. Carl reading the skill expects ~/.airc/, sees state appear
in /Users/joel/Development/.airc/ when running from a non-project dir,
gets confused.

Per-cwd-by-default is intentional — multi-tab on one machine: each tab
in its own dir = distinct identity, never colliding. The fix updates
the skill text to match actual behavior + mentions AIRC_HOME as the
override knob.

Identified during the Carl QA pass tracked at #341.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
)

airc doctor still reported [MISSING] sshd "needed when you HOST a room"
on every Mac/Linux/Windows box where Remote Login wasn't enabled. The
fix in install.sh comment 287 already notes "Post-3c: sshd setup +
Tailscale install fully removed" — the doctor probe was the last
vestige claiming sshd is required, and it confused Carl on this rig
(reported as the third sub-bullet during the QA pass on #341).

Post-3c, every peer reads + writes the room gist via gh API. There is
no ssh path remaining. ssh-keygen stays (identity key generation),
ssh client probe stays (occasional manual diagnostic + future
wire-pluggable bearers like LoRa/Reticulum may want it), but sshd
itself is irrelevant.

Removes:
- _doctor_probe_sshd() function (~100 lines of macOS launchctl /
  systemd / Windows OpenSSH.Server probe code)
- Both call sites: default `airc doctor` (line 56) and
  `airc doctor --connect` preflight (line 366)

Replaces each call site with a one-line comment explaining the
removal, so future readers don't add it back.

Verified on this Mac: pre-fix doctor reported [MISSING] sshd; post-fix
"All required prereqs present." Identical change applies to the
--connect preflight.

Doesn't touch the dead sshd-comment chunk in install.sh:268-287
(historical context, no actual logic) — fold into the next install.sh
touch.

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Carl flagged this in #345: the install.sh sshd-install block was
removed as part of Phase 3c (gist-substrate replaces ssh-on-the-wire),
but the surrounding comments + AIRC_SKIP_SSHD doc + CI auto-detect
narrative were left behind. Confused enough on read that #345 had to
explicitly call out 'this is unused, just comments now'.

Replace with a single tombstone comment so anyone grepping git history
for 'sshd' finds the rationale, but nothing else.

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.

1 participant