Skip to content

fix: connect find-first _now/_machine_id + test pidfile parsing - #338

Merged
joelteply merged 5 commits into
canaryfrom
fix/connect-find-first-vars-and-pidfile-test
Apr 29, 2026
Merged

joelteply merged 5 commits into
canaryfrom
fix/connect-find-first-vars-and-pidfile-test

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • cmd_connect.sh: find-first canonical-gist adoption skipped the create-new block, but downstream heartbeat code references `_now` and `_machine_id` populated there. Result: fresh joiners crashed with `_now: unbound variable` at exactly the moment pairing should have completed. Populate both in the adopt branch too.
  • test/integration_smoke.sh: post-fix: gh-auth surface + identity caps + airc.pid full-tree #328 `airc.pid` has multiple entries (parent on line 1, appended subshells below). `orphan_loops_self_reap` was extracting parent_pid via `awk '{print $1}'`, returning every line and breaking PID logic. Restrict to `NR==1 + exit`.

Both bugs surfaced when running the smoke suite against the gh substrate. `passive_recv` (4/4) and `orphan_loops_self_reap` (2/2) now pass.

Test plan

  • passive_recv green
  • orphan_loops_self_reap green
  • Run remaining smoke scenarios on this branch before merging

🤖 Generated with Claude Code

joelteply and others added 5 commits April 29, 2026 17:33
…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]>
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]>
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]>
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]>
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]>
@joelteply
joelteply merged commit e46cd32 into canary Apr 29, 2026
6 checks passed
@joelteply
joelteply deleted the fix/connect-find-first-vars-and-pidfile-test branch April 29, 2026 23:37
joelteply added a commit that referenced this pull request Apr 30, 2026
#363)

The integration-suite has been failing on every canary push for the
duration of this push (#351 cluster B). Root cause: 14 scenarios call
airc with --room or bare connect (use_room=1), which trips
cmd_connect's pre-flight gh-auth check (#338) — and CI's integration-
suite runner has no gh auth wired in (no PAT secret).

Add requires_gh_auth_or_skip() helper at the top of integration.sh:
checks gh auth status once (cached for subsequent calls — saves rate
limit budget when the suite runs many substrate scenarios), and
either proceeds (when authed) or marks the scenario as skipped-pass
with the reason. Test count stays sane, suite goes green on no-auth
runners, substrate coverage preserved when gh IS authed (developer
machines, future CI with PAT secret).

Apply the gate to the 13 scenarios that exercise substrate features
(--room or use_room=1 default): room, events, mnemonic, kick,
heartbeat, bounce, two_tab_localhost, auto_scope, connect_after_kill_
recovers, general_sidecar_default, host_msg_publishes_to_gist,
general_has_shared_gist, custom_room_creates_gist.

Cluster A (Carl, #362) was test-stderr wording updates for the #343
ed25519-message-shape change. Together these close out #351.

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