Repository navigation
fix(daemon,join): #3 status honesty + #5 join-path daemon tip (b69f's daemon audit, my half) - #410
Merged
Conversation
Two of the 5 daemon bugs from b69f's 2026-05-02 audit: ## #3 STATUS LIES — kill -0 verify + .bat existence check (cmd_daemon.sh) Pre-fix `airc daemon status` reported "RUNNING (PID N)" whenever ps-ef awk matched, WITHOUT verifying the matched PID was alive or the launcher .bat still existed. Repro (b69f): kill -0 92284 → no-such-process; status said RUNNING. Causes: ps-ef can report zombie/defunct/stale matches; registry entry can outlive launcher .bat after partial uninstalls. Fix: triage in priority order (most-actionable failure mode first): 1. launcher .bat missing → MISSING_LAUNCHER (reinstall msg) 2. ps-ef match + kill -0 verified → RUNNING (truly alive) 3. launcher present, no live pid → STALE/STOPPED User now sees actual state, not aspirational state. ## #5 JOIN-PATH DAEMON TIP — visibility on daily airc join (cmd_connect.sh) Pre-fix the daemon-install offer fired only at install.sh + post-disconnect tip. Daily `airc join` users (the most common path post-install) never saw the prompt — so daemon mode stayed opt-in by accident, leaving substrate fragile to Claude session ends + machine sleep. Fix: cmd_connect joiner success-path prints the tip if not already installed. Idempotent silent on installed scopes. Same pattern as the existing host-success tip at line 1763. ## Cumulative Tonight's airc daemon UX sweep: - #408 + #409 = daemon.log actually populates at the right path - This PR = status doesn't lie + join path nudges install b69f taking #2 (non-idempotent install) + #4 (crashloop research) in parallel. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR tightens daemon UX around two audited reliability issues: making Windows daemon status less likely to report false positives, and surfacing the daemon-install hint on the joiner success path so reconnect/self-heal is more discoverable in normal airc join usage.
Changes:
- Updates Windows
airc daemon statusto check launcher-file presence and verify candidate PIDs withkill -0before reportingRUNNING. - Adds new Windows status labels/messages for missing launcher vs. stale/stopped daemon states.
- Adds a post-join, idempotent
airc daemon installtip for users who successfully join without having the daemon installed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/airc_bash/cmd_daemon.sh |
Refines Windows daemon status detection and messaging around launcher/PID state. |
lib/airc_bash/cmd_connect.sh |
Adds a daemon-install tip to the successful joiner flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+466
to
+473
| # Status decision tree, in priority order so the user sees the | ||
| # actionable failure mode first when more than one applies: | ||
| # 1. launcher_status=missing → MISSING_LAUNCHER (registry | ||
| # points to a path that doesn't exist; reinstall needed) | ||
| # 2. live_pid set + launcher present → RUNNING (truly alive) | ||
| # 3. launcher present, no live pid → registered (waiting on | ||
| # next logon OR daemon was killed; user can re-fire) | ||
| if [ "$launcher_status" = "missing" ]; then |
Comment on lines
+1252
to
+1254
| # silent on already-installed scopes (idempotent check). | ||
| if ! airc_daemon_is_installed; then | ||
| echo " Tip: 'airc daemon install' keeps this mesh alive across Claude session ends + sleep/wake." |
joelteply
added a commit
that referenced
this pull request
May 2, 2026
…udit) (#411) fix(daemon,install): scope-aware idempotency — install.sh no longer skips when daemon is registered for a DIFFERENT scope (#2 from b69f's daemon audit) ## Why b69f hit it 2026-05-02: 1. Installed daemon while in /c/.airc-src 2. Re-ran AIRC_INSTALL_YES=1 install.sh from ~/continuum 3. install.sh saw "any airc daemon registered" → no-op'd the prompt 4. ~/continuum had no daemon serving it; surface looked installed from `airc daemon status`'s old behavior, but launcher .bat pointed at the wrong scope The cmd_daemon_install function itself IS idempotent (force-overwrites .bat + reg add //f). The bug was install.sh's coarse pre-check — `airc_daemon_is_installed` answered "any daemon anywhere?" not "the daemon for THIS scope?". Pairs with #410 (Mac's #3 status honesty + #5 join tip) — both make the daemon stop lying about its own state. ## What ### New: `airc_daemon_is_installed_for_scope <scope>` in lib_daemon_detect.sh Stricter sibling of `airc_daemon_is_installed`. Returns 0 only when the registered launcher / unit / plist is wired to the given scope: - darwin: plist's EnvironmentVariables.AIRC_HOME == scope - linux/wsl: systemd unit has Environment="AIRC_HOME=<scope>" - windows: registry value contains <scope>/airc-daemon.bat AND .bat exists on disk Plain `airc_daemon_is_installed` is preserved unchanged for callers that want "any daemon presence" (post-disconnect tip, status banner). ### install.sh updated Both branches (AIRC_INSTALL_YES=1 + interactive prompt) now use `airc_daemon_is_installed_for_scope "$INSTALL_DAEMON_SCOPE"` where INSTALL_DAEMON_SCOPE mirrors cmd_daemon.sh::_daemon_scope: ${AIRC_HOME:-$(pwd)/.airc}. Net effect: - AIRC_INSTALL_YES=1 + already installed for THIS scope → no-op - AIRC_INSTALL_YES=1 + registered for DIFFERENT scope → reinstall (cmd_daemon_install regenerates .bat + reg add //f overwrites) - Interactive + already installed for THIS scope → skip prompt - Interactive + registered for DIFFERENT scope → prompt with clearer "registered for a different scope; reinstall and wire to <new>?" ## Tests End-to-end smoke (this branch, on Windows Git Bash): $ airc daemon install # in ~/continuum $ airc_daemon_is_installed_for_scope ~/continuum/.airc; echo $? 0 ← was 1 pre-fix when registry pointed at different scope $ airc_daemon_is_installed_for_scope /tmp/other/.airc; echo $? 1 $ airc daemon uninstall $ airc_daemon_is_installed_for_scope ~/continuum/.airc; echo $? 1 Existing 11/11 monitor_formatter tests still pass. ## Pairs with the 5-bug audit - #1 (#408+#409 Mac): launcher absolute paths - #2 THIS PR: scope-aware install - #3+#5 (#410 Mac): status honesty + join-path tip - #4 still open: Windows crashloop research (b69f next) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
May 2, 2026
…ills 10-min takeover blackout (#4) (#412) fix(monitor,daemon): skip bearer-state fallback in daemon context — kills 10-min takeover blackout (#4 from b69f's daemon audit) ## Why Last bug from b69f's 2026-05-02 daemon audit. Repro: 1. Interactive `airc connect` running, writing bearer_state.json 2. Process dies (Claude session end, Ctrl-C, crash) 3. Daemon launcher (.bat / launchd / systemd) starts new airc connect 4. New airc connect calls _monitor_alive_with_bearer_fallback 5. Phase 1 (kill -0 on pidfile PIDs): all dead — falls through to Phase 2 6. Phase 2 (bearer_state freshness): last_recv_ts within 600s window → "yes" 7. New airc connect early-exits "monitor already running" 8. Launcher restarts every 5s, repeats until 600s window expires 9. **10-minute substrate blackout while daemon can't take over** Then daemon.err fills with hundreds of `airc connect exited. Restarting in 5s.` lines per minute. Joel observed exactly this pattern 2026-05-02 calling the daemon path "brittle as hell." Phase 2 was added (#370) for Codex sandbox blindness — kill -0 lies in some sandboxes about cross-process visibility. The fallback was supposed to disambiguate. But in daemon context (which sets `AIRC_BACKGROUND_OK=1`), kill -0 is reliable; the fallback only causes false positives. ## What Three-line skip at the top of Phase 2: when `AIRC_BACKGROUND_OK=1`, trust kill -0 and return "no" if all pidfile PIDs are dead. ```bash if [ "${AIRC_BACKGROUND_OK:-0}" = "1" ]; then echo "no" return 0 fi ``` Effect: daemon takeover is immediate (next .bat iteration after interactive death) instead of delayed 10 minutes. ## Why this is safe - Codex / sandbox sessions don't set `AIRC_BACKGROUND_OK=1` — they get the existing fallback behavior. Phase 2's purpose is preserved for them. - Daemon launcher (cmd_daemon.sh:233) explicitly sets `AIRC_BACKGROUND_OK=1` before spawning airc connect. That's the marker. - launchd plist (cmd_daemon.sh:160-162) and systemd unit (cmd_daemon.sh:331) also set it. Cross-platform consistent. - In daemon context the only thing populating bearer_state is the previously-running airc connect; that connect is now dead (Phase 1 confirmed), so there's no "real but blind" monitor — only a stale state file. ## Out of scope (follow-up) When daemon legitimately CAN'T take over because another airc connect IS running (user has both interactive + daemon, dual-monitor scenario), the launcher still spams 5s restart cycles. Distinct exit code from "monitor already running" → longer .bat sleep would be the polish. Filing as follow-up; this PR is the hot-path fix. ## Tests - bash -n passes - 11/11 monitor_formatter tests pass - Diff is 3 functional lines + comment; sandbox path unchanged - Smoke test scaffolding to repro the blackout requires a real Windows daemon install + interactive death; will rely on Mac dogfood + integration suite ## Closes b69f's daemon audit | Bug | PR | |-----|----| | #1 launcher absolute paths | #408 + #409 (Mac) | | #2 scope-aware install | #411 (b69f) | | #3 status honesty | #410 (Mac) | | **#4 daemon takeover blackout** | **THIS PR** | | #5 join-path tip | #410 (Mac) | 5/5 audit bugs in PRs. Daemon path on Windows should be substantially more honest after merge. 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.
Two of b69f's 5 daemon bugs from the 2026-05-02 audit:
#3 STATUS LIES:
airc daemon statusreported RUNNING whenever ps-ef awk matched, no kill -0 verify, no .bat existence check. Now triages: launcher missing → MISSING_LAUNCHER, ps-ef + kill -0 verified → RUNNING, otherwise STALE/STOPPED.#5 JOIN-PATH TIP: daemon-install offer fired only at install.sh + post-disconnect — daily
airc joinusers never saw it. Added idempotent tip on joiner success-path (matches existing host-success tip pattern).b69f taking #2 (non-idempotent install) + #4 (crashloop research) in parallel.
🤖 Generated with Claude Code