Repository navigation
feat(observability): daemon-died / pipe-handover / client-disconnected lifecycle events (#755) - #756
Merged
Merged
Conversation
…d lifecycle events (#755) Closes #755. Extends `daemon-lifecycle.log` with three new JSONL event types and two new client-meta fields on every spawn-attempt / spawn row, so the two-versions-on-one-pipe wedge — fbuild's bundled 1.12.4 vs. PyPI's 1.12.5, both racing for the same Windows named pipe — becomes reconstructable from a single `grep` instead of by-hand timestamp matching. ## Schema additions (all additive; existing tooling keeps working) * `daemon-died` — emitted by the CLI after `stop_stale_daemon` successfully kills a predecessor. Envelope `pid` is overridden to the dying daemon's PID; carries `reason: takeover`, `replaced_by_pid`, `replaced_by_version`. Self-emitted `died-idle` / `died-shutdown` continue to fire from the daemon unchanged. * `pipe-handover` — emitted alongside `daemon-died` when the new daemon's PID is observed post-bind. Envelope `pid` is the new daemon's PID; carries `inbound_pid`, `inbound_version`, `outbound_pid`, `reason: previous-died`. * `client-disconnected` — emitted at the point a client's IPC connection breaks (`cause: comm-error` / `pipe-closed-mid-write`). Pre-fix this dropout was only visible one round-trip later as the next `spawn-attempt`'s `reason: replaced-comm-error`. * `client_version` + `client_binary_path` on every `spawn-attempt` (CLI-emitted) and `spawn` (daemon-emitted) row — distinguishes fbuild's bundled binary from a PyPI install when both share an endpoint. Single source: `core::lifecycle::client_meta()`. ## TDD trail RED before, GREEN after — see `core/lifecycle.rs` tests for the schema-pinning suite and the `emit_takeover_lifecycle_events` round- trip that verifies the `outbound_pid` ↔ `inbound_pid` join the schema doc instructs operators to grep against: * `new_event_constants_match_schema` — pins the wire strings. * `new_reason_and_cause_constants_match_schema` — pins reason + cause strings. * `client_meta_returns_version_and_binary_path` — pins the helper's contract (binary_path never empty). * `write_event_round_trips_new_daemon_died_takeover_event` — pins the wire shape of `daemon-died`, including envelope-pid override and `replaced_by_*` fields. * `emit_takeover_lifecycle_events_writes_linked_pair` — pins acceptance #2's structural join (`died.pid == handover.outbound_pid` and `died.replaced_by_pid == handover.inbound_pid`). ## Acceptance coverage (issue checklist) * [x] daemon-died with matching `reason` — emitted by CLI on takeover via `emit_takeover_lifecycle_events`. Self-emitted `died-idle` / `died-shutdown` paths unchanged. * [x] Linked daemon-died / pipe-handover with PID join — see the round-trip test above. * [x] client-disconnected at point of failure with `cause` — emitted in `run_ephemeral_attempt` and `cmd_compile`'s Failed arm. * [x] `client_version` + `client_binary_path` on every spawn-attempt and spawn line — wired in 3 call sites (runtime.rs, commands/daemon.rs, bin/zccache-daemon.rs). * [x] Schema backward-compatible — additive only; envelope fields unchanged; the writer preserves any key the caller passes. * [x] Doc block describing schema with forensic walkthrough — module doc in `core/lifecycle.rs` includes the event table + the six-row walkthrough from the issue's repro. ## Out of scope (tracked separately) * The structural fix for the underlying collision — hashing `(binary_path, version)` into the pipe-name suffix so coexisting versions land on distinct pipes — warrants its own issue. This PR is about making the collision *visible* in the meantime. * The duplicated `stop_stale_daemon` / `spawn_and_wait` between `cli/runtime.rs` and `cli/commands/daemon.rs` is preserved; both arms now emit the linked events identically. Unifying them is a separate refactor. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 15, 2026
Closed
zackees
added a commit
that referenced
this pull request
Jun 15, 2026
Ships three reliability + observability changes on top of 1.12.5: - fix(wrap): auto-retry link/compile-ephemeral on lost-connection (#754) - feat(observability): daemon-died / pipe-handover / client-disconnected lifecycle events (#756) - fix(wedge): probe daemon with Ping before sending Shutdown (#757) 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.
Closes #755.
Extends
daemon-lifecycle.logwith three new JSONL event types and two new client-meta fields on everyspawn-attempt/spawnrow, so the two-versions-on-one-pipe wedge — fbuild's bundled 1.12.4 vs. PyPI's 1.12.5, both racing for the same Windows named pipe — becomes reconstructable from a singlegrepinstead of by-hand timestamp matching.Schema additions (additive; existing tooling keeps working)
daemon-diedpid(dying daemon),reason: takeover,replaced_by_pid,replaced_by_version,client_pidpipe-handoverpid(new daemon),inbound_pid,inbound_version,outbound_pid,reason: previous-died,client_pidclient-disconnectedendpoint,client_pid,client_version,client_binary_path,cause,detailPlus
client_version+client_binary_pathenrichment on everyspawn-attempt(CLI-emitted) andspawn(daemon-emitted) row — single source:core::lifecycle::client_meta().Acceptance (issue checklist)
daemon-diedwith matchingreason— emitted by CLI on takeover viaemit_takeover_lifecycle_events. Self-emitteddied-idle/died-shutdownpaths unchanged.daemon-died.pid == pipe-handover.outbound_pid,daemon-died.replaced_by_pid == pipe-handover.inbound_pid. See testemit_takeover_lifecycle_events_writes_linked_pair.client-disconnectedat point of failure withcause— emitted inrun_ephemeral_attempt(per-attempt) andcmd_compile's Failed arm (persistent-session).client_version+client_binary_pathon every spawn-attempt and spawn line — wired in 3 call sites (runtime.rs,commands/daemon.rs,bin/zccache-daemon.rs).core/lifecycle.rsincludes the event table + a six-row forensic walkthrough using the issue's verbatim repro.TDD trail
5 RED→GREEN unit tests in
core/lifecycle.rs::tests:new_event_constants_match_schema— pins wire strings fordaemon-died/pipe-handover/client-disconnected.new_reason_and_cause_constants_match_schema— pins all 4 new reasons + 4 new causes.client_meta_returns_version_and_binary_path—binary_pathis never empty.write_event_round_trips_new_daemon_died_takeover_event— wire shape ofdaemon-diedincluding envelope-pid override.emit_takeover_lifecycle_events_writes_linked_pair— pins acceptance Fix cross-platform path handling in linker detection #2's structural join.Test plan
soldr cargo test -p zccache --lib core::lifecycle— 11/11 pass (5 new + 6 existing)soldr cargo test -p zccache --lib cli::commands::wrap::ipc— 11/11 pass (no regressions on the retry/wedge suite)soldr cargo test -p zccache --lib— 1780/1780 passsoldr cargo fmt --all -- --checksoldr cargo clippy -p zccache --all-targets -- -D warnings~/.zccache/logs/daemon-lifecycle.logafter azccache stop+ spawn cycle and confirm the linkeddaemon-died+pipe-handover+ enrichedspawnrows appear with PID join intact.Out of scope (tracked separately)
(binary_path, version)into the pipe-name suffix so coexisting versions land on distinct pipes — warrants its own issue. This PR makes the collision visible.stop_stale_daemon/spawn_and_waitbetweencli/runtime.rsandcli/commands/daemon.rsis preserved; both arms now emit the linked events identically. Unifying them is a separate refactor.Refs
broker-rsshared lifecycle primitives (forward-compatible schema)🤖 Generated with Claude Code