Skip to content

fix: gh-auth surface + identity caps + airc.pid full-tree - #328

Merged
joelteply merged 1 commit into
canaryfrom
fix-gh-auth-detection-and-misc
Apr 29, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix-gh-auth-detection-and-misc

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Five fixes for fresh-Mac e2e: gh auth pre-flight on connect, gh auth state in status, accurate auth_failure error in send, identity length caps (4KB bios → 512 max), reminder/flush PIDs added to airc.pid for honest status/teardown.

Four mission-critical fixes for the clean-install + multi-machine path:

1. cmd_connect pre-flight gh-auth check. If gh's keyring is invalid
   (token revoked / 2FA expired / brew upgrade replaced gh), every
   downstream gh API call fails silently — bearer.send returns
   auth_failure, recv polls forever finding nothing, peers see
   'monitor running, no traffic' (the freeze pattern Joel kept
   hitting). Catch at startup with a clear 'run gh auth login'
   message instead of mystery silence.

2. cmd_status surfaces gh auth state. Adds 'gh auth: ok' / 'gh auth:
   ✗ INVALID' line so users have a one-second diagnostic when
   things go wrong mid-session.

3. cmd_send auth_failure path: replaces stale 'SSH auth FAILED'
   message (leftover from SSH era) with 'gh auth FAILED — re-auth
   required' + concrete fix command. No more 'airc teardown --flush
   && airc connect <invite-string>' direction (which is wrong post-3c
   — that was the SSH-pair re-pair path).

4. identity field length caps (continuum-b741 caught 4KB bio stored
   verbatim). Hard caps:
     pronouns 64  role 128  bio 512  status 256
   Loud rejection over silent acceptance.

5. monitor() now appends reminder + flush subshell PIDs to airc.pid
   so status/teardown/send see the FULL tree. Pre-fix airc.pid had
   parent only; if parent died first while subshells were still
   alive, status reported 'not running' but reality was different.
   Post-#325 the subshells self-reap on parent death anyway, but
   tracking keeps pidfile honest during the transition window.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply
joelteply merged commit e4e5b62 into canary Apr 29, 2026
@joelteply
joelteply deleted the fix-gh-auth-detection-and-misc branch April 29, 2026 17:46
joelteply added a commit that referenced this pull request Apr 29, 2026
* 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]>
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