Skip to content

fix(peers): show recent broadcast peers even when paired records exist - #523

Merged
joelteply merged 1 commit into
canaryfrom
ce/peers-include-broadcast-from-msgs
May 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
ce/peers-include-broadcast-from-msgs

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Caught by codex during the post-#522 noisy validation pass

Codex on Mac reported during the multi-agent validation:

peers does NOT list continuum-8e97; only stale vhsm-d1f4, so peer presence metadata is still lagging gh-room reality

continuum-8e97 was actively broadcasting to #cambriantech (every 30s, within the recent window), but airc peers on Mac kept showing only the stale vhsm-d1f4 paired record from a prior pair handshake.

Root cause

cmd_peers in lib/airc_bash/cmd_rooms.sh has two render paths:

  1. PEERS_DIR empty → falls through to airc_core.collaboration peers-fallback, which reads messages.jsonl and lists everyone seen in the last 600s. Works correctly.
  2. *PEERS_DIR has .json → uses the inline python listing, which only enumerates paired records from peers/*.json. Broadcast-only peers from messages.jsonl are silently dropped.

So one stale paired record is enough to hide every genuinely-active broadcast peer.

The same messages.jsonl scan was already happening for last_seen (the age column on paired peers); the data just wasn't fanned out to non-paired senders.

Fix

After rendering paired records, walk last_seen for any sender that wasn't already rendered, filter out self + the airc sentinel + anyone outside the 600s window, and print them in the same shape the empty-dir fallback uses.

Verified live on Windows + WSL2

$ airc peers
  stub-peer-test → test-host-stub   [#cambriantech]   last seen never (no recorded activity)
  airc-8a5e → broadcast room   [(from signed messages.jsonl)]   last seen 7m ago

Pre-fix the same state listed only stub-peer-test. Post-fix lists both — the stale paired record AND the recent broadcast peer.

Test plan

  • PEERS_DIR with stale json + broadcasting peer → both visible (verified above)
  • PEERS_DIR empty → unchanged (peers-fallback path is untouched)
  • Mac: codex's airc peers should now show continuum-8e97 after pulling this branch + a broadcast within 600s
  • CI: bash -n already passes; existing peers-fallback integration test stays green

🤖 Generated with Claude Code

`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:02
@joelteply

Copy link
Copy Markdown
Contributor Author

Codex review: LGTM. Verified the root cause matches the Mac observation: existing stale peer records bypassed the broadcast-only fallback, so active gh-room peers were hidden. Local checks passed: bash -n lib/airc_bash/cmd_rooms.sh and python3 test/test_collaboration.py. CI is clean except expected skipped integration-suite. Merging to canary.

@joelteply
joelteply merged commit 5991086 into canary May 5, 2026
8 checks passed
@joelteply
joelteply deleted the ce/peers-include-broadcast-from-msgs branch 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

Fixes airc peers so recent broadcast-only peers (derived from messages.jsonl) are still shown even when peers/*.json paired records exist, preventing stale paired records from masking active room participants.

Changes:

  • Pass the local identity into the inline cmd_peers Python renderer via AIRC_PEERS_MY_NAME so broadcast peers can exclude self.
  • Track rendered paired peer names, then append any recent broadcast-only senders (within a 600s window) that weren’t already listed.

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

Comment on lines +678 to +684
my_name = os.environ.get('AIRC_PEERS_MY_NAME', '')
RECENT_WINDOW = 600
broadcast_only = []
for who, ts in last_seen.items():
if who in rendered: continue
if who == my_name or who == 'airc': continue
if now - ts >= RECENT_WINDOW: continue
Comment on lines +681 to +688
for who, ts in last_seen.items():
if who in rendered: continue
if who == my_name or who == 'airc': continue
if now - ts >= RECENT_WINDOW: continue
broadcast_only.append((who, ts))
broadcast_only.sort(key=lambda kv: kv[1], reverse=True)
for who, ts in broadcast_only:
print(f' {who} → broadcast room [(from signed messages.jsonl)] last seen {_fmt_age(ts)}')
Comment on lines +672 to +688
# Also surface broadcast-only peers (no DM-paired record). Pre-fix,
# stale paired records masked recent peers entirely — codex on Mac saw
# 'vhsm-d1f4' (an old paired host) but not 'continuum-8e97' even after
# multiple broadcast messages within the recent window. Mirror the
# behaviour of the empty-peers-dir fallback path so listings remain
# consistent regardless of whether stale records exist.
my_name = os.environ.get('AIRC_PEERS_MY_NAME', '')
RECENT_WINDOW = 600
broadcast_only = []
for who, ts in last_seen.items():
if who in rendered: continue
if who == my_name or who == 'airc': continue
if now - ts >= RECENT_WINDOW: continue
broadcast_only.append((who, ts))
broadcast_only.sort(key=lambda kv: kv[1], reverse=True)
for who, ts in broadcast_only:
print(f' {who} → broadcast room [(from signed messages.jsonl)] last seen {_fmt_age(ts)}')
joelteply added a commit that referenced this pull request May 5, 2026
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 added a commit that referenced this pull request May 5, 2026
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.
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