Skip to content

canary → main: bearer dedup + self-heal hardening, Codex inbox, human paste-block onboarding - #454

Merged
joelteply merged 113 commits into
mainfrom
canary
May 5, 2026
Merged

joelteply merged 113 commits into
mainfrom
canary

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Promotes 8 commits from canary to main. Major themes:

1. Bearer lifecycle & duplicate-emission dedup (#451 + #452)

Diagnosed 2026-05-04 by Joel: peer broadcasts arriving twice in monitor streams with identical body + nonce. Two stacked fixes:

2. Self-heal hardening (#446 + #447)

3. Codex (non-Monitor) runtime (#445 + #450)

  • fix(skills): codify Codex non-Monitor airc runtime #445 codifies the non-Monitor runtime in skill docs — Codex (and any agent without the Monitor tool) starts airc through the daemon or as a background process, then polls airc logs --since. Idempotent re-arm semantics + scope-local pid file are described.
  • feat(codex): add stateful inbox polling #450 adds stateful inbox polling: airc inbox cursors through new messages since last read, complementary to airc logs --since. Useful for non-Monitor runtimes that want a "what's new since I last looked" surface.

4. Human-coworker onboarding (#449)

airc invite --human prints a self-contained shell paste-block — install one-liner + airc connect <gist-id> (using absolute path so PATH-not-yet-refreshed shells find airc post-install) + first-message hint with literal $(whoami) (expands on the receiver's shell, not the host's) + clean-exit hint. Cross-account-safe: uses raw gist-id, not mnemonic. Same PR also fixes cmd_connect.sh to honor AIRC_NO_DISCOVERY=1 in the host-publish path (was waiting up to ~90s for find_existing on gist-heavy accounts; now ~3s).

5. Lobby etiquette + small text fixes (#448)

  • New "Lobby etiquette" section in the /join skill with a single test: "would agents in OTHER projects need to see this?" — defaults project chatter to the project room, not #general.
  • Fixes the display-filter WARN line that advertised the nonexistent airc subscribe <channel> command (the actual command is airc join --room <channel>).

Commits

SHA Title
9ef316c fix(monitor): isolate failed channel bearer restarts (#452)
da16768 fix(bearer): per-(scope, channel, gist) lock prevents duplicate emission (#451)
82ccf16 feat(invite): airc invite --human — self-contained paste-block for coworker onboarding (#449)
0d48ccd feat(codex): add stateful inbox polling (#450)
f0f8111 docs(skills): lobby etiquette + fix nonexistent 'airc subscribe' in display-filter warn (#448)
09edbec fix(self-heal): verify PID cmdline before treating as live monitor — closes Task #97 (airc-bios) (#447)
82d3fa7 fix(teardown): reap scope parent chain when pidfile is stale (#446)
7864e21 fix(skills): codify Codex non-Monitor airc runtime (#445)

Test plan

Already exercised on canary by the live mesh:

  • Bearer dedup verified live: 3 distinct gists in scope → 3 distinct bearer_gist.<gist>.pid pidfiles, each claimed by exactly one bearer.
  • Recent peer broadcasts in #general arrive once post-fix(monitor): isolate failed channel bearer restarts #452 (compare to repeated duplicates pre-fix).
  • HOST GIST ROTATED self-heal fires + new bearer claims new pidfile cleanly without disturbing healthy bearers (fix(monitor): isolate failed channel bearer restarts #452 cascade-restart behavior).
  • airc invite --human smoke-tested locally — paste-block format correct, $(whoami) literal preserved, gist-id matches host's published room gist.
  • All 90 bearer unit tests pass (python3 test/test_bearer.py).
  • CI clean-install matrix green on every PR contributing to this bundle.

Rollback

If a regression shows up, revert order would be #452 → #451 → #449/#450/#448 → #447/#446/#445. The first two are bearer-internal so safest to revert in pair; the rest are independent.

🤖 Generated with Claude Code

Co-Authored-By: airc-8a5e (Codex) [email protected]

joelteply and others added 8 commits May 3, 2026 10:38
…closes Task #97 (airc-bios) (#447)

fix(self-heal): verify PID cmdline before treating as live monitor — closes Task #97 (airc-bios self-heal)

Joel hit this 2026-05-03: laptop slept, airc Monitor died, OS later
reused those PIDs for unrelated bash/python procs. `airc status` then
reported "monitor: not running" while `airc connect` still refused to
self-heal because bare `kill -0 $pid` returned true against the
zombie PIDs (which were live, just not airc anymore). Mesh
effectively partitioned. Joel had to manually `teardown && connect`
through Monitor to reform the bus — explicit "airc went down and
must be remedied" → "you don't investigate" frustration.

Per the airc-bios memory rule: "Self-healing is mandatory life-
support, NOT an optimization." Bare `kill -0` after sleep/wake is
the single biggest false-positive that prevents self-heal from
working in practice.

## Two call sites fixed

1. `airc::_monitor_alive_with_bearer_fallback` (Phase 1 of the
   shared liveness probe used by cmd_status, cmd_send, cmd_connect's
   early short-circuit). Previously: any `kill -0` true → "yes".
   Now: also requires cmdline regex match. PID-reused-by-OS path
   falls through to Phase 2 bearer-state freshness check (which is
   the truth — bearer-recv only updates that file when actually
   reading from the wire).

2. `cmd_connect.sh` canonical pidfile-cleanup block (line ~488).
   Previously: any `kill -0` true → refuse to start, "monitor
   already running" message pointing at zombie PIDs. Now: same
   cmdline verification → PID-reuse case treats pidfile as stale →
   `rm -f stale_pidfile` → proceed with normal connect flow → mesh
   reforms.

## Cmdline regex shape

Identical to cmd_teardown's parent-chain reaper (#446). Three
alternatives cover:
- absolute-path airc connect|join (`/usr/local/bin/airc connect`)
- bare airc connect|join (`airc connect` on PATH)
- eval-wrapped airc connect|join (some daemon launchers)

Keeps the codebase consistent on what counts as "an airc process."

## What it does NOT change

- Live monitor in same scope: still detected, still respected
  (cmdline regex matches an actual airc connect|join).
- Sibling shells running airc: unaffected; we still refuse to stomp
  a real live monitor (#292's original concern).
- Bearer-state Phase 2 fallback: unchanged. Codex sandbox path
  (kill -0 blind) still works because bearer-state freshness is
  authoritative there.

## Verification

- `bash -n airc lib/airc_bash/cmd_connect.sh` clean.
- `bash test/integration_smoke.sh round_trip` 2 pass / 0 fail.
- The two test/integration_smoke.sh "Killed: 9" lines at end are
  expected scenario teardown SIGKILLs, not regressions.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…isplay-filter warn (#448)

Two small text-only fixes motivated by today's #general overflow:

1. /join skill — add a "Lobby etiquette" section with a single test
   ("would agents in OTHER projects need to see this?") to redirect
   project-internal chatter back to project rooms. Default airc msg
   already routes to subscribed_channels[0] (the project room), but
   nothing in the skill told agents that lobby ≠ project chat. Result:
   continuum-internal vulkan-bug + PR threads landed on #general for
   the past day, drowning out actual cross-room signal.

2. monitor_formatter display-filter WARN — the warning advertised
   `airc subscribe <channel>` to view filtered messages, but no such
   command exists. The actual subscribe path is `airc join --room
   <channel>`. Fixed in the print statement, the docstring, and the
   matching test docstring.

Tests: all 12 monitor_formatter tests still pass (no string assertions
on the user-facing text were affected).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
feat(codex): add stateful airc inbox polling
…worker onboarding (#449)

* feat(invite): airc invite --human emits a self-contained paste-block

New convenience method for onboarding a coworker who doesn't have
airc yet. `airc invite --human` (or --share-block / --for-friend)
prints a shell-runnable block the user pastes into a coworker's
chat tool (Slack/email/etc.). The block includes:

  1) curl|bash install one-liner (skip if already installed)
  2) airc connect <gist-id> using the absolute path ~/.local/bin/airc
     so PATH-not-yet-refreshed shells still find airc post-install
  3) "say hi" first-message hint (preserves literal $(whoami) so
     it expands on the receiver's shell, not the host's)
  4) airc part clean-exit hint

Why the gist-id and not the mnemonic: mnemonic resolution is
same-gh-account-only; raw gist-id is the cross-account-safe form,
which is what coworkers (different gh accounts, no Tailscale) need.

Integration scenario (test/integration.sh: invite_human) asserts
the paste-block contains each onboarding step, the gist-id matches
the host's actual published room gist, the gist exists/reachable
on gh, and absolute airc path is present. Joiner-pair end-to-end
is intentionally NOT covered here (it's exercised by existing
scenarios general_has_shared_gist + custom_room_creates_gist);
this scenario's job is regression coverage for the paste-block
FORMAT itself.

Motivated by Joel's framing 2026-05-04: "this will be a bot-driven
system, other than the convenience methods, human instructions for
example: paste this to your friend etc. They might not even have
airc yet too."

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

* fix(connect): honor AIRC_NO_DISCOVERY=1 in host-publish path too

cmd_connect.sh's host-publish path called channel_gist.resolve
unconditionally, even when AIRC_NO_DISCOVERY=1 was set. resolve
walks `gh api gists --paginate` (timeout 30s, retried 3×) before
falling through to create_new. On gh accounts with many gists
this added ~90s of pre-publish latency despite the explicit
"don't go looking" opt-out.

Half-honoring AIRC_NO_DISCOVERY (skip the early mesh-find gate
but still consult find_existing in the host-publish path) was a
real footgun for tests + CI scenarios that explicitly opt out.
The resolve module's own docstring says host-bootstrap should
treat find_existing as best-effort; this commit makes that the
flag-driven behavior.

Net: with AIRC_NO_DISCOVERY=1, host bootstrap goes straight to
create_new — gist published in ~3-5s instead of up to ~90s on
gist-heavy accounts.

Convergence semantics for the default case (no AIRC_NO_DISCOVERY)
are unchanged: full retry, ~4.5s wait to handle gh's listing
eventual consistency, oldest-canonical wins on race.

Also bumps the invite_human scenario's wait from 30s → 60s
defensively, in case the gh API is slow even on the create_new
path. With the fix, the typical wait should still be ~3-5s.

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

* docs(skills): document --human flag in /invite skill

Adds a "Pick the right form" decision table at the top:
agent-recipient → bare invite (single join string), human-recipient
→ invite --human (self-contained shell paste-block).

Default is the agent form. AIs switch to --human only when the user
names a specific human coworker or says "send to a human."

Motivated by Joel's framing 2026-05-04: "smooth UX experience for
humans and AIs alike, and tonight Toby will test a remote conn."
The skill needs to make the pick explicit so AIs don't reflexively
hand a human a 200-char base64 invite string.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…ion (#451)

* fix(bearer): per-(scope, channel, gist) lock to prevent duplicate emission

Symptom Joel diagnosed 2026-05-04: the same peer broadcast appeared
twice in the monitor stream with identical body + identical session
nonce — meaning bearer_cli yielded it from the gist twice, not that
the peer broadcast twice.

Root cause: nothing prevents multiple bearer_cli recv processes from
running for the same (scope, channel, gist) tuple. Two paths produced
this in practice:

  - Scope teardown leaks orphan bearers. cmd_teardown kills processes
    via airc.pid, but bearer_cli children spawned by the old monitor
    can be reparented to PID 1 if the parent died ungracefully. They
    keep polling forever, unbounded by the cleanup that removed the
    visible monitor.
  - Host-gist-rotation respawns. When the host gist rotates (e.g.
    self-heal eviction), a new bearer is spawned against the new gist
    while the old bearer may still be alive briefly polling the old
    gist. If both their stdouts feed the same downstream, every line
    arrives twice.

Fix: bearer_cli.cmd_recv claims a per-(scope, channel, gist) lock at
startup. Pidfile path is derived from --state-file by replacing
.json → .pid (so bearer_state.general.json → bearer_state.general.pid
in the same scope dir). Stale-pidfile recovery follows cmd_connect's
#97 self-heal pattern (kill -0 alone is unsafe — OS reuses PIDs after
sleep/wake; verify cmdline shape matches bearer_cli recv for OUR gist).

Lock claim outcomes:
  - Pidfile absent → claim, write our pid+gist.
  - Pidfile present, PID dead → stale; claim.
  - Pidfile present, PID alive but for a different gist → stale
    (rotated-gist case); claim.
  - Pidfile present, PID alive AND for our gist → exit 0 cleanly with
    a stderr line so the watchdog can see why the second bearer
    declined to spawn.

Without --state-file no lock is taken — preserves backwards compat
for legacy / test invocations that don't have a writable scope dir.

Tests: 6 new BearerCliRecvLockTests cover each branch + the
release-only-when-we-own-it semantic that prevents stomping a
successor that took the lock after we ran. All 87 existing bearer
tests still pass.

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

* fix(bearer): make recv lock claim atomic

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 4, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Promotes a canary bundle to main focused on improving mesh reliability (bearer dedup + targeted self-heal/restart behavior), adding a stateful polling surface for non-Monitor runtimes (Codex), and improving human onboarding via a pasteable invite block.

Changes:

  • Add a per-scope/per-gist recv lock to prevent duplicate bearer polling of the same gist, plus unit tests for lock claim/release behavior.
  • Add airc inbox (and aliases) with a per-scope cursor, plus integration coverage; update skills/docs to prefer inbox polling for Codex/non-Monitor runtimes.
  • Harden self-heal/teardown and multi-channel monitoring: cmdline verification for PID reuse, parent-chain reaping on stale pidfiles, and per-channel bearer restart isolation.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test_monitor_formatter.py Updates the display-filter warning text expectation to the correct command (airc join --room).
test/test_bearer.py Adds unit tests covering recv lock claim/reclaim/release semantics and failure modes.
test/integration.sh Adds scenarios for airc inbox cursor behavior and airc invite --human paste-block validation; wires them into the mode switch.
test/integration_smoke.sh Adds smoke coverage ensuring teardown reaps the scope parent chain when pidfiles are stale.
skills/update/SKILL.md Updates update workflow to include Codex/non-Monitor restart + inbox catch-up guidance.
skills/resume/SKILL.md Documents Monitor vs Codex/non-Monitor resume flows, adding inbox polling steps.
skills/repair/SKILL.md Adds Codex/non-Monitor reconnect flow with background connect + inbox.
skills/msg/SKILL.md Recommends running airc inbox before sending in non-Monitor runtimes; updates message transport wording.
skills/logs/SKILL.md Expands examples to include logs --since and inbox; clarifies no follow mode.
skills/join/SKILL.md Adds “lobby etiquette” guidance and codifies daemon/background join + inbox polling for Codex.
skills/invite/SKILL.md Adds --human invite guidance describing the coworker paste-block behavior and failure modes.
skills/inbox/SKILL.md Introduces the new /inbox skill for stateful unread polling.
skills/doctor/SKILL.md Updates triage order to use airc inbox --peek for recent unread context.
skills/canary/SKILL.md Updates canary instructions to restart the scope and include Codex/non-Monitor restart + inbox steps.
lib/airc_core/monitor_formatter.py Fixes the displayed command in the loud drop warning and docstring.
lib/airc_core/bearer_cli.py Implements recv pidfile locking + stale lock self-heal based on PID liveness and cmdline verification.
lib/airc_bash/cmd_teardown.sh Extends teardown to reap parent wrappers of scope-path-tagged children to prevent respawn loops.
lib/airc_bash/cmd_status.sh Adds cmd_inbox implementing cursor-based unread polling atop cmd_logs --since.
lib/airc_bash/cmd_rooms.sh Adds airc invite --human paste-block generation and help text updates.
lib/airc_bash/cmd_connect.sh Hardens stale-pidfile detection with cmdline verification and honors AIRC_NO_DISCOVERY=1 in host publish path.
integrations/openai-codex/README.md Updates Codex integration guidance to include /inbox and daemon/background join + inbox polling.
airc Hardens monitor liveness check against PID reuse and changes multi-channel behavior to restart only failed channel bearers; wires airc inbox routing/help.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/airc_bash/cmd_status.sh Outdated
Comment on lines +387 to +407
local read_started
read_started=$(date -u '+%Y-%m-%dT%H:%M:%SZ')

local out
if ! out=$(cmd_logs "$count" --since "$since" 2>&1); then
printf '%s\n' "$out" >&2
return 1
fi

if [ -n "$out" ]; then
printf '%s\n' "$out"
else
echo "No new airc messages since $since"
fi

if [ "$peek" -eq 0 ]; then
mkdir -p "$AIRC_WRITE_DIR"
local latest
latest=$(printf '%s\n' "$out" | sed -n 's/^\[\([^]]*\)\].*/\1/p' | tail -1)
printf '%s\n' "${latest:-$read_started}" > "$cursor_file"
fi
Comment thread lib/airc_core/bearer_cli.py Outdated
Comment on lines +96 to +118
def _is_our_bearer(pid: int, expected_gist: str) -> bool:
"""True iff PID's cmdline matches bearer_cli recv for `expected_gist`.

Cross-platform via `ps -p <pid> -o command=`. The PID alone is unsafe
(OS reuses PIDs after sleep/wake — Joel hit this in #97). Verify the
process is actually a bearer_cli recv AND for our gist; otherwise
treat the pidfile as stale.
"""
try:
out = subprocess.run(
["ps", "-p", str(pid), "-o", "command="],
capture_output=True, text=True, timeout=2,
)
except (OSError, subprocess.SubprocessError):
return False
if out.returncode != 0:
return False
cmdline = (out.stdout or "").strip()
if "bearer_cli" not in cmdline or " recv " not in f" {cmdline} ":
return False
if expected_gist:
return f"--room-gist-id {expected_gist}" in cmdline
return True
Comment thread lib/airc_core/bearer_cli.py Outdated
Comment on lines +54 to +58
# ── Per-(scope, channel, gist) bearer lock ─────────────────────────────
# Without this lock, scope teardown that leaks orphan bearers OR a
# host-gist-rotation respawn that races with the old bearer can end up
# with TWO bearer_cli processes polling the same gist for the same
# channel. Both yield each new line to their stdout. If their pipes
Comment thread airc
Comment on lines 1352 to +1356
ch="${entry#*:}"
if kill -0 "$pid" 2>/dev/null; then
_alive+=("$entry")
else
_dead="$ch"
break 2
echo "airc: bearer recv for #${ch} died — see ${AIRC_WRITE_DIR}/bearer_recv.${ch}.log; restarting that channel only" >&2
Comment thread lib/airc_bash/cmd_rooms.sh Outdated
Comment on lines +386 to +388
# Output is itself shell-pasteable: comment lines + commands.
# Heredoc has a quoted delimiter so $(whoami) doesn't expand at
# generation time; it expands at paste time on the receiver's shell.
…irc-shaped fake PID, honest e2e skip (#456)

fix(test): scaffold_identity venv probe + send_dead_monitor airc-shaped fake + e2e_encryption honest skip

Three test fixes surfaced when canary→main CI ran the integration
suite. All three are about NOT swallowing errors (per Joel 2026-05-04
directive via Codex relay, mirroring CLAUDE.md "never swallow
errors"):

1. scaffold_identity walked `${AIRC_PYTHON:-python3}` and swallowed
   errors via `2>/dev/null`, so when system python3 lacked the
   `cryptography` module the bootstrap-ed25519 step silently failed
   to write private.pem. Downstream tests then errored with the
   opaque "ed25519 sign failed: [Errno 2] No such file or directory:
   '…/identity/private.pem'" — caller never told that cryptography
   was missing. Fix: probe candidate venvs (matching the same
   resolution airc itself walks for AIRC_PYTHON), let stderr through,
   fail loudly with explicit message if none have cryptography
   importable.

2. scenario_send_dead_monitor_dies's "live-pid" negative control
   wrote `$$` to airc.pid — the test harness's bash PID. Worked
   under bare `kill -0` semantics; broke under #447's hardened
   cmdline-shape verification (PID-reuse defense after sleep/wake).
   Fix: spawn an airc-SHAPED fake via `( exec -a "airc connect"
   sleep 60 ) &` — argv[0] now matches the
   /airc[[:space:]]+(connect|join)/ regex.
   _monitor_alive_with_bearer_fallback accepts it.

3. scenario_e2e_encryption gated on `$(dirname AIRC)/.venv-dev`,
   which install.sh does NOT create (install.sh creates `.venv`,
   inside its install dest — typically $HOME/.airc-src). Result:
   silently skipping every CI run despite the suite reporting "ran."
   Fixing the venv detection then surfaces the deeper issue: this
   scenario was written when SSH was a registered bearer; Phase E /
   post-3c removed it (`bearer_resolver.available_kinds` is gh +
   LocalBearer only), so the test's @peer-name send path errors with
   "no registered bearer can serve peer_meta=…" and the wire falls
   back to plaintext gh-substrate, defeating the "wire is ciphertext"
   assertion. Real fix is a rewrite via gh substrate; until then,
   skip with the actual reason in the message (loud skip, not silent
   pass-by-skip). Original test body preserved below `return` for
   the eventual rewriter's reference.

Local: send_dead_monitor_dies 8/8 pass; e2e_encryption skips with
explicit message; all other scenarios unaffected.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 4, 2026 17:04
…opilot review of #454) (#457)

docs(invite): correct heredoc-quoting comment in _cmd_invite_human

Copilot's review of #454 caught that the comment claimed the heredoc
used a quoted delimiter, but the actual code uses unquoted `<<PASTE`
with explicit `\$(whoami)` escape (so ${primary_chan} and
${primary_gid} expand on the host while $(whoami) survives to the
receiver). Comment now matches the actual behavior with a warning
against accidentally re-quoting the delimiter without also restoring
the channel/gist substitutions.

No functional change.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/airc_core/bearer_cli.py Outdated
Comment on lines +55 to +61
# ── Per-(scope, channel, gist) bearer lock ─────────────────────────────
# Without this lock, scope teardown that leaks orphan bearers OR a
# host-gist-rotation respawn that races with the old bearer can end up
# with TWO bearer_cli processes polling the same gist for the same
# channel. Both yield each new line to their stdout. If their pipes
# converge (the parent monitor's children share a downstream pipe, or
# both feed an unprivileged log), each downstream message arrives twice.
Comment on lines +189 to +212
fd = os.open(pidfile, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644)
try:
os.write(fd, lock_payload)
finally:
os.close(fd)
return (pidfile, my_pid)
except FileExistsError:
# Format: "<pid>\t<gist_id>". gist_id may be empty for non-gh bearers.
other_pid, _other_gist = _read_lock_owner(pidfile)
if other_pid > 0 and other_pid != my_pid \
and _pid_alive(other_pid) and _is_our_bearer(other_pid, my_gist):
print(
f"bearer_cli recv: another bearer for gist {my_gist or '(none)'} "
f"already running (PID {other_pid}); exiting cleanly to avoid "
f"duplicate emission",
file=sys.stderr, flush=True,
)
return _LOCK_HELD
# else: stale (dead pid, OS-reused, or old gist) → remove then
# retry O_EXCL claim. If another process wins the race, the next
# loop sees its pidfile and exits or retries accordingly.
try:
os.unlink(pidfile)
except FileNotFoundError:
Comment on lines +386 to +389
# Output is itself shell-pasteable: comment lines + commands.
#
# The heredoc uses an UNQUOTED delimiter (`<<PASTE`) so we can expand
# ${primary_chan} and ${primary_gid} from the host's state. The
joelteply and others added 2 commits May 4, 2026 12:15
…inite respawn loop when channels share a gist (#458)

fix(monitor): dedup bearer spawns by gist, not by channel

Real-world repro Joel hit 2026-05-04: channel_gists collapsed
useideem and general onto the SAME gist (host advertising one mesh
gist for both subscribed channels). #452's per-(scope, gist) lock
correctly admitted only ONE bearer for that gist — but the bash
supervisor in _monitor_multi_channel iterated channels and spawned
one bearer per channel REGARDLESS of gist sharing. Result: the
lock-loser bearer exits 0 cleanly with "another bearer for gist X
already running"; supervisor sees the exit as a death, respawns,
loses lock again, ad infinitum. bearer_recv.<ch>.log filled with
identical exit-cleanly lines, the channel's events_total stayed at
0, and inbound messages on that channel never reached the user.

This was the third bearer-related design-mismatch bug in the same
session (#451 was process lifecycle, #452 was the lock-key
mismatch, this is the supervisor-key mismatch). Fixing at the
supervisor: dedup by gist BEFORE spawning. Same invariant in both
paths:

  - Initial spawn (channel_map iteration): track _served_gists set;
    skip channels whose gist already has a bearer from earlier in
    the iteration.
  - Live-refresh add path: build _live_gists from current _pids
    (resolving each entry's channel→gist via the current map);
    skip channels whose gist is already covered by another live
    bearer.

The bearer reads the gist once and yields each line; monitor_formatter
routes to subscribed channels via the envelope's `channel` field
downstream. State files stay per-channel for now (per-gist state-
files would be a deeper refactor that touches status/doctor/cmd_send;
not blocking tonight's Toby remote-conn test).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
* fix(health): warn on solo collaboration mesh

* fix(mesh): use one canonical gist resolver
Copilot AI review requested due to automatic review settings May 4, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/airc_bash/cmd_status.sh Outdated
Comment on lines +638 to +643
if [ "$peek" -eq 0 ]; then
mkdir -p "$AIRC_WRITE_DIR"
local latest
latest=$(printf '%s\n' "$out" | sed -n 's/^\[\([^]]*\)\].*/\1/p' | tail -1)
printf '%s\n' "${latest:-$read_started}" > "$cursor_file"
fi
Comment on lines +168 to +172
for level, ch, suffix, detail in rows:
if mode == "degraded-only" and level != "DEGRADED":
continue
print(f" #{ch}: {level} ({suffix}) — {detail}")
PY
Comment on lines +195 to +220
except FileExistsError:
# Format: "<pid>\t<gist_id>". gist_id may be empty for non-gh bearers.
other_pid, _other_gist = _read_lock_owner(pidfile)
if other_pid > 0 and other_pid != my_pid \
and _pid_alive(other_pid) and _is_our_bearer(other_pid, my_gist):
print(
f"bearer_cli recv: another bearer for gist {my_gist or '(none)'} "
f"already running (PID {other_pid}); exiting cleanly to avoid "
f"duplicate emission",
file=sys.stderr, flush=True,
)
return _LOCK_HELD
# else: stale (dead pid, OS-reused, or old gist) → remove then
# retry O_EXCL claim. If another process wins the race, the next
# loop sees its pidfile and exits or retries accordingly.
try:
os.unlink(pidfile)
except FileNotFoundError:
pass
except OSError as e:
print(
f"bearer_cli recv: could not remove stale pidfile {pidfile}: {e}; "
f"proceeding without lock (duplicate emission possible)",
file=sys.stderr, flush=True,
)
return _LOCK_DISABLED
Comment thread test/integration.sh
Comment on lines +3470 to +3478
# This scenario tests the END-TO-END user flow Joel calls "Toby's
# case for humans" — friend pastes the block, ends up in the room.
# We can't actually run the install one-liner in the test (would
# touch the real ~/.local/bin/airc and pull from main), but we
# CAN extract the connect line and execute its substantive part:
# (1) the paste-block has the right shape, and (2) the connect
# command in it actually puts a fresh joiner scope into the host's
# room.
section "invite --human: paste-block onboards a coworker end-to-end"
joelteply added 2 commits May 4, 2026 12:31
* fix(gist): select freshest channel envelope

* fix(mesh): elect takeover winner by channel
Join discovery now skips seed-only channel gists, failed joins preserve existing mesh gists by default, takeover is explicit via --takeover/AIRC_ALLOW_TAKEOVER, and doctor marks zero-peer solo meshes as degraded.
Copilot AI review requested due to automatic review settings May 4, 2026 17:47
Copilot AI review requested due to automatic review settings May 5, 2026 05:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 61 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +313 to +317
client_id = current_client_id()
seen_sigs: set[str] = set()

def _load_seen_sigs(limit: int = 5000) -> None:
try:
Comment thread uninstall.sh
Comment on lines +142 to +146
if [ -x "$CLONE_DIR/.venv/bin/python" ]; then
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$CLONE_DIR/.venv/bin/python" -m airc_core.codex_install --codex-home "$HOME/.codex" uninstall-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
Comment on lines +225 to +226
"Get-CimInstance Win32_Process | Where-Object { \$_.CommandLine -like '*airc*' -and \$_.CommandLine -like '*$needle*' } | Select-Object -First 1 | ForEach-Object { 'yes' }" \
2>/dev/null | grep -q yes && return 0
Comment on lines +7 to +10
import os
import signal
import sys
import time
Copilot AI review requested due to automatic review settings May 5, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 61 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +313 to +315
client_id = current_client_id()
seen_sigs: set[str] = set()

Comment on lines +316 to +320
def _load_seen_sigs(limit: int = 5000) -> None:
try:
with open(local_log, encoding="utf-8", errors="replace") as f:
lines = f.readlines()[-limit:]
except Exception:
Comment on lines +33 to +36
def _set_codex_hooks_feature(config: Path) -> bool:
text = _read_text(config)
if "codex_hooks" in text:
return False
Comment thread uninstall.sh
Comment on lines +142 to +149
if [ -x "$CLONE_DIR/.venv/bin/python" ]; then
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$CLONE_DIR/.venv/bin/python" -m airc_core.codex_install --codex-home "$HOME/.codex" uninstall-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
done
fi
fi
Comment on lines +34 to +36
for path in sorted(home.glob("bearer_state.*.json")):
channel = path.name.removeprefix("bearer_state.").removesuffix(".json")
if channel and channel not in channels:
joelteply and others added 2 commits May 5, 2026 01:20
#518)

* fix(set_config_val): preserve empty values across Windows/wsl.exe boundary

Closes #511 (Windows AIRC canary smoke failed - airc join exits before
bearer spawns).

Root cause repro (Windows 11 + WSL2 Ubuntu + Claude Code Monitor):

  $ wsl bash -lc 'cd /home/joel/.airc-src/lib && python3 \
      -m airc_core.config set --config /tmp/c.json \
      --key host --value ""'
  usage: airc_core.config set [-h] --config CONFIG --key KEY --value VALUE
  airc_core.config set: error: argument --value: expected one argument

  $ wsl bash -lc 'python3 /tmp/argv-show.py --value ""'
  ['/tmp/argv-show.py', '--value']        # the "" was eaten by wsl/PS

The empty positional that follows --value gets stripped somewhere
between PowerShell / cmd.exe / wsl.exe before WSL bash sees it. Inside
WSL bash directly, the same sequence preserves "" — so the bug only
fires when airc is launched through a Windows-side process boundary.

cmd_connect.sh's join path always calls

  set_config_val host "$(get_host)"

very early, and on no-LAN machines (or transient routing) get_host
returns "". argparse then bails with "argument --value: expected one
argument" and `airc join` exits 2 before spawning the bearer or
heartbeat loops. From outside, the Monitor stream stops at "Saved
channel preference: #general" and `airc msg` then refuses with "monitor
down". Captured as #511 update 5.

Fix: switch the bash wrapper from `--value "$2"` (separate-token form)
to `--value="${2-}"` (fused-token form). The fused form is preserved
verbatim through every Windows/WSL/PowerShell layer in the launch
chain because it's a single argv element, never an empty-string-after-
flag pair. argparse parses `--value=` as `--value` with value `""`
correctly on Python 3.10+.

Also wraps `${2-}` so an unset $2 (rather than empty $2) under
`set -euo pipefail` doesn't trip nounset before reaching python.

Verified locally:

  $ python3 -m airc_core.config set --config /tmp/c.json \
      --key foo --value=
  $ cat /tmp/c.json
  {"foo": ""}

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

* Restore airc executable bit

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 5, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 62 out of 62 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uninstall.sh
Comment on lines +142 to +146
if [ -x "$CLONE_DIR/.venv/bin/python" ]; then
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$CLONE_DIR/.venv/bin/python" -m airc_core.codex_install --codex-home "$HOME/.codex" uninstall-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
Comment on lines +113 to +117
issues.append("starting; no heartbeat yet")
else:
issues.append("no heartbeat evidence")
else:
issues.append("no bearer_state file")
Comment on lines +225 to +226
"Get-CimInstance Win32_Process | Where-Object { \$_.CommandLine -like '*airc*' -and \$_.CommandLine -like '*$needle*' } | Select-Object -First 1 | ForEach-Object { 'yes' }" \
2>/dev/null | grep -q yes && return 0
joelteply and others added 2 commits May 5, 2026 01:41
… join (#521)

* fix(attach): strip --attach from forwarded argv before recursive airc join

When `airc join --attach` enters attach mode, cmd_connect re-spawns the
transport via:

    AIRC_NO_ATTACH=1 AIRC_BACKGROUND_OK=1 "$AIRC_SELF" join "$@"

with `"$@"` being the original args (`--attach` included). On every code
path I traced this should be harmless — the child sets AIRC_NO_ATTACH=1
which forces `attach=0` after the parser shifts `--attach` off — but on
Windows + Claude Code Monitor the child's flag-loop intermittently
falls through (the case-arm misses, or a re-exec re-introduces the
arg), and `--attach` lands in `positional[]`. From there:

    local target="${1:-}"  # = "--attach"
    local name="${target:-}"
    [ -z "$name" ] && name=$(resolve_name)   # skipped, name already set
    init_identity "$name"
    set_config_val name "$name"

The scope's name field gets persisted as `--attach`. Subsequent runs
read it back from config; `airc status` reports `identity: --attach
(host)`, the host gist's host_block stamps the bad name, peers see it.
Manual repair requires editing config.json since `airc rename` blocks
the rename if any peer in the room has used the name (#511 update 6
on Windows reproduced this).

Fix: strip `--attach` / `-attach` from `$@` before forwarding to the
recursive join. The child's `AIRC_NO_ATTACH=1` already prevents the
re-attach loop, so dropping the flag is safe in every code path while
also making the stuck-flag class of bug impossible by construction.

Verified locally on Windows 11 + WSL2 + Claude Code Monitor:

    $ airc join --attach
    ...
    identity:    continuum-b69f (hosting on port 7547)
    airc process: AIRC background process running for scope (PID 66054)
    transport health: DEGRADED (3/3 channel(s) need attention)
    [bearers spawn, channels start]
    $ airc msg --channel general "windows ops-ok ..."
    → #general (broadcast)

Pre-fix the same sequence put `--attach` in the name field and `airc
msg` refused with `monitor down`.

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

* Test attach spawn strips attach flag

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 5, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 64 out of 64 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread install.sh
Comment on lines +734 to +839
# ── Codex model-visible AIRC turn contract ─────────────────────────────
# Codex currently has no Claude-style Monitor tool. A daemon can keep
# the transport alive, but the model will not notice inbound peer
# traffic unless it polls local state during a turn. Install a small
# model-visible instruction so future Codex sessions surface AIRC
# traffic reliably without hitting GitHub: `airc codex-poll` reads the
# local messages.jsonl cursor, suppresses empty output, and excludes
# this identity's own messages.
#
# We only write this if the user has no existing developer_instructions
# key. If they do, do not overwrite; they can copy the block manually or
# opt into a profile. This keeps install.sh from clobbering unrelated
# Codex configuration.

_install_airc_codex_developer_instructions() {
local config="$HOME/.codex/config.toml"
local hooks_json="$HOME/.codex/hooks.json"
[ "${AIRC_SKIP_CODEX_INSTRUCTIONS:-0}" = "1" ] && return 0
[ -f "$config" ] || return 0

if grep -qE '^[[:space:]]*codex_hooks[[:space:]]*=[[:space:]]*true' "$config" 2>/dev/null \
&& [ -f "$hooks_json" ] \
&& grep -qF 'airc codex-hook user-prompt-submit' "$hooks_json" 2>/dev/null; then
if grep -qF 'AIRC-CODEX-INSTRUCTIONS-START' "$config" 2>/dev/null; then
local _tmp; _tmp=$(mktemp)
sed '/^# AIRC-CODEX-INSTRUCTIONS-START/,/^# AIRC-CODEX-INSTRUCTIONS-END/d' "$config" > "$_tmp"
mv "$_tmp" "$config"
fi
info " Codex AIRC hook already installed; skipping legacy developer_instructions polling contract"
return 0
fi

if grep -qF 'AIRC-CODEX-INSTRUCTIONS-START' "$config" 2>/dev/null; then
local _tmp; _tmp=$(mktemp)
sed '/^# AIRC-CODEX-INSTRUCTIONS-START/,/^# AIRC-CODEX-INSTRUCTIONS-END/d' "$config" > "$_tmp"
mv "$_tmp" "$config"
fi

if grep -qE '^[[:space:]]*developer_instructions[[:space:]]*=' "$config" 2>/dev/null; then
info " ~/.codex/config.toml already has developer_instructions; skipping airc Codex turn contract"
return 0
fi

local _tmp; _tmp=$(mktemp)
{
cat <<'TOML'
# AIRC-CODEX-INSTRUCTIONS-START — managed by install.sh; remove this section through AIRC-CODEX-INSTRUCTIONS-END to opt out
developer_instructions = """
AIRC Codex runtime contract:
- At the beginning of every user turn, before substantive work, if `airc` is available on PATH, run `airc codex-poll`.
- `airc codex-poll` is local-only: it reads this scope's local message cursor, prints only unread peer messages, advances the cursor, and is silent when empty.
- If `airc codex-poll` prints messages, briefly surface them to the user and account for them before continuing. If it is silent or says the scope is not initialized, continue normally.
- Do not claim AIRC collaboration is healthy from process health alone. Distinguish transport/process liveness from whether this Codex session has actually polled and seen peer traffic.
"""
# AIRC-CODEX-INSTRUCTIONS-END

TOML
cat "$config"
} > "$_tmp"
mv "$_tmp" "$config"
ok "Added Codex AIRC turn contract to ~/.codex/config.toml — restart Codex to activate automatic local inbox polling"
}

if command -v codex >/dev/null 2>&1 && [ -d "$HOME/.codex" ]; then
_install_airc_codex_developer_instructions
fi

# ── Codex lifecycle hook for local AIRC inbox injection ────────────────
# Newer Codex CLI builds can run deterministic hooks at turn boundaries.
# Install a UserPromptSubmit hook so unread airc messages become
# developer context before each user prompt reaches the model. This is
# the closest Codex equivalent to Claude Code's Monitor notifications:
# no GitHub calls, no log-tail polling in the model, and no dependence
# on the agent remembering the turn contract.

_install_airc_codex_hooks() {
[ "${AIRC_SKIP_CODEX_HOOKS:-0}" = "1" ] && return 0
[ -f "$HOME/.codex/config.toml" ] || return 0

local _python="${_airc_venv_python_bin:-}"
if [ -z "$_python" ]; then
if command -v python3 >/dev/null 2>&1; then
_python=python3
elif command -v python >/dev/null 2>&1; then
_python=python
else
warn "Could not install Codex AIRC hook: python not found"
return 0
fi
fi

local out
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$_python" -m airc_core.codex_install --codex-home "$HOME/.codex" install-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
done
fi
else
warn "Could not install Codex AIRC hook: $out"
fi
}

if command -v codex >/dev/null 2>&1 && [ -d "$HOME/.codex" ]; then
_install_airc_codex_hooks
fi
Comment on lines +295 to 317
local _gh_state
_gh_state="$(airc_detect_gh_auth_state 2>/dev/null || echo invalid)"
if [ "$_gh_state" != "ok" ]; then
# Distinguish a real auth failure from a GitHub secondary rate limit
# (abuse detection). The /rate_limit endpoint is reachable during
# secondary limits, so if it works, the token is fine — the user just
# needs to wait. `gh auth status` probes /user, which gets 403'd, and
# gh then misreports the symptom as 'token invalid'. Issue #341.
if gh api rate_limit >/dev/null 2>&1; then
if [ "$_gh_state" = "rate_limited" ]; then
printf " [BLOCKED] gh secondary rate limit (abuse detection) — token is fine\n"
printf " Fix: wait 5-15 min then re-run; cause is too many gh API calls in a short window\n"
printf " Fix: wait 5-15 min; airc caches probes so health checks do not deepen the throttle\n"
elif [ "$_gh_state" = "env_token_invalid" ]; then
printf " [BLOCKED] GH_TOKEN is set but invalid\n"
printf " Fix: unset/fix GH_TOKEN, then retry\n"
else
printf " [BLOCKED] gh authenticated\n"
printf " Fix: gh auth login -s gist\n"
fi
issues=$((issues+1))
elif ! gh auth status 2>&1 | grep -qiE '(scopes|token scopes):.*\bgist\b'; then
elif ! gh auth status 2>&1 | grep -qiE '(scopes|token scopes):.*\bgist\b'; then
printf " [BLOCKED] gh authed but missing 'gist' scope (room substrate needs it)\n"
printf " Fix: gh auth refresh -s gist\n"
issues=$((issues+1))
Comment on lines +403 to +407
c = json.load(open('$CONFIG'))
print(c.get('channel_gists', {}).get('$primary_chan', ''))
except Exception:
pass
" 2>/dev/null)
Comment thread uninstall.sh
Comment on lines +142 to +150
if [ -x "$CLONE_DIR/.venv/bin/python" ]; then
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$CLONE_DIR/.venv/bin/python" -m airc_core.codex_install --codex-home "$HOME/.codex" uninstall-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
done
fi
fi
fi
joelteply and others added 2 commits May 5, 2026 10:31
…kill it (#522)

* fix(attach): detach transport via setsid -f so Monitor exit doesn't kill it

Closes the third Windows blocker tracked on #511.

After #518 (empty-value argparse) and #521 (--attach identity leak),
Windows + Claude Code Monitor + `airc join --attach` still produced no
working transport. `airc status` reported `airc process: not running`
and `airc msg` refused with `monitor down` even though the canonical
events ("Hosting as 'continuum-b69f'", "Found canonical gist") landed
in the transport log. The transport-log mtime stops within a couple of
seconds of the Monitor's `wsl bash -lc 'airc join --attach'` returning,
exactly when SIGHUP would cascade through the launcher's pgroup.

Root cause: `_join_spawn_transport_for_attach` started the transport
as `( ... ) >>"$_log" 2>&1 &` — same session and pgroup as the
launcher bash. On Windows, the launcher is the controlling-terminal
session leader; when it returns, the kernel SIGHUPs the entire pgroup.
The transport bash + airc_core.handshake accept_one + bearer_cli recv
loops + reminder_timer_loop + _mesh_rediscover_loop all die before
they ever write `airc.pid`. Foreground bash on Linux/Mac doesn't hit
this because the user's interactive shell stays alive holding children
open. (See the post-65adceb retest in #511 — transport-log frozen at
"Found canonical gist", no fresh writes for 12+ hours.)

Fix: detach the transport into a new session+pgroup with `setsid -f`
on systems where it's available. The kernel-cascade SIGHUP from
launcher exit no longer reaches the transport. Watchdog reworked to
rely solely on the `airc.pid` file (written by airc itself once the
transport reaches the bearer-spawn point); `setsid -f` returns 0
immediately after fork, so `$!` is no longer a useful liveness signal.

Verified end-to-end on Windows 11 + WSL2 + Claude Code Monitor:

  $ airc join --attach   (via Monitor)
  $ pgrep -af airc
  30211 /bin/bash /home/joel/.airc-src/airc join
  30584 ...handshake accept_one ...
  30591 ...bearer_cli recv ...
  $ airc status
  airc process: AIRC background process running for scope (PID 30211)
  $ airc msg --channel general "..."
  → #general (broadcast)

Pre-fix: same sequence produced zero airc processes after Monitor's
bash returned.

Fallback: AIRC_NO_DETACH=1 forces the inline `( ... ) &` form for
harness tests that want to reap the transport via the parent process
tree. macOS where setsid may be missing falls back to the inline form
automatically (Mac doesn't hit the SIGHUP cascade because the
launcher shell is foreground and stays alive).

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

* Clarify attach transport detach comments

---------

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

`airc peers` had two render paths in cmd_peers (cmd_rooms.sh:570):

1. PEERS_DIR empty → call airc_core.collaboration peers-fallback,
   which scans messages.jsonl and lists broadcast peers seen in the
   last 600s. Works.
2. PEERS_DIR has *.json → call the inline python listing, which
   ONLY enumerates paired records from peers/*.json. Recent broadcast
   peers from messages.jsonl were silently dropped from this path.

Effect: when even one stale paired record exists (the integration-test
'tr' peer, or an old vhsm-d1f4 from a prior pair handshake that never
got cleaned up), `airc peers` lists ONLY the stale records and hides
genuinely-active broadcast peers. Codex on Mac reproduced this
empirically: `peers does NOT list continuum-8e97; only stale
vhsm-d1f4` even though continuum-8e97 was sending broadcast messages
into #cambriantech every 30s within the recent window. peer presence
metadata then "lags gh-room reality" — the description Codex used.

Same data was already accessible via the messages.jsonl scan that
last_seen does for paired records' age column; just didn't fan out to
non-paired senders.

Fix: after rendering paired records, walk last_seen for any sender NOT
already in the rendered set, filter out self + the 'airc' sentinel +
anyone outside the same 600s window the empty-dir fallback uses, and
print them in the same shape peers-fallback prints them. Listings are
now consistent regardless of whether stale paired records exist.

Verified live on Windows + WSL2:
- empty PEERS_DIR: peers-fallback path unchanged → broadcast peers
  listed (pre-existing behavior, kept).
- PEERS_DIR with stub-peer-test.json + airc-8a5e broadcasting in
  #cambriantech: pre-fix listed ONLY stub-peer-test; post-fix lists
  BOTH stub-peer-test (paired record) AND airc-8a5e (broadcast room).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 5, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 64 out of 64 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uninstall.sh
Comment on lines +142 to +150
if [ -x "$CLONE_DIR/.venv/bin/python" ]; then
if out=$(PYTHONPATH="$CLONE_DIR/lib${PYTHONPATH:+:$PYTHONPATH}" "$CLONE_DIR/.venv/bin/python" -m airc_core.codex_install --codex-home "$HOME/.codex" uninstall-hooks 2>&1); then
if [ -n "$out" ]; then
printf '%s\n' "$out" | while IFS= read -r line; do
ok "Codex AIRC hook: $line"
done
fi
fi
fi
Comment on lines +35 to +38
if "codex_hooks" in text:
return False
lines = text.splitlines()
for idx, line in enumerate(lines):
Comment on lines +317 to +321
def _load_seen_sigs(limit: int = 5000) -> None:
try:
with open(local_log, encoding="utf-8", errors="replace") as f:
lines = f.readlines()[-limit:]
except Exception:
Comment on lines +26 to +30
def _recent_sigs(path: str, limit: int = TAIL_LIMIT) -> set[str]:
try:
with open(path, encoding="utf-8", errors="replace") as f:
lines = f.readlines()[-limit:]
except (FileNotFoundError, OSError):
fix(codex): make join own detached startup

Public Codex flow now uses plain airc join. The shell dispatch detects Codex for join/resume and routes through the detached adapter, while the spawned child is guarded from recursive detach. Fresh scopes no longer fail before init.\n\nAlso emit join/part lifecycle notices through the normal message protocol as system events instead of local attach-only appends, and preserve the broadcast-peer listing fix from #523 in this branch.
@joelteply
joelteply merged commit 02c7f06 into main May 5, 2026
12 checks passed
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.

2 participants