Repository navigation
feat(monitor): filter display by subscribed_channels (#9 from QA pass) - #243
Conversation
Resolves continuum-b741's #9 finding: 'airc msg --channel X' succeeds even when sender + recipient aren't subscribed to X, because the channel field was purely a display tag with no filtering. From a trust-modeling POV that meant channels-as-permission-boundary didn't exist. ## Fix (display-side) monitor_formatter.py: read subscribed_channels from config.json each inbound line (fresh read so join/part during session takes effect immediately). If a message's channel field isn't in our subscribed set, skip display. Bypasses (always show, regardless of subscription): - DMs addressed to us (presence in `to` CSV) — a peer reaching out across channels still surfaces - System events (from='airc' or 'sys') — joins/parts/[HOST EVICTED] are operational, not channel-scoped Opt-in semantics: subscribed_channels=None or empty list → show everything (pre-Phase-2B configs unaffected; brand-new scopes before cmd_join writes anything won't see "subscribed to nothing → display nothing" footgun). ## What this is NOT Wire-level filtering. The host's messages.jsonl contains EVERY channel's traffic; any peer with SSH access can read all channels even when subscribed to none. This is display-only; if you need real channel-as-permission, the host needs server-side per-channel filtering on the SSH-tail. That's a much bigger change (Phase 3). Documented in the channel display comments so it's clear what the filter does + doesn't promise. ## Verification python ast.parse: clean test/integration.sh tabs: 19/0 ✓ test/integration.sh general_sidecar_default: 10/0 ✓ Manual e2e via mesh: pending — needs a peer to send a tagged message to a channel I'm not subscribed to + verify it doesn't display. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Implements the QA-requested “subscribed_channels” display filter in the monitor formatter so the UI only shows messages for channels the user is subscribed to (while still surfacing DMs to the user and system/operational events).
Changes:
- Add
subscribed_channels()helper to read the subscription set from config at runtime. - Skip printing inbound messages whose
channelis not insubscribed_channels, with bypasses for DMs addressed to the current user and for system events (from=airc/sys).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| v = json.load(open(config_path)).get("subscribed_channels") | ||
| if isinstance(v, list) and v: | ||
| return set(v) |
There was a problem hiding this comment.
subscribed_channels() reads config with json.load(open(config_path)). Because this helper is called inside the main stdin loop, repeatedly opening the file without a context manager can keep file descriptors alive longer than intended (and is especially risky on non-CPython runtimes). Use with open(config_path) as f: (or a small shared _load_config() helper) so the file is always closed promptly.
| subs = subscribed_channels() | ||
| if subs is not None and fr not in ("airc", "sys"): | ||
| addressed_to_me = bool(to) and to not in ("", "all") and current_name() in to.split(",") | ||
| if line_channel and line_channel not in subs and not addressed_to_me: | ||
| continue |
There was a problem hiding this comment.
In the hot path, this adds extra config reads: subs = subscribed_channels() loads config, and addressed_to_me calls current_name() (which also loads config) even though current_name() was already called earlier in the same iteration for own-send filtering and ping handling. Consider computing my_current = current_name() once per line and reusing it for all checks to reduce repeated disk I/O + JSON parsing.
| subs = subscribed_channels() | |
| if subs is not None and fr not in ("airc", "sys"): | |
| addressed_to_me = bool(to) and to not in ("", "all") and current_name() in to.split(",") | |
| if line_channel and line_channel not in subs and not addressed_to_me: | |
| continue | |
| if fr not in ("airc", "sys"): | |
| subs = subscribed_channels() | |
| if subs is not None: | |
| my_current = current_name() | |
| addressed_to_me = bool(to) and to not in ("", "all") and my_current in to.split(",") | |
| if line_channel and line_channel not in subs and not addressed_to_me: | |
| continue |
| # Phase 2C+ (continuum-b741's #9 from QA pass 2026-04-28): | ||
| # filter display by subscribed_channels. If the user is | ||
| # subscribed to specific channels and this message is on a | ||
| # different channel, skip display. DMs addressed to us bypass | ||
| # the filter (a peer reaching out across channels still | ||
| # surfaces). System events ('airc'/'sys' from-field) also | ||
| # bypass — joins/parts/[HOST EVICTED] are operational, not | ||
| # channel-scoped. Wire-level all peers still see all messages | ||
| # in messages.jsonl; this is display-only. | ||
| subs = subscribed_channels() | ||
| if subs is not None and fr not in ("airc", "sys"): | ||
| addressed_to_me = bool(to) and to not in ("", "all") and current_name() in to.split(",") | ||
| if line_channel and line_channel not in subs and not addressed_to_me: | ||
| continue |
There was a problem hiding this comment.
This introduces new channel display-filtering semantics (including DM/system-event bypass) but there doesn't appear to be an integration test asserting the formatter output is suppressed for unsubscribed channels. Adding a scenario in test/integration.sh that (1) sets subscribed_channels to a subset, (2) sends messages on both channels, and (3) asserts only the subscribed channel (plus DM-to-me + system events) shows up in the captured connect output would protect against regressions.
…ersists scenarios (#259) * fix(ci): restore 'all)' case in integration.sh dispatch (#244 / CI failure) #239 deleted scenario_peers_cross_scope and scenario_whois_cross_scope because those tests exercised the pre-Phase-2B.3 sidecar peer-walk that was removed. The Python regex used to scrub them — `if 'X' not in line` — was too aggressive: it matched the whole `all)` case line which contained both scenario names in its scenarios-to-run list. Result: `all)` deleted entirely. CI's no-arg invocation `bash test/integration.sh` then hit `*)` → exit 2 → push-to-canary integration job failed. ## Fix Restore an `""|all)` case (matches both no-arg and explicit `all`) with the proper scenario list MINUS the two deleted ones. Preserve the `*)` usage block as the unrecognized-scenario fallback. Verification: tabs 19/0; manual no-arg + 'all' invocation kicks off the full sweep instead of bailing. Closes the canary push integration-suite failure on 75e7bb5. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci): delete pre-2B.3 send_room_flag + part_keeps_sidecar + part_persists scenarios Same root cause as the cross_scope deletions in #239: these three scenarios test sibling-scope semantics that Phase 2B.3 (#227) deleted. Running them on canary HEAD fails because: - send_room_flag: expects --room to re-exec into .airc.<name> sibling scope. Post-#227, --room is a channel-tag alias for --channel; no scope switch. - part_keeps_sidecar: expects a separate sidecar process for #general. Post-#227, no sidecar process exists; #general is a subscribed_channel in the same scope. - part_persists: same. The 'sidecar' it tries to part isn't there. Coverage of the new behavior: - Channel-tag stamping: tabs / queue / status scenarios verify envelope.channel - subscribed_channels filter display: monitor_formatter + #243 path - general_sidecar_default: rewritten in #227 to verify subscribed_channels includes 'general' AND no .general dir is created. Verification: tabs 19/0; general_sidecar_default 10/0; away 5/0; no syntax errors. --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…closes #152) (#262) The PS port was 2968 lines — a parallel codebase to the bash 'airc'. After Phase 1+2 substrate landed (PRs #222-#243+) it lagged ~100 commits behind canary because every fix had to be hand-ported and never was. Issue #152 tracked the drift. ## Resolution Stop maintaining a parallel codebase. Git Bash ships with Git for Windows (install.ps1 already ensures git is installed). The new airc.ps1 is an 80-line shim: 1. Locate bash.exe (PATH → standard Git install paths → fallback). 2. Exclude System32\bash.exe (WSL Linux bash can't see Windows paths). 3. Forward all args via @Args splat to bash 'airc'. 4. Print clear install instructions if Git Bash is missing. ## Net effect airc.ps1: 2968 → 80 lines (-2888) Windows users running 'airc' (whether via airc.cmd → pwsh → airc.ps1 or directly via airc.ps1) now execute the same bash binary as Mac/Linux users. Zero drift forever. Every Phase 1+2 substrate fix instantly applies on Windows. ## What this requires - Git for Windows (provides bash.exe). install.ps1 already installs it. - For users on the OLD airc.ps1 who haven't reinstalled: re-run install.ps1 (or 'curl install.sh | bash' from Git Bash) to pull this change. ## What this drops The parallel PS port's value was 'works without Git Bash'. In practice nobody ran without Git Bash because install.ps1 ships it as a hard dep. The maintenance burden vastly exceeded the value. Closes #152. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Addresses continuum-b741's QA finding: channel field was display-only, no actual filtering. Now monitor formatter skips inbound lines for channels not in subscribed_channels. DMs to us + system events bypass the filter. Wire-level still all-visible — display-only filter, not security.