Skip to content

fix(monitor): force python UTF-8 in monitor_formatter (kills silent crash on unicode) - #413

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-monitor-formatter-utf8
May 2, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-monitor-formatter-utf8

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel's 'your monitor code is the problem' was this: monitor_formatter invocation in airc:1524 was python -u without -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 utf8 and their Monitor wakes reliably; airc's own monitor_formatter (no -X utf8) drops events. Same flag fixes at source.

🤖 Generated with Claude Code

…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]>
Copilot AI review requested due to automatic review settings May 2, 2026 16:29
@joelteply
joelteply merged commit 23c814d into canary May 2, 2026
8 checks passed
@joelteply
joelteply deleted the fix/airc-monitor-formatter-utf8 branch May 2, 2026 16:29

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

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 utf8 to the Python invocation used by the monitor_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 thread airc
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"
Comment thread airc
# 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]>
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