Repository navigation
fix(whois): walk sibling sidecar scopes (closes #134) - #135
Conversation
Pre-fix: cmd_whois only consulted the primary scope's host / local-peer-file / cross-peer-via-host SSH lookups. A peer in the #general sidecar but not the primary project room returned "no record" — even after airc peers (post-#124) already showed them across rooms. JOIN events in the sidecar emitted names the IRC-style mental model said should be reachable, but whois 404'd. Post-fix: cmd_whois walks sibling scopes (.airc + .airc.<room>) using the same prefix-detection pattern cmd_peers uses. Each scope tries its own host / local-peer-file / cross-peer-via-host lookups; first hit wins. Per-scope logic factored into _whois_in_scope so primary and siblings share one code path. The cross-peer-via-host SSH path uses the SCOPE's identity/ssh_key (not the primary scope's), so a sidecar joiner can authenticate to its sidecar host even when the primary scope is paired with a different host on different keys. Test (scenario_whois_cross_scope) covers: - sidecar local peer found from primary scope (the vhsm bug) - sidecar HOST resolved from primary scope - primary host still resolves (no regression) - unknown peer still 404s after exhausting all scopes - symmetric: sidecar→primary lookup also works No wire-format change; backward compatible with single-scope users.
There was a problem hiding this comment.
Pull request overview
Fixes airc whois in multi-scope setups by searching across sibling sidecar scopes (matching the cross-scope behavior already added to airc peers), closing issue #134.
Changes:
- Refactors
cmd_whoisto delegate per-scope resolution to_whois_in_scopeand then walk sibling scopes if not found in the current scope. - Ensures cross-peer SSH lookups use the scope-specific SSH identity (per-scope
identity/ssh_key). - Adds an integration test scenario covering cross-scope
whoisresolution.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airc |
Updates cmd_whois to search across sibling scopes and factors lookup logic into _whois_in_scope. |
test/integration.sh |
Adds scenario_whois_cross_scope and wires it into the test runner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Strip a trailing .<word> to recover the primary prefix. Mirrors the | ||
| # detection in cmd_peers (#124) so .airc / .airc.general both resolve | ||
| # to .airc as the prefix; in tests we see state / state.general → state. | ||
| prefix=$(printf '%s' "$self_base" | sed -E 's/\.[a-z0-9-]+$//') |
There was a problem hiding this comment.
The prefix derivation sed -E 's/\.[a-z0-9-]+$//' will turn the primary scope basename .airc into an empty string (because it strips the entire .airc). That makes the sibling glob expand to $parent/ and $parent/.*, causing whois to scan essentially the whole parent directory and potentially return incorrect matches. Please mirror cmd_peers’ anchored prefix detection (airc:4203-4205), so .airc stays .airc while .airc.general becomes .airc.
| # Strip a trailing .<word> to recover the primary prefix. Mirrors the | |
| # detection in cmd_peers (#124) so .airc / .airc.general both resolve | |
| # to .airc as the prefix; in tests we see state / state.general → state. | |
| prefix=$(printf '%s' "$self_base" | sed -E 's/\.[a-z0-9-]+$//') | |
| # Strip only a sidecar suffix to recover the primary prefix. Mirrors | |
| # the anchored detection in cmd_peers (#124): .airc stays .airc, | |
| # .airc.general becomes .airc, and state.general becomes state. | |
| prefix="$self_base" | |
| if [[ "$self_base" =~ ^(.+)\.[a-z0-9-]+$ ]]; then | |
| prefix="${BASH_REMATCH[1]}" | |
| fi |
| for sibling in "$parent/$prefix" "$parent/$prefix".*; do | ||
| [ -d "$sibling" ] || continue | ||
| [ "$sibling" = "$AIRC_WRITE_DIR" ] && continue | ||
| [ -f "$sibling/config.json" ] || continue |
There was a problem hiding this comment.
Sibling-scope discovery for whois currently accepts any $parent/$prefix.* directory that has config.json. cmd_peers additionally requires room_name + peers/ to avoid unrelated/stale dirs like .airc.bak polluting cross-scope behavior (airc:4207-4210). Consider applying the same gating here so whois doesn’t consult old/backup scopes and return stale identities.
| [ -f "$sibling/config.json" ] || continue | |
| [ -f "$sibling/config.json" ] || continue | |
| [ -f "$sibling/room_name" ] || continue | |
| [ -d "$sibling/peers" ] || continue |
Bug
vhsm-d1f4 (paired in #useideem primary + #general sidecar) saw a JOIN event for continuum-b741 in #general. Then:
Issue #134.
Root cause
cmd_whoisonly consulted the primary scope's lookups. A peer who's only in a sidecar scope returned "no record" — even thoughairc peers(post-#124) already aggregates across scopes.Fix
Walk sibling sidecar scopes using the same prefix-detection pattern cmd_peers uses. Per-scope lookup logic factored into
_whois_in_scope(host name, local peer file, cross-peer-via-host SSH). Primary scope tried first, siblings second; first hit wins.Cross-peer SSH uses the scope's ssh_key (not the primary's), so a sidecar joiner can authenticate to its sidecar host even when the primary scope is paired with a different host on different keys.
Test
scenario_whois_cross_scope(6 assertions):Adjacent tests still green:
whois(5/5),identity(19/19),kick(12/12).Compatibility
No wire-format change. Single-scope users get the identical fast path (primary scope hit ends the walk). Empty sibling list = no-op.