Skip to content

feat(daemon): attribute a vanished daemon to the cache watchdog's own report (#1866) - #1881

Merged
zackees merged 1 commit into
mainfrom
agent/1866-daemon-abort-witness
Nov 3, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1866-daemon-abort-witness

Conversation

@zackees

@zackees zackees commented Nov 3, 2026

Copy link
Copy Markdown
Member

Why

#1866: two ESP32-S3 AutoResearch builds lost the shared daemon
mid-compile. The daemon's own log names the cause — the embedded zccache lock
watchdog
aborting the process (artifact/store.rs:492 flush guard,
spawn_exclusion.rs:61 admission guard, both age_ns just over the 15 s
budget) — but the client could only report error decoding response body /
error sending request, which reads like a device or firmware fault and invites
the wrong response (replugging, cache deletion, retries against a dead daemon).

This PR makes the daemon's death attributable. It does not silence the
watchdog and does not raise the budgets: the abort stays, and stays fatal for
the process. What changes is that the surviving evidence reaches the user.

What

fbuild_core::daemon_diagnostics (new module, 263 LOC) — parses a bounded
tail of the daemon log into a typed verdict:

  • DaemonLoss::WatchdogAbort { holders, waiters } — from the upstream
    zccache: lock hold exceeded its budget report: guard shape, held time,
    budget, shortened acquisition site (artifact/store.rs:492:14), thread, and
    the count of queued waiters. Only Holding lines are blamed; Waiting lines
    are counted, never accused. The last report block wins, so an earlier
    overrun cannot mask a later, different one.
  • DaemonLoss::Panic { message } — a panic = "abort" exit.
  • DaemonLoss::Unattributed — nothing to attribute; callers keep the existing
    message.

Parsing is shape-tolerant: an age_ns that arrives redacted or unparseable
degrades to the signature-only verdict instead of fabricating "held for 0 s".

Client (daemon_client.rs) — build_streaming, post_operation's send
error and its response-decode error now append the verdict when the daemon is
gone (owner claim's PID dead) or the log witnesses an abort:

lost connection to daemon mid-build (…); the daemon process may have died — check …/daemon.log
the embedded zccache lock watchdog aborted the daemon: holding a Mutex for 15.03s exceeded its 15.00s budget at artifact/store.rs:492:14 (thread tokio-rt-worker), 0 waiter(s) queued. That is the embedded cache-watchdog failure class (#1866): an infrastructure fault inside the daemon process, not a device, firmware, upload or build error. The in-flight operation was interrupted and must be retried once a daemon is serving again; full diagnostics: …/daemon.log

Daemon (entry/mod.rs) — the stale-PID warning at the next start repeats
the previous process's last abort report, so the cause is in the log even if no
client was attached.

Docs: docs/reference/cli.md "When the daemon disappears" + fbuild-core
README module list.

Tests (real output)

New daemon_diagnostics_tests (9 tests, hardware-free): both production report
shapes, waiters-not-blamed, surrounding build log, last-block-wins,
ordinary-log non-attribution, redacted numbers, panic, explanation text,
bounded tail read (read_log_tail keeps the newest bytes and drops the oldest).

Behavioural RED first — diagnose stubbed to always return Unattributed:
test result: FAILED. 2 passed; 7 failed. Restored: 9 passed / 0 failed.

  • soldr cargo test -p fbuild-core --lib → 375 passed; 0 failed; 2 ignored
    (baseline 368 + 9 new, minus overlap)
  • soldr cargo clippy -p fbuild-core -p fbuild-cli -p fbuild-daemon --all-targets -- -D warnings → rc 0
  • soldr cargo fmt --all -- --check → rc 0
  • ci/enforce_platform_boundary.py --print-totals → rows=44; dylint_rows=43, rc 0
  • ci/check_test_layout.py → ok, 8 categories
  • python -m ci.run_dylint --package fbuild-core → (result below)

Remaining #1866 scope (not this PR)

The abort itself is upstream: flush_lock at artifact/store.rs:492 takes the
short STATE_TIMEOUT (15 s) hold budget for a full snapshot + bincode +
fsync + rename + dir-fsync, and spawn_exclusion.rs:61 gives the shared
fork/exec guard the same budget. Verified locally that zccache 1.15.11,
1.15.12 and 1.15.13 are byte-identical at both sites
, so a pin bump does not
fix it — a long-operation permit (vs. a short state critical section) is needed
upstream. That hand-off, plus the concurrent-build reproduction, is the
follow-up; this PR is the honest, typed failure in the meantime.

… report

#1866: the embedded zccache lock watchdogs abort the daemon
*process*, so a build or deploy caught by one reported only a dead connection
("error decoding response body" / "error sending request") — indistinguishable
from a device or firmware fault.

New fbuild_core::daemon_diagnostics parses a bounded tail of the daemon log into
a typed verdict: WatchdogAbort (guard shape, held time, budget, acquisition
site, thread, queued waiters; only Holding lines are blamed, the newest report
block wins), Panic, or Unattributed. Unparseable/redacted numbers degrade to the
signature-only verdict rather than fabricating a duration.

The client appends the verdict to lost-connection and failed-request errors when
the daemon is gone or the log witnesses an abort; the daemon repeats the
previous process's last abort report next to its stale-PID warning.

The abort itself stays: it is upstream (artifact/store.rs flush_lock and
spawn_exclusion.rs share the short STATE_TIMEOUT hold budget), and zccache
1.15.11-13 are byte-identical at both sites, so a pin bump cannot fix it.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@zackees
zackees added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit ff4c71e Nov 3, 2026
49 of 52 checks passed
@zackees
zackees deleted the agent/1866-daemon-abort-witness branch November 3, 2026 21:37
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant