Skip to content

Fix WSL join liveness detection - #512

Merged
joelteply merged 1 commit into
canaryfrom
codex/fix-wsl-join-liveness
May 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
codex/fix-wsl-join-liveness

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • fix monitor liveness so pidfile-owned WSL/Claude Monitor wrappers that show as /path/to/airc still count as alive
  • keep PID-reuse protection by requiring the PID to come from this scope airc.pid and pass kill -0 before accepting the narrower WSL command shape
  • report the verified live PID in status, not just the first pidfile token
  • harden airc version output with printf fallbacks

Fixes #511.

Tests

  • bash -n airc lib/airc_bash/cmd_status.sh lib/airc_bash/cmd_send.sh lib/airc_bash/cmd_update.sh test/integration.sh
  • python3 test/test_scope_repair.py && python3 test/test_monitor_formatter.py
  • ./airc doctor --tests python_units
  • bash test/integration.sh send_dead_monitor_dies
  • bash test/integration.sh monitor_liveness_process_evidence

Windows Retest

After this lands on canary, Windows should run:

airc update --channel canary
airc join
airc version
airc status
airc daemon status
airc msg --channel general "windows ops-ok $(date -u +%FT%TZ)"

Expected: status reports a running AIRC process or formatter for the scope, and msg does not refuse with monitor down while the Monitor stream is alive.

Copilot AI review requested due to automatic review settings May 5, 2026 04:23
@joelteply
joelteply merged commit c73efec into canary May 5, 2026
8 checks passed
@joelteply
joelteply deleted the codex/fix-wsl-join-liveness branch May 5, 2026 04:24

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 addresses incorrect monitor liveness detection on Windows/WSL (notably when running under Claude Code Monitor) so airc status / airc msg don’t falsely report “monitor down” when the join wrapper is actually alive, and it hardens airc version output formatting.

Changes:

  • Add pidfile PID validation helpers in airc to identify live “monitor wrapper” PIDs, including a WSL/Monitor-compatible command-line shape.
  • Update cmd_status to report the verified live PID (rather than the first raw pidfile token) and guard empty PID checks.
  • Add an integration regression test covering WSL wrapper liveness and multi-PID pidfiles; update version output to use printf with fallbacks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
airc Adds helper(s) to extract verified live monitor-wrapper PIDs from airc.pid and uses them in _monitor_alive_with_bearer_fallback.
lib/airc_bash/cmd_status.sh Reports a verified live PID from the pidfile (via new helper) and avoids kill -0 on an empty PID.
lib/airc_bash/cmd_update.sh Uses printf and fallback values to make airc version output more robust.
test/integration.sh Adds #511 regression coverage for WSL-style wrapper command lines and multi-PID pidfiles.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread airc
Comment on lines +513 to +520
echo "$cmd" | grep -Eq '(^|[[:space:]])/[^[:space:]]*/airc[[:space:]]+(connect|join)([[:space:]]|$)|(^|[[:space:]])airc[[:space:]]+(connect|join)([[:space:]]|$)|eval .*airc[[:space:]]+(connect|join)' \
&& return 0

# WSL/Claude Monitor can preserve only the script path in `ps` even
# though the PID came from this scope's airc.pid. Accept that narrower
# shape only after pidfile ownership + kill -0 have already been proven
# by the caller.
echo "$cmd" | grep -Eq '(^|[[:space:]])/[^[:space:]]*/airc([[:space:]]|$)|(^|[[:space:]])airc([[:space:]]|$)'
Comment thread airc
Comment on lines +519 to +520
# by the caller.
echo "$cmd" | grep -Eq '(^|[[:space:]])/[^[:space:]]*/airc([[:space:]]|$)|(^|[[:space:]])airc([[:space:]]|$)'
Comment thread airc
Comment on lines 555 to +560
# Fix: a PID is only "ours" if `kill -0` says alive AND its cmdline shapes
# like an airc connect/join wrapper. Same regex shape as cmd_teardown's
# parent-chain reaper (#446) — keeps the two paths in lockstep on what
# "an airc process" means. PID reuse → cmdline doesn't match → treat as
# dead, fall through to Phase 2 (scope formatter process evidence).
# like an airc wrapper. Same shape as cmd_teardown's parent-chain reaper
# (#446), with one WSL/Claude Monitor allowance: if the PID came from this
# scope's pidfile, a visible /path/to/airc wrapper is enough even when `ps`
# drops the join/connect argument. PID reuse → cmdline doesn't match →
# treat as dead, fall through to Phase 2 (scope formatter process evidence).
Comment thread airc
local pidfile="${1:-}"
[ -f "$pidfile" ] || return 0
local p raw
raw=$(cat "$pidfile" 2>/dev/null)
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