fix(daemon): make binary-staleness watchdog failures observable, add task-level test - #480
Conversation
…task-level test Item #107: a live daemon kept running for 19+ minutes after its on-disk binary was replaced, missing ~19 BINARY_STALENESS_CHECK_INTERVAL checks, with no log line ever indicating whether the watchdog was armed. The comparison logic in BinarySnapshot::is_stale() already had unit coverage and reads correctly; what was missing was any signal, at the live-daemon level, of whether the watchdog task ever armed in the first place -- capture() failing at startup and the watchdog silently no-op'ing was indistinguishable from "armed, nothing stale yet". Split the polling loop out of spawn_binary_staleness_watchdog into daemon::wait_for_stale so it has its own test coverage independent of is_stale()'s unit tests -- exercised here with a simulated tokio clock covering multiple ticks and a real on-disk file swap. Also log explicitly on both the armed and disabled-at-startup paths so a silent failure to arm shows up in daemon.log instead of looking identical to normal operation. Agentflare-Agent: claude-code Agentflare-Branch: task/107-binary-staleness-watchdog-doesn-t-self-r Agentflare-Item: 107
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Comment |
The new #[tokio::test(start_paused = true)] regression test in src/daemon.rs pulled in tokio's test-util feature, changing the workspace-wide feature union cargo hakari computes. Regenerate agentflare-workspace-hack/Cargo.toml to match, which is what CI's own cargo hakari generate --diff check enforces. Agentflare-Agent: claude-code Agentflare-Branch: task/107-binary-staleness-watchdog-doesn-t-self-r Agentflare-Item: 107
Summary
cargo build/cargo installreplaced its on-disk binary, missing ~19BINARY_STALENESS_CHECK_INTERVALchecks, with no log line anywhere indicating whether the staleness watchdog task had even armed.BinarySnapshot::is_stale()'s comparison logic already had unit coverage and reads correctly on inspection — the gap was observability:BinarySnapshot::capture()failing at startup and the watchdog silently no-op'ing was indistinguishable, from the log, from "armed and nothing's stale yet".spawn_binary_staleness_watchdogintodaemon::wait_for_stale, giving the polling task itself test coverage (via a simulated tokio clock + a real on-disk file swap), not justis_stale()'s comparison logic in isolation.spawn_binary_staleness_watchdognow logs explicitly on both the armed and disabled-at-startup paths, so a silent failure to arm shows up indaemon.loginstead of looking identical to normal operation.Test plan
cargo build --bin agentflare— clean buildcargo test --bin agentflare daemon::— 4/4 pass, including the newwait_for_stale_polls_until_the_file_on_disk_changesregression testcargo clippy --bin agentflare --tests --no-deps— no new warningsbinary staleness watchdog armed for <path>, checking every 60sline prints at startup