Repository navigation
fix(monitor,#406): scope beacon to subscribed channels (kill stale-file false-positive) - #406
Merged
Merged
Conversation
…s (kill stale-file false-positive) Self-fix for #404. The beacon iterated ALL bearer_state*.json files including stale files from previously-subscribed channels (test rooms left weeks ago, e.g. bearer_state.useideem.json from Apr 29 with last_recv_ts: 1777446869 = 80hrs prior). MAX over the set picked the stale file's positive ts when current channels' bearers had only just opened (last_recv_ts: null). Result: false 80hr alarm on a fresh restart. Caught LIVE 2026-05-02: my freshly-rejoined airc fired beacon "288919s silent" 25s after start because bearer_state.useideem.json from 80hrs prior won the MAX over current channels' nulls. Fix: read CONFIG's subscribed_channels list, build a set of expected bearer_state file paths, filter the iteration to only those files. Stale files from old subscriptions get skipped. Falls back to including all files when subscribed_channels is empty (legacy scope preservation). ## Tests - bash syntax clean - Functional repro of the failure case in commit prep: Setup: bearer_state.useideem.json with stale ts, subs=[cambriantech, general] Pre-fix: useideem's stale ts won → beacon fires false 80hr Post-fix: useideem skipped, freshest_recv=0 → falls to bs_mtime fallback which uses recent file mtime correctly ## Pattern Same family as the no-silent-eat sweep tonight: silent failures become loud failures, but the loud signal must be CORRECT, not spurious. False alarms are their own silent failure (alarm fatigue). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR tightens the monitor’s receive-silence beacon so it ignores stale bearer_state*.json files from channels that are no longer subscribed, which fits the codebase’s broader effort to make bearer-state-driven liveness and alerting reliable.
Changes:
- Read
subscribed_channelsfromconfig.jsoninsidereminder_timer_loop(). - Restrict the receive-silence scan to bearer-state files that correspond to currently subscribed channels.
- Preserve the previous “scan everything” behavior when no subscribed-channel list is available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1835
to
+1855
| local sf_path="$AIRC_WRITE_DIR/bearer_state.${sub}.json" | ||
| subs_file_glob="${subs_file_glob}${sf_path}|" | ||
| done < <("$AIRC_PYTHON" -c " | ||
| import json, sys | ||
| try: | ||
| cfg = json.load(open('$CONFIG')) | ||
| for c in cfg.get('subscribed_channels') or []: | ||
| print(c) | ||
| except Exception: | ||
| pass | ||
| " 2>/dev/null) | ||
|
|
||
| for sf in "$AIRC_WRITE_DIR"/bearer_state*.json; do | ||
| [ -f "$sf" ] || continue | ||
| # Filter: skip stale files whose channel is no longer subscribed. | ||
| # If subs list is empty (no subscribed_channels in config), fall | ||
| # back to including all bearer_state files (preserves old behavior | ||
| # for legacy scopes that haven't populated subscribed_channels). | ||
| if [ -n "$subs_file_glob" ]; then | ||
| case "|$subs_file_glob" in | ||
| *"|$sf|"*) ;; # in subs list, keep |
Comment on lines
+1817
to
+1858
| # Build the set of CURRENTLY subscribed channels — only their | ||
| # bearer_state files are relevant. Stale files from previously- | ||
| # subscribed channels (e.g. test rooms left weeks ago) hold | ||
| # ancient last_recv_ts values that, if included in the MAX, would | ||
| # silently rot the beacon's calculation. Caught live 2026-05-02: | ||
| # beacon reported '288919s silent' on a fresh-restart bearer | ||
| # because bearer_state.useideem.json from 80hrs prior had a | ||
| # positive last_recv_ts that won the MAX over the freshly-opened | ||
| # bearer's null. The freshly-opened bearer's correct read should | ||
| # have been "small recv_silent because the file was just written" | ||
| # — but the stale-file's older positive ts beat the fresh file's | ||
| # null and produced false 80hr alarms. | ||
| local subs_file_glob="" | ||
| local sub | ||
| while IFS= read -r sub; do | ||
| [ -n "$sub" ] || continue | ||
| # Strip leading '#' if present in config (#401 tolerance pattern). | ||
| sub="${sub#\#}" | ||
| local sf_path="$AIRC_WRITE_DIR/bearer_state.${sub}.json" | ||
| subs_file_glob="${subs_file_glob}${sf_path}|" | ||
| done < <("$AIRC_PYTHON" -c " | ||
| import json, sys | ||
| try: | ||
| cfg = json.load(open('$CONFIG')) | ||
| for c in cfg.get('subscribed_channels') or []: | ||
| print(c) | ||
| except Exception: | ||
| pass | ||
| " 2>/dev/null) | ||
|
|
||
| for sf in "$AIRC_WRITE_DIR"/bearer_state*.json; do | ||
| [ -f "$sf" ] || continue | ||
| # Filter: skip stale files whose channel is no longer subscribed. | ||
| # If subs list is empty (no subscribed_channels in config), fall | ||
| # back to including all bearer_state files (preserves old behavior | ||
| # for legacy scopes that haven't populated subscribed_channels). | ||
| if [ -n "$subs_file_glob" ]; then | ||
| case "|$subs_file_glob" in | ||
| *"|$sf|"*) ;; # in subs list, keep | ||
| *) continue ;; # stale, skip | ||
| esac | ||
| fi |
joelteply
added a commit
that referenced
this pull request
May 2, 2026
… missing) (#408) The Windows daemon launcher .bat (generated by 'airc daemon install') called the airc binary with NO stdout redirect: "$bash_exe" -c "exec '$airc_bin_unix' connect" So airc's event stream (the entire stdout output: hosting messages, peer joins, channel state, beacons) went to NOTHING. Only the launcher's own restart-record messages reached daemon.err. Symptom (b69f 2026-05-02): airc daemon-installed on Windows; daemon "running" per the registry entry; but `airc daemon log` reports "daemon.log doesn't exist" because no process ever wrote to it. Operator has no way to see what airc actually did — bios-critical substrate is opaque on the very platform users need it most. Fix: 1>> daemon.log 2>> daemon.err on the airc invocation. Now daemon.log captures the actual airc event stream while daemon.err keeps the launcher's restart records separate. Per the global "evidence is for the debugger, not the trash" rule + tonight's bios-resilience sweep (everything airc does must be visible AND self-healing). Daemon mode is the OS-supervised path that survives Claude session ends — but only useful if its logs exist. ## Cumulative effect Tonight's airc sweep now closes: - Receive path silent failures (#400/#401/#402/#403/#404/#406) - Self-heal of host rotation (#405/#407) - Daemon-log invisibility on Windows (THIS PR) Last remaining bios-fragility I know of: `airc daemon install` on Windows succeeded BEFORE this fix — so b69f's daemon may be running right now but wrote nothing all session. After this lands + b69f re-installs, daemon.log will populate. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
May 2, 2026
…once-per-session contract notice (#423) fix(monitor,vuln-a): wrap peer chat in <peer-message> sandbox tags Vuln-A: peer broadcasts contain raw text that reaches the AI session via Claude Code Monitor. An attacker peer can put prompt-injection payloads in `msg` ("ignore previous instructions and ...") and the text arrives indistinguishable from operator commands. Fix: wrap peer-supplied content in <peer-message>...</peer-message> tags before printing to stdout. System events (fr in airc/sys) are trusted and pass through unwrapped. Anthropic's prompt-injection guidance recommends exactly this pattern for any third-party text fed to a model — Claude has been trained on XML-tag input boundaries forever, so the tagged content is naturally treated as data not directives. Plus b69f's suggestion 2026-05-02: emit a one-shot stdout contract notice on the FIRST peer message of the session, so the receiving Claude knows the contract surface. Idempotent — only fires once, subsequent peer messages just get the wrap. NOT a complete defense — sufficiently-crafted payload may still attempt escape — but raises the bar dramatically and aligns with the substrate's "evidence is for the debugger" rule (peer content surfaces, but as DATA, not COMMAND). Pairs with future transport- level peer auth (#418 design) for defense-in-depth. ## Tests - python ast.parse: clean - Manual smoke: send a broadcast → check formatter output has <peer-message> wrap + first-message contract notice - Existing system-events still unwrapped (alice joined, watchdog beacons, etc.) ## Pairs with - #418 (fusion-transport): vuln-A + transport-auth shrinks attack surface from "anyone with gh write" to "anyone on tailnet" - #401, #402, #403, #404, #406, #413, #419, #421: receive-path silent-failure sweep. Vuln-A is the next class — silent injection. Now loud + sandboxed. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
May 2, 2026
…ealth to subscribed_channels (#428) fix(skills,doctor): YAML frontmatter quoting (Codex catch) + scope --health to subscribed_channels Bundle of 3 fixes from the live Codex onboarding session 2026-05-02 (first non-Claude peer on the substrate). Codex's first run as a peer caught real bugs Claude missed — exactly the cross-agent-kind value PR #422's "outsider agent invitation" predicted. ## Codex's catch — YAML frontmatter # comment-coercion Codex's skill loader truncated /airc:join's description at "AND" because the unquoted `#general` in the description value was parsed as a YAML comment. Codex patched skills/join/SKILL.md by wrapping the description in double quotes — same fix applied here, plus an audit of all 24 skills that surfaced one more case (skills/list/SKILL.md, same pattern). Affected: descriptions that contain `#channel` references rendered fine to Claude Code (which is more permissive on the YAML parse) but broke silently on Codex. Wrapping in quotes is the canonical YAML fix and works for both consumers. Two skills touched: - skills/join/SKILL.md (Codex's original patch — preserved here) - skills/list/SKILL.md (audit-found, same pattern) Audit method (for future reviews): for f in skills/*/SKILL.md; do awk '/^description:/||/^argument-hint:/' "$f" \ | grep -E "^(description|argument-hint):[^\"']*#" done ## F1 — `airc doctor --health` scope to subscribed_channels Codex also reported: "sees stale bearer-state files for older channels (#cambriantech, #useideem, and QA rooms)". The probe in #425 globbed every `bearer_state.*.json` on disk including stale files from prior subscriptions (parted rooms, old QA test scopes, etc.). Same fix-shape as #406's beacon scoping: intersect the bearer-state file set with the current subscribed_channels list. Empty subs list falls back to scanning everything — preserves behavior on uninitialized scopes (legacy paths without subscribed_channels populated). Verification in continuum scope (subscribed: ["general"], stale on disk: cambriantech, useideem, 2 qa rooms): Pre-fix: [BLOCKED] #cambriantech — last bearer recv 10307s ago [info] #general — last bearer recv 84s ago [WARN] #qa-cambrian-experiment — never received [WARN] #qa-demo-tomorrow — never received [BLOCKED] #useideem — 303527s ago ✗ Bus DEGRADED on 2 issue(s) (2 warning(s)) Post-fix: [info] #general — last bearer recv 92s ago (idle channel?) ✓ Bus healthy. Same noise-reduction principle as #406; my new --health probe in #425 shipped without applying it. Codex's report exposed the gap on first non-Claude run. ## Why this matters for #422 The PR's outsider-agent invitation said "the bus gets more reliable when more agent kinds depend on it AND contribute back." This commit is the proof-of-concept landing within hours of the invitation: Codex joined → broadcast on the substrate → caught two YAML bugs Claude's parser didn't notice → patched the source. That's the substrate immune response operating across vendors, not just within one team. Pairs with #427 (which unblocked CI so Codex could see green) and #422 (canary→main bundle). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Codex CLI 0.128.0 (the YAML catch was theirs) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
Self-fix for #404. Beacon iterated ALL
bearer_state*.jsonincluding stale files from previously-subscribed channels with positive last_recv_ts. MAX picked the stale value when current channels had null. Result: false 80hr alarm on fresh restart.Live repro 2026-05-02: my freshly-rejoined airc fired
288919s silent25s after start.Fix: filter iteration to bearer_state files for subscribed channels in CONFIG. Stale files skipped. Falls back to including all files when subscribed_channels is empty (legacy scope preservation).
Same family as the no-silent-eat sweep tonight — false alarms are their own silent-failure mode (alarm fatigue).
🤖 Generated with Claude Code