Repository navigation
Conversation
fix(gh): drain pending sends under governor
…gression test(attach): cover launcher hup survival
Pre-fix `cmd_connect`'s arg loop had a single `*) positional+=("$1")` arm
that silently accepted any unrecognized `--<flag>` as a positional. That
positional then became `target` in the parser tail, which became host-mode
`name` (line 1733: `local name="${target:-}"`), which got persisted to
config.json `name` field (line 1740: `set_config_val name "$name"`).
Observed in the wild: continuum-8e97 on Windows ran `airc join --background`
and got "Hosting as '--background'", with config.json `name` field
persisted as `"--background"`. Identity stayed corrupted across `airc
teardown` + `airc join` cycles; only manual JSON edit recovered it.
Same shape as the original `--attach` leak (#511/#521). The PR #521 belt
at lines 584-594 strips `--attach` specifically from positional[]. This
generalizes the defense to ALL unrecognized flags.
Inline invites, gist ids, and humanhash mnemonics never start with `-`,
so the rejector cannot eat a legitimate positional. The known `--attach`
recovery belt is preserved (encoding-corrupted variants still recover).
Adds scenario_join_rejects_unknown_flag to test/integration.sh covering
exit code, stderr message, host-setup-not-started, and config-not-written
assertions. Test runs on the same path as #533's HUP regression test.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…own-flags fix(cmd_connect): reject unknown flags instead of treating as positional name
…ill-audit fix(doctor): surface gh governor health
Pre-fix the JOIN MODE diverged-intent path (user wants channel A, host's mesh advertises channel B) called `ensure_channel_subscribed_with_gist` on the user's intent FIRST and `die`'d the entire join when that one call failed (cmd_connect.sh:1496). The host's channel was warning-only when it failed (line 1498), so the asymmetry made one recoverable hiccup fatal while leaving the actual failure mode it should have guarded against silent. Observed in the wild today (continuum-8e97 on Windows): Found mesh on your gh account → joining (df40c8ae...) Resolving gist df40c8ae... ... ✓ Resolved invite from gist. ✓ Multi-address pick: 192.168.1.223:7547 (from host.addresses) ⚠ Could not resolve gist for #general: ERROR: Could not bootstrap #general; refusing to join with broken state The user's auto-scope intent was #general; host advertised #cambriantech. #general gist resolution hiccupped (gh API path returned empty without stderr — likely transient sub-bucket throttling on a busy session). The mesh was reachable. The host's channel was reachable. There was no reason to refuse the join — but `die` exited 1 with no recovery. Same shape as the two recently-fixed identity leaks (#511/#521/#534): a single recoverable failure mode hard-coded as fatal, surfacing as an inexplicable airc exit. Fix: try both intent and host channels, fall back to whichever bootstraps. Joined-mesh / joined-intent-only / joined-host-only-fallback are the three success paths; only `die` when BOTH are gone (no viable subscription either way). Adds AIRC_TEST_FAIL_ENSURE_CHANNEL — a test-only env hook the structural regression scenario uses to deterministically lock in the fix without needing a real gh-rate-limit reproducer. Behavioral coverage is limited by the integration suite's offline constraints (the diverged path requires a real gist), so the scenario is structural: parses clean, hook is wired, fallback message present, the unconditional intent die is gone. Manual reproducer at /tmp/repro.sh. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…strap-fallback fix(cmd_connect): fall back to host channel when intent bootstrap fails
fix(bearer-gh): coalesce monitor gist reads
fix(monitor): stop respawning gone channel gists
…prune fix(repair): preserve gone channel pruning
…ault-nicks feat(identity): prefix generated nicks by platform
join: expose transport during attach cold start
windows: launch airc cmd shim through bash directly
…le-source windows: prefer WSL airc install from cmd shim
`wsl.exe sh -lc "<script>" airc %*` does NOT forward the positional
args to the inline script as $0, $1, $@. wsl.exe consumes them itself,
so `$@` inside the script was always empty and `airc.cmd join` ended
up running `exec airc` with no verb. airc fell through to the generic
help banner and exited 0; Claude Code's Monitor on Windows saw airc
print help and silently terminate before any transport spawned.
Symptom from Windows trace just now (`airc.cmd version`): printed
the help banner instead of `airc <sha> on canary`. Same shape was
hiding behind the post-takeover "no existing room — fresh start"
death window: the Monitor's airc.cmd → wsl.exe → sh -lc invocation
was never actually running `airc join`; it was running airc with
no args, which prints help and exits.
Fix:
1. Inline cmd's %* directly into the bash command string, so
positional args are part of the script string before wsl.exe
sees them — bypassing the silent arg-drop.
2. Use `bash -lc` (matches the airc script's #!/bin/bash shebang)
instead of `sh -lc` (dash on Ubuntu). Avoids subtle sh/dash
parser divergence on the same wire shape.
Verified locally:
$ cmd /c airc.cmd version
airc <sha> on canary
Merge pull request #543 ...
install: /home/joel/.airc-src
Pre-fix the same command printed help.
Related context for the Windows Monitor cold-start surface:
#533: SIGHUP cascade (transport detach via setsid -f)
#538: monitor 404-gone gist treated as terminal
#541: airc.pid + messages.jsonl created before slow bootstrap
#542: airc.cmd direct cmd→bash (drop PowerShell hop)
#543: dual-clone single-source — Windows shim prefers WSL clone
THIS: #543 made the WSL-routing path correct in shape but
broke arg-forwarding in implementation.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pre-fix `install.sh` line 451 used `ln -sf "$CLONE_DIR/airc" "$BIN_DIR/airc"`. On real Linux/macOS this is a real symlink that the kernel resolves to the canonical airc each invocation — `airc update` propagates instantly. On Git Bash for Windows, `ln -sf` is silently a literal COPY (Developer Mode is off by default; Git for Windows can't make NTFS symlinks). That's why a 112KB May-5 copy of the full airc bash script sat at `C:\Users\<user>\.local\bin\airc` for weeks: every `airc update` (run from WSL) refreshed `~/.airc-src/` on the WSL side, but the Windows PATH copy stayed frozen. Claude Code's Monitor on Windows resolves `airc` via Git Bash's `which`, found the stale copy first, and silently ran months-old code while `airc version` (which goes through the .cmd shim) reported the new SHA. Diagnosed today during the post-#543 Monitor-cold-start investigation. Fix per Joel's directive (#543 follow-up): > Any Windows-visible airc on PATH must be a shim, not a copied full > bash script. The shim should route to the canonical WSL install > when WSL ~/.airc-src/airc exists. Native Windows fallback remains > only when no WSL OR AIRC_WINDOWS_NATIVE=1. New file `airc.shim` — polyglot bash routing shim: 1. AIRC_DIR explicit → exec that 2. We're in WSL ourselves → exec $HOME/.airc-src/airc directly (handles "user invokes /mnt/c/.../bin/airc from WSL bash") 3. AIRC_WINDOWS_NATIVE=1 → skip WSL branch 4. wsl.exe present + WSL canonical exists → route via wsl.exe (uses printf %q to forward args correctly — wsl.exe doesn't forward positional args after `-lc`, so they must be inlined into the bash command string. Same root cause as #544.) 5. Native Windows clone at %USERPROFILE%\.airc-src → exec that 6. Loud failure with all attempted paths `install.sh` updated: on MINGW/CYGWIN/MSYS hosts, drop the polyglot shim into BIN_DIR/airc + BIN_DIR/relay instead of `ln -sf`'ing the full bash script. Also clean any pre-existing full-script copy left by prior installs (best-effort `rm -f` is enough). Real Linux/macOS keeps the symlink — that's the right tool there. Verified locally on Windows + WSL2 (canary tip + this branch): - cmd /c airc.cmd version → routes via wsl.exe → canonical - "C:\Program Files\Git\bin\bash.exe" airc version → shim → canonical - wsl bash -lc /mnt/c/.../bin/airc version → shim detects WSL → canonical All three contexts hit the same canonical SHA. No more dual-clone drift. Follow-up — install.ps1 should also drop the polyglot shim at %USERPROFILE%\.local\bin\airc so Git Bash users who installed via the Windows-native path also get a shim instead of nothing on Git Bash's default PATH. Deferred to a separate PR for review-scope hygiene. Related context: #542: airc.cmd direct cmd→bash (drop PowerShell hop) #543: dual-clone single-source — airc.cmd prefers WSL clone #544: airc.cmd args-forwarding (wsl.exe doesn't forward $@) THIS: extend single-source to ALL Windows-visible PATH copies, not just airc.cmd. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pre-fix this function was the last self-killer in the join cold-start
path. Three failure shapes combine — fixing only one was insufficient:
(1) Same-PID self-kill after re-exec. After `_reexec_into host`,
the new airc inherits the SAME pid as the pre-exec instance.
airc.pid (written early per #541) names US. Without filtering
$$/$PPID, the kill loop SIGTERM'd its own shell. Defensive
pattern already exists in _join_scope_transport_pids:211 — was
never propagated to airc.pid contents until now.
(2) OS PID recycling. The other PID sources (airc.pid contents from
a crashed predecessor, bearer_gist.*.pid stragglers) can name
a slot the kernel has since reassigned to an unrelated process
— including, on Windows WSL2, the parent wsl.exe / cmd.exe
shell in our launcher chain. Killing one of those takes Claude
Code's Monitor down with us. Joel hit this exact shape in #97 /
#446 in different code paths; the fix there ("verify cmdline
before treating PID as ours") was never propagated here.
(3) set -e + pipefail kills the whole airc on best-effort PID
assembly. The function uses `proc_airc_pids_matching` (pgrep)
which exits 1 when no matches. Pipefail propagates the 1
through `pgrep | tr`, the simple var assignment then triggers
set -e, and airc dies between debug-instrumented "step1" and
"step2" markers — never reaching the kill loop, never returning
from the function. This was the residual death point that
made my earlier $$ filter alone look ineffective. Joel's
"Codex and Claude usually miss the obvious" call applies.
Fix:
Layer 1 — drop $$ and $PPID from the candidate list.
Layer 2 — verify cmdline matches airc/airc_core before killing,
so an OS-recycled PID owned by an unrelated process is
never targeted.
Layer 3 — wrap each substitution in `|| true` so pipefail can't
propagate pgrep's empty-result-1 into a fatal var
assignment.
Verified end-to-end on Windows + WSL2 (with #544 + #545 also applied
locally). Monitor's `airc join` flow:
shim → wsl.exe → canonical airc → join → discover → take over
→ re-exec to host mode → trust-existing-monitor short-circuit
→ degraded transport detected → _join_restart_scope_processes
→ filters $$ (PID 57724) + dead bearer pids 80413/38943
→ all candidates dropped, kill loop empty, function returns
→ host setup completes through "Hosting #cambriantech (gh-account
substrate)" → "Monitoring for messages..." → broadcast contract
banner → mesh send confirmed bidirectional.
After: Windows Claude Code Monitor `airc join` finally completes
the cold-start path without Joel relay.
Related — Windows Monitor cold-start surface trail:
#533 SIGHUP cascade (transport detach via setsid -f)
#538 monitor 404-gone gist treated as terminal
#541 airc.pid + messages.jsonl created before slow bootstrap
#542 airc.cmd direct cmd→bash (drop PowerShell hop)
#543 dual-clone single-source (airc.cmd prefers WSL)
#544 airc.cmd args-forwarding (wsl.exe doesn't forward $@)
#545 polyglot shim for Windows-visible PATH (single source)
THIS three-layer self-protect on the supervisor restart path.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rwarding fix(windows-shim): forward args correctly through wsl.exe
…hims fix(install): single-source polyglot shim for Windows PATH
fix(connect): _join_restart_scope_processes must not kill self
…auth test: skip gone-gist send scenario without gh auth
There was a problem hiding this comment.
Pull request overview
Promotes canary ead6d6f to main, bringing in a set of reliability hardening changes across transport (GitHub gist), supervisor/join flows, and Windows/WSL install/shim behavior to support stable multi-agent collaboration.
Changes:
- Add a cross-process GitHub request governor (shared backoff + per-user request budget + audit log) and route
ghusage through it. - Improve dissolved/gone gist handling and recovery (send-side, recv-side, monitor respawn prevention, and scope repair guardrails).
- Harden join/attach/Codex startup flows (early process evidence, duplicate-generation repair, clearer status/doctor surfacing) and add extensive regression coverage.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_scope_repair.py | Adds regression coverage ensuring gone-gist markers prevent scope repair from restoring dead channel mappings. |
| test/test_pending_batch.py | Adds CLI-level tests for pending batch route classification. |
| test/test_gh_backoff.py | Adds unit tests for the GitHub governor (budget/backoff/audit/doctor surfaces). |
| test/test_bearer.py | Adds regression tests for recv failure state marking, gone-gist recv behavior, GET cache coalescing, and batched sends. |
| test/integration.sh | Expands integration scenarios for gone-gist send/recv behavior, attach/Codex join hardening, Windows shim expectations, and platform-prefixed nick derivation. |
| skills/tests/SKILL.md | Removes the standalone tests skill (tests are owned by doctor). |
| skills/doctor/SKILL.md | Updates doctor guidance to include gh governor diagnosis and consolidates tests under doctor. |
| README.md | Updates CLI docs for airc doctor --tests, removes /tests skill, and documents platform-prefixed autogenerated identity names. |
| lib/airc_core/scope_repair.py | Teaches scope repair to respect persisted “gone gist” markers when inferring channel_gists. |
| lib/airc_core/pending_batch.py | Introduces a small CLI/helper for classifying pending.jsonl batches without shell JSON parsing. |
| lib/airc_core/gh_backoff.py | Expands backoff into a shared governor with locking, budgeting, auditing, and CLI/doctor helpers. |
| lib/airc_core/channel_gist.py | Routes gh calls through the governor to reduce rate-limit storms. |
| lib/airc_core/bearer.py | Adds a default send_many() batching API for bearers. |
| lib/airc_core/bearer_gh.py | Implements send_many() batching, adds per-user GET cache coalescing, and treats gone gists as terminal on recv. |
| lib/airc_core/bearer_cli.py | Adds send-batch, and ensures recv exceptions mark state as failed with last_error. |
| lib/airc_bash/lib_auth.sh | Improves gh auth-state detection to classify governor blocks as rate-limited (non-auth) conditions. |
| lib/airc_bash/cmd_status.sh | Surfaces bearer last_error, displays queue pausing due to gh governor, and hardens Codex start idempotence/waiting. |
| lib/airc_bash/cmd_send.sh | Ensures 404/gone gist sends do not claim delivery, persists gone markers, and prints queued vs delivered banners correctly. |
| lib/airc_bash/cmd_doctor.sh | Integrates gh governor doctor output into airc doctor --health. |
| lib/airc_bash/cmd_connect.sh | Hardens restart/self-kill avoidance, rejects unknown flags, adds early pidfile evidence, and improves intent/host fallback behavior. |
| install.sh | Enforces Windows single-source behavior by installing a shim instead of symlink/copying the full script on Git Bash. |
| install.ps1 | Updates Windows shim generation to call Git Bash directly and prefer WSL when available. |
| airc.shim | Adds a polyglot shim to route Windows-visible airc invocations to the canonical install (prefer WSL). |
| airc.cmd | Reworks cmd shim to invoke Git Bash directly and prefer WSL canonical clone. |
| airc | Adds scope-path canonicalization, platform-prefixed derived names, centralized gh governor wrapper, monitor gone-gist recovery, and pending batch drain improvements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+36
| result = subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-m", | ||
| "airc_core.pending_batch", | ||
| "host-broadcast-route", | ||
| "--snapshot", | ||
| str(snapshot), | ||
| "--config", | ||
| str(config), | ||
| "--fallback-gist", | ||
| fallback, | ||
| ], | ||
| cwd=str(REPO_ROOT), | ||
| env={"PYTHONPATH": str(REPO_ROOT / "lib")}, | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) |
Comment on lines
+277
to
+279
| wsl.exe sh -lc "test -x \"$HOME/.airc-src/airc\"" >nul 2>nul | ||
| if not errorlevel 1 ( | ||
| wsl.exe sh -lc "exec \"$HOME/.airc-src/airc\" \"$@\"" airc %* |
Comment on lines
1395
to
+1408
| # Re-read channel_map from config at top of each outer cycle so | ||
| # an in-flight config change (e.g. _mesh_rediscover_loop swapping | ||
| # the host gist after rotation) takes effect on the next bearer | ||
| # respawn, no full process restart required. Falls back to the | ||
| # parameter passed at startup if the re-read returns empty | ||
| # (transient config-write race or missing list_channel_gists | ||
| # support on older airc_core). | ||
| # the host gist after rotation, or a gone-gist prune below) takes | ||
| # effect on the next bearer respawn, no full process restart | ||
| # required. Empty is meaningful: it means no channel currently has | ||
| # a viable wire, so do not fall back to the stale startup map. | ||
| local _refreshed_map | ||
| _refreshed_map=$("$AIRC_PYTHON" -m airc_core.config list_channel_gists \ | ||
| --config "$CONFIG" 2>/dev/null || true) | ||
| if [ -n "$_refreshed_map" ]; then | ||
| channel_map="$_refreshed_map" | ||
| channel_map="$_refreshed_map" | ||
| if [ -z "$channel_map" ]; then | ||
| echo "airc: no channel_gists mappings remain; monitor waiting for 'airc join --room <channel>' to re-host" >&2 | ||
| sleep 30 | ||
| continue |
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.
Summary
Promote canary
ead6d6fto main after cross-agent/cross-platform validation.This promotion includes PRs #527-#546, centered on making AIRC reliable enough for real multi-agent collaboration:
Live validation
Validated on canary
ead6d6fwith multiple active agents/scopes:airc doctor --healthon Mac scope: bus working, gh core rate remaining healthy, governor active/calmKnown follow-up, not a promotion blocker:
Local checks
bash -n airc airc.shim install.sh test/integration.sh lib/airc_bash/cmd_connect.shairc doctor --health(bus working; one governor warning from protected blocks, no transport failure)Release gate
No updated-sha transport blockers reported after round-robin and burst validation. I support canary -> main.