Repository navigation
fix(connect+skill): trust running monitor over gh-auth-probe noise (closes #367) - #369
Merged
Merged
Conversation
…loses #367) The user-visible bug: in environments where gh's auth probe is flaky (Codex sandbox especially — openai/codex#10695), airc join's preflight hard-died with "token invalid" even when the scope's airc monitor was already running and bearer was actively reading/writing gh gists. The skill then reacted to the (wrong) token-invalid message by trying gh auth login -w (which also fails in the same flaky env), and Carl saw a multi-step debug-loop wreckage on a scope that was actually fine. Joel's call: "if the skill constantly causes this, it seems broken to everyone. do the most correct and robust [fix]." Two-layer fix. LAYER 1 — cmd_connect.sh: trust-existing-monitor short-circuit ------------------------------------------------------------------- Hoist the "this scope's monitor is already running" detection (which already lived at lines ~438 below) to BEFORE the gh-auth preflight. On a hit (live PID in airc.pid), emit the same canonical message + return 0. No preflight runs. The gh-auth probe was always meant to catch "user is about to do real work, ensure their gh credential is healthy first" — but if real work is ALREADY HAPPENING in this scope (live monitor → live bearer → live gh API calls), the running monitor's own health is the authoritative signal, not an out-of-band probe. Stale pidfile (file present, no live PIDs) falls through to the canonical cleanup block below — that path was already correct, no duplication. LAYER 2 — /join skill: airc status as ground truth ------------------------------------------------------------------- Adds a section to skills/join/SKILL.md explicitly telling the agent: `airc status` is the authoritative signal for whether this scope is in the mesh. It's local-only — no gh probe, no network call. When gh-auth-status probes disagree with airc status, trust airc status. Also adds explicit handling for the "monitor already running" exit: that's a successful no-op, NOT a failure. Run `airc status` once to confirm + narrate "already in the mesh as <nick> in <rooms>". Do NOT re-arm a Monitor (would dual-tail the same scope). Generalizes beyond Codex — same fix unblocks the rate-limit-misreport class (#344-era) AND any future "gh probe noisy but airc actually works" class. Tested on this Mac: airc join with a live monitor in the scope now emits the canonical "monitor already running" message and exits 0 WITHOUT firing the gh-auth preflight. Before this change, the preflight always fired first; on environments where it flaked, that was the source of the cascade. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 30, 2026
joelteply
added a commit
that referenced
this pull request
Apr 30, 2026
…back (generalizes #371 to cmd_send + cmd_connect) (#374) fix(monitor-liveness): centralize via _monitor_alive_with_bearer_fallback (cmd_send + cmd_status + cmd_connect short-circuit) — generalizes #371 #371 fixed cmd_status to fall back to bearer-state freshness when kill -0 was sandbox-blind (Codex). But cmd_send and cmd_connect's #369 short-circuit had the SAME blindness in the SAME way, and #371 only patched one site. Joel hit this immediately when Codex (continuum-2c54, hosting #cambriantech with bearer_state.general fresh 60s ago) tried `airc msg "hello mesh"` — got "Send NOT delivered — this scope's monitor isn't running" while the bearer was provably alive. Then `airc connect` didn't trust-existing-monitor either (#369 short-circuit also kill -0 blind), tried gh auth login, hit the same Forbidden wall. Root cause for all three: kill -0 across process trees is broken inside Codex's sandbox. Fix: extract a centralized helper at airc top-level + use everywhere. New helper: _monitor_alive_with_bearer_fallback(pidfile) Phase 1: kill -0 against PIDs in pidfile (canonical, fast) Phase 2: bearer-state freshness fallback when phase 1 returns no live PIDs but pidfile exists. If any bearer_state.<ch>.json in scope has last_recv_ts within 2x reminder interval (default 600s), bearer-recv child is provably alive. Pure read — does NOT mutate the pidfile (the older prune_pidfile_and_count would actively delete a "no live PIDs" pidfile, silently corrupting state when phase 1 was wrong about death). prune_pidfile_and_count remains for explicit cleanup paths where pruning IS desired (teardown). Three call sites updated to use the helper: 1. cmd_send.sh: monitor-liveness gate before "Send NOT delivered" refusal. Codex can now broadcast even though kill -0 is blind. 2. cmd_connect.sh #369 short-circuit: trust-existing-monitor early return now fires for Codex too (was kill -0 inline, missed sandbox-blind case). 3. cmd_status.sh: switched from inline #371 fallback to the shared helper. Same behavior, less duplicated code, single source of truth for liveness semantics. cmd_status retains the diagnostic split between "running (PID X)" (verified via kill -0) and "likely-alive (Ns via #channel; kill -0 blind ...)" (verified via bearer-state only) so the user can tell which path confirmed liveness. Tested locally: airc status from a no-pidfile scope still reports "not running" (helper returns no on missing pidfile — correct). Live-test path: Joel runs airc msg from Codex's continuum-2c54 scope post-merge — expect successful broadcast instead of "monitor isn't running" refusal. Closes the operational half of #372 (Codex can now send + status correctly). The agent-side event surfacing (auto-receive for Codex) is still tracked there as the broader UX fix. Co-authored-by: joel <[email protected]> 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.
Closes #367. Joel's exact framing: "if the skill constantly causes this, it seems broken to everyone. do the most correct and robust [fix]."
The user-visible bug
In environments where gh's auth probe is flaky (Codex sandbox especially — openai/codex#10695),
airc join's preflight hard-died with"token invalid"even when the scope's airc monitor was already running and bearer was actively reading/writing gh gists. The skill then reacted to the (wrong) token-invalid message by tryinggh auth login -w— which also fails in the same flaky env — and Carl saw a multi-step debug-loop wreckage on a scope that was actually fine.This was reproduced live during today's Codex first-encounter QA on Joel's rig, four times in a row.
Two-layer fix
LAYER 1 —
cmd_connect.shtrust-existing-monitor short-circuitHoist the
"this scope's monitor is already running"detection (which already lived ~200 lines below in cmd_connect) to before the gh-auth preflight. On a hit (live PID inairc.pid), emit the canonical message + return 0. The gh-auth preflight runs ONLY when no live monitor exists.The gh-auth probe was always meant to catch "user is about to do real work, ensure their gh credential is healthy first." If real work is already happening in this scope (live monitor → live bearer → live gh API calls), the running monitor's own health is the authoritative signal, not an out-of-band probe.
Stale pidfile (file present, no live PIDs) falls through to the canonical cleanup block below — that path was already correct, no duplication.
LAYER 2 —
/joinskill:airc statusas ground truthAdds a section telling the agent:
airc statusis the authoritative signal for whether this scope is in the mesh. Local-only — no gh probe, no network call. When gh-auth-status probes disagree withairc status, trustairc status.Plus explicit handling for the
"monitor already running"exit: that's a successful no-op, NOT a failure. Runairc statusonce to confirm + narrate"already in the mesh as <nick> in <rooms>". Do NOT re-arm a Monitor (would dual-tail the same scope).Generalization
Both layers fix the Codex-sandbox-flake class AND the rate-limit-misreport class (#344-era) AND any future "gh probe noisy but airc actually works" class. The principle — trust the operation's own state over out-of-band probes — is durable.
Tested on this Mac
With a live monitor in the scope:
No gh-auth preflight ran. Before this change, the preflight always fired first; on flaky environments, that was the source of the cascade.
Test plan
bash -n cmd_connect.shsyntax checkairc joinshort-circuits cleanly without gh-auth probe/joinfrom the airc skill — expect "already in the mesh" path (the prior Claude Code session in same dir established the host)Related
🤖 Generated with Claude Code