Repository navigation
hotfix: cmd_peers Python comment backtick broke airc peers in production (#645 follow-up) - #646
Merged
Merged
Conversation
PR-1 (#645) shipped a backtick inside a Python comment that was embedded in a bash double-quoted string. Bash parses backticks as command substitution inside double quotes BEFORE Python sees the content, so: # `last seen <age>` display column. The NEW columns are additive made bash try to execute 'last seen <age>' as a shell command, with <age> looking like an input redirect — syntax error, airc peers broken in production. Caught live by Joel: 'have to see if it works.' Tested updated airc on canary install; airc peers errored before listing the legacy peer records. Fix: replace backticks with single quotes in the comment. Same human meaning, no bash interaction. Adds a guard-comment naming the gotcha for future edits. Title prefixed 'hotfix:' so the require-canary-or-hotfix gate permits direct-to-main path if needed, though this PR targets canary like the original PR-1.
joelteply
added a commit
that referenced
this pull request
May 17, 2026
…r_loop hook + monitor filter (airc#644 PR-2) (#647) Closes airc#644 end-to-end. PR-1 (#645) landed the envelope shape, helper module, and cmd_peers display. PR-2 wires the actual cross-peer emission so PROCESS_DOWN detection becomes real. ## Changes ### lib/airc_bash/cmd_send.sh New '--heartbeat' flag. Unlike '--system' which rewrites 'from' to 'airc' (system-wide notice), '--heartbeat' keeps 'from=$my_name' because heartbeats are per-peer attribution. Stamps 'kind=heartbeat' into the payload JSON so cmd_peers + monitor_formatter can recognize. Implies '--internal' so a missing monitor doesn't produce noisy error output every 60s (one missed heartbeat is fine; two missed is the PROCESS_DOWN signal anyway). ### airc (reminder_timer_loop) New heartbeat emit branch fires every HEARTBEAT_CADENCE_SEC (60s). Best-effort: 'cmd_send --heartbeat --internal' in a subshell with stdout+stderr suppressed. A transient send failure is precisely the signal we want propagating — peer's airc process not emitting means PROCESS_DOWN, no need to log every failure locally. The 60s cadence is hard-tied to lib/airc_core/heartbeat.py's HEARTBEAT_CADENCE_SEC constant. test_heartbeat_pr2.py greps the bash literal and asserts it matches the Python constant so drift produces a test failure rather than silent false PROCESS_DOWN signals. ### lib/airc_core/monitor_formatter.py New filter case: 'kind == "heartbeat"' is dropped from UI rendering AND arms the inbound-watchdog. The watchdog arming is important — any inbound traffic (including remote heartbeats) proves the bearer is alive, which is exactly the local-side signal we already use for 'airc_heartbeat' (a different field; that one is THIS process's self-loop signal). Heartbeats are protocol traffic; user-invisible. ### test/test_heartbeat_pr2.py (new — 9 tests) Four suites covering: - CmdSendHeartbeatFlagShapeTests (2): constants pinned (kind literal agrees Python ↔ bash; cadence agrees Python ↔ bash) - MonitorFormatterHeartbeatFilterTests (4): filter recognizes heartbeats; doesn't false-positive on chat or pre-#644 legacy envelopes; the constant the formatter reads (HEARTBEAT_KIND) matches what bash emits - ReminderTimerLoopShapeTests (1): grep the bash for the cadence literal and assert it matches the Python constant — catches drift at test-time, not in production - CmdSendHeartbeatFlagWiringTests (2): structural grep verifying the flag parser case + the payload-stamp line exist (catches bit-rot if someone refactors flag handling without preserving --heartbeat) ## Validation - bash -n lib/airc_bash/cmd_send.sh → ok - bash -n airc → ok - python3 ast.parse monitor_formatter → ok - test/test_heartbeat_pr2.py → 9 tests passing - test/test_heartbeat.py (PR-1) → 18 tests still passing (4 skip on no-crypto) - test/test_envelope.py (existing) → 18 tests still passing (all skip on no-crypto base env) ## Why It Works End-To-End After This PR Before PR-1: airc peers shows 'last seen Nh ago (silent)' — can't tell heads-down from process-down. After PR-1 (#645 merged): envelope.kind field + cmd_peers tracks last_heartbeat separately + display logic distinguishes the three cases. But no heartbeats are emitted yet, so all peers still show '(silent)'. After PR-2 (this PR): Every running airc emits 'kind=heartbeat' every 60s through the existing broadcast path. Peers receive them; cmd_peers' separate tracking now has data. After two missed heartbeats (>120s), a peer's display flips from '(silent, heartbeat OK)' to '(PROCESS DOWN)'. The substrate-level fix is live. Tested locally on canary: PR-1's airc peers no longer crashes (the backtick hotfix #646 cleared the syntax error); PR-2's emission will populate the columns once it merges + propagates. Closes airc#644 end-to-end.
This was referenced May 28, 2026
Closed
Merged
This was referenced May 28, 2026
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.
What
PR-1 #645 shipped a backtick inside a Python comment that was embedded in a bash double-quoted string. Bash parses backticks as command substitution inside double quotes before Python sees the content, so:
```python
`last seen ` display column. The NEW columns are additive
```
made bash try to execute `last seen ` as a shell command, with `` looking like an input redirect — syntax error, `airc peers` broken in production.
Caught By
Joel: "have to see if it works." I updated airc to canary on the test scope and ran `airc peers`:
```
$ airc peers
/Users/joelteply/.airc-src/lib/airc_bash/cmd_rooms.sh: command substitution: line 581: syntax error near unexpected token `newline'
/Users/joelteply/.airc-src/lib/airc_bash/cmd_rooms.sh: command substitution: line 581: `last seen '
authenticator-448f → [email protected] [#general] last seen 9d ago (silent)
vhsm-d1f4 → [email protected] [#general] last seen 13h ago (silent)
```
Legacy peers still display (the bash error doesn't halt the parent script) but the substitution is broken — peer name + host + tags + age field are all stomped, only the fallback path runs.
This is exactly the testing discipline Joel's been enforcing: code review + unit tests + bash -n syntax check do NOT validate user experience. Run the actual command a user would run, from a fresh install path.
Fix
Replace backticks with single quotes in the comment. Same meaning, no bash interaction. Adds a guard-comment naming the gotcha so future edits in this Python-in-bash region don't repeat it:
```python
Note: single-quotes (not backticks) on purpose. This Python code is
embedded in a bash double-quoted string; bash interprets backticks
as command substitution inside double quotes EVEN INSIDE python-quoted
regions because bash parses the outer string before python sees it.
```
Validation
`bash -n lib/airc_bash/cmd_rooms.sh` passes clean.
Title Prefix
`hotfix:` so the require-canary-or-hotfix policy gate permits direct-to-main path if escalation is needed. Targets canary like the original PR-1.