Repository navigation
fix(monitor): force python UTF-8 in monitor_formatter (kills silent crash on unicode) - #413
Merged
Merged
Conversation
…ent crash) Joel's "your monitor code is the problem" — the airc bash invocation of monitor_formatter at line 1524 was missing -X utf8. On Windows (cp1252 default) and any non-UTF-8 macOS terminal, print() of a line containing unicode (→, ✓, ⚠ — all of which we use in airc system messages + peer chat with arrows) raises UnicodeEncodeError. The crash kills the formatter mid-stream. Bash sees the pipe close, restarts the bearer/formatter pair, and the missed event is silently lost. Symptom: substrate writes events to messages.jsonl correctly, formatter "runs," but Claude Code Monitor surfaces nothing. Caught 2026-05-02 after b69f added `python -X utf8` to their tail-direct workaround command — their Monitor wakes reliably; mine (running airc-join's monitor_formatter) drops events. Same single flag fixes it at the SOURCE rather than each operator needing to hand-roll a utf8 tail pipeline. This is bug #6 of tonight's airc bios sweep — the LAST silent-failure mode in the receive surface. After this PR + the previous 18: - airc receive path: loud all the way through - formatter: utf8-safe on all platforms, doesn't crash on unicode - daemon: takes over after interactive death + status doesn't lie - self-heal: 60s rotation auto-rediscover Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR attempts to harden the monitor pipeline by changing how airc launches airc_core.monitor_formatter, with the goal of preventing locale-dependent Unicode output failures in monitor sessions.
Changes:
- Adds
-X utf8to the Python invocation used by themonitor_formatter()shell wrapper. - Expands the inline comment above that wrapper to document the suspected Unicode crash scenario and why the flag was added.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1524
to
+1538
| # -X utf8 forces UTF-8 mode regardless of locale (cp1252 on Windows | ||
| # default + non-UTF-8 macOS terminals). Without it, monitor_formatter | ||
| # CRASHES SILENTLY on print() of any line containing unicode (→, ✓, | ||
| # ⚠ — all of which we use in airc system messages + peer chat). The | ||
| # crash kills the formatter mid-stream; bash sees the pipe close, | ||
| # restarts the bearer/formatter pair, and the missed event is | ||
| # silently lost. Symptom: substrate writes events to messages.jsonl | ||
| # correctly, formatter "runs," but Claude Code Monitor surfaces | ||
| # nothing. Joel's "your monitor code is the problem" was exactly | ||
| # this — caught 2026-05-02 after b69f's tail-direct workaround | ||
| # (which uses `python -X utf8`) wakes their AI session reliably | ||
| # while airc's own monitor_formatter (no -X utf8) drops events. | ||
| # Same fix here closes the gap at the SOURCE rather than relying on | ||
| # each operator to add their own tail-pipeline. | ||
| "$AIRC_PYTHON" -u -X utf8 -m airc_core.monitor_formatter --peers-dir "$PEERS_DIR" --my-name "$my_name" |
| # while airc's own monitor_formatter (no -X utf8) drops events. | ||
| # Same fix here closes the gap at the SOURCE rather than relying on | ||
| # each operator to add their own tail-pipeline. | ||
| "$AIRC_PYTHON" -u -X utf8 -m airc_core.monitor_formatter --peers-dir "$PEERS_DIR" --my-name "$my_name" |
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]>
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.
Joel's 'your monitor code is the problem' was this:
monitor_formatterinvocation in airc:1524 waspython -uwithout-X utf8. On Windows (cp1252 default) + non-UTF-8 macOS terminals, print() of any line containing unicode (→, ✓, ⚠ — all of which airc system messages + peer chat use heavily) raises UnicodeEncodeError, kills formatter mid-stream, bash respawns, event silently lost.Caught 2026-05-02 — b69f's tail-direct workaround added
python -X utf8and their Monitor wakes reliably; airc's ownmonitor_formatter(no -X utf8) drops events. Same flag fixes at source.🤖 Generated with Claude Code