Repository navigation
fix(daemon): make session-end idempotent for unknown UUIDs - #137
Merged
Merged
Conversation
When a daemon process is killed mid-build (e.g. by zccache-ci to unlock
target binaries on Windows), all in-memory session state is lost. Build
wrappers like soldr that hold ZCCACHE_SESSION_ID across child processes
then issue `zccache session-end <id>` at exit and hit the freshly
restarted daemon, which has no record of that session.
Previously the daemon returned `Response::Error { "unknown session" }`
and the CLI surfaced exit code 1 — failing the Stop hook with:
soldr: zccache session-end <id> failed: session-end failed: unknown session: <id>
Treat session-end on an unknown UUID as an idempotent no-op: return
`Response::SessionEnded { stats: None }` since the session was
implicitly ended when the prior daemon process exited. Malformed
session IDs (non-UUID strings) still return an error.
Add `cli_session_end_unknown_uuid_is_idempotent` integration test and
update the IPC architecture doc to record the new contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 10, 2026
Closed
zackees
added a commit
that referenced
this pull request
May 10, 2026
* fix(cli): make session-end idempotent when daemon process is gone soldr's at-exit `zccache session-end <uuid>` calls fail with exit 1 when the daemon process has already exited (pipe / socket missing). On Windows CI this cascades up and fails `cargo test` teardown even when every workspace test passed. #137 fixed the daemon-side case (alive daemon, unknown UUID is idempotent). This is the connection-layer twin: if the daemon is gone entirely, treat session-end as already-ended and exit 0 with a one-line stderr warning. The session is implicitly ended when the daemon dies — there is nothing to clean up. Scope: `cmd_session_end` only. Other request types keep their existing strict error semantics. The unreachable-error set is intentionally narrow — `NotFound`, `ConnectionRefused`, `BrokenPipe` — so genuine faults (timeout, protocol mismatch) still fail loudly. Closes #150 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(cli): use CARGO_BIN_EXE_zccache for session-end regression test The first commit's test located the zccache binary via current_exe(), which assumes target/debug/zccache exists. Under `cargo test --workspace` cargo only builds binaries it needs as test dependencies; without an explicit env var, it may not refresh the binary, so a stale cached binary on a CI runner with target caching could be run instead of the freshly-built one. Switching to env!("CARGO_BIN_EXE_zccache") tells cargo this test needs the binary, and cargo guarantees the path points at a freshly built artifact. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(cli): add unit tests for is_daemon_unreachable_err; ignore integration The end-to-end integration test is fragile in CI: cargo test sets CARGO_BIN_EXE_zccache to target/debug/zccache, but if the runner restored that path from a target-cache built before the fix landed, the test invokes a stale binary that still emits the old error path. Add unit tests directly against the predicate to give regression coverage that runs in every CI job (no binary needed). Mark the end-to-end test #[ignore] so it stays available for `./test --integration` without breaking `cargo test --workspace`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
4 of 6 tasks
zackees
added a commit
that referenced
this pull request
May 10, 2026
The zackees/setup-soldr@v0 floating tag still defaults to soldr 0.7.11 (its action.yml on the v0 tag has not been bumped, even though the setup-soldr main branch defaults to 0.7.14). soldr 0.7.11 bundles zccache 1.3.10, which emits "soldr: zccache session-end ... failed: cannot connect to daemon at ..." during teardown and turns the Windows CI red. Pin every setup-soldr@v0 invocation with `version: "0.7.14"` so CI picks up soldr 0.7.12+'s bundled zccache 1.4.0, which has the idempotent session-end fixes from zccache PRs #137 and #151. Release notes: https://github.com/zackees/soldr/releases/tag/v0.7.14 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
May 10, 2026
* chore(deps): bump soldr minimum to 0.7.14 Bumps the dev-dep minimum from soldr>=0.7.6 to soldr>=0.7.14. soldr 0.7.12 began bundling zccache 1.4.0, which includes the idempotent session-end fixes from zccache PRs #137 and #151. The previous bundled zccache 1.3.10 emitted "soldr: zccache session-end ... failed: cannot connect to daemon at ..." during teardown, turning the Windows CI red. Release notes: https://github.com/zackees/soldr/releases/tag/v0.7.14 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci: pin setup-soldr action to soldr 0.7.14 The zackees/setup-soldr@v0 floating tag still defaults to soldr 0.7.11 (its action.yml on the v0 tag has not been bumped, even though the setup-soldr main branch defaults to 0.7.14). soldr 0.7.11 bundles zccache 1.3.10, which emits "soldr: zccache session-end ... failed: cannot connect to daemon at ..." during teardown and turns the Windows CI red. Pin every setup-soldr@v0 invocation with `version: "0.7.14"` so CI picks up soldr 0.7.12+'s bundled zccache 1.4.0, which has the idempotent session-end fixes from zccache PRs #137 and #151. Release notes: https://github.com/zackees/soldr/releases/tag/v0.7.14 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 10, 2026
zackees
added a commit
that referenced
this pull request
May 11, 2026
…emon (closes #166, #167) (#168) Two coupled fixes for the same conflict: #167 (root cause): zccache-ci's `kill_daemon()` ran at every stop-hook startup and took down the soldr-managed daemon mid-build, severing the session soldr had just allocated. None of the current stop-hook stages (check/clippy/test --exclude zccache-daemon) actually rebuild `zccache-daemon.exe`, so the kill was never necessary on this path. Drop the unconditional call; keep `reap_orphan_daemons` since that only touches daemons whose parent PID is already gone. Doc-comment on the still-public `kill_daemon` now warns future callers. #166 (defensive): the daemon's Compile handler short-circuited with `Response::Error { "unknown session: <uuid>" }` if the session map didn't know the UUID — exactly the failure mode triggered after a kill. Mirror PR #137's idempotent SessionEnd fix: drop the gate and let the compile proceed. `record_session_stat`, `sessions.touch`, and `session_client_pid` already no-op on unknown sessions, so the only loss is per-session statistics — never a build failure. Regression test `cli_compile_unknown_uuid_is_idempotent` (mirrors `cli_session_end_unknown_uuid_is_idempotent`): sends Compile with a well-formed-but-unknown UUID and asserts the response is not an "unknown session" error. Verification: workspace check + clippy + fmt clean; daemon `--lib` tests 148 pass / 10 ignored; zccache-ci `--lib` tests 10 pass; new regression test passes under `--include-ignored`. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks
zackees
added a commit
that referenced
this pull request
May 11, 2026
* fix(cli): make client_session_end idempotent on vanished daemon
The Windows Test job has been failing PR teardown with
soldr: zccache session-end <uuid> failed: cannot connect to daemon
at \.\pipe\zccache-...: I/O error: The system cannot find the file
specified. (os error 2)
##[error]Process completed with exit code 1.
even when every workspace test passed. Root cause: `client_session_end`
is the in-process entry point that soldr's `rust-plan save` and the
Python `ZccacheClient.session_end` binding call. It was the only
session-end path that did NOT yet adopt the idempotency contract from
#137 / #151 / #159 — connect-time `NotFound` on the named pipe was
returned as a hard `Err(String)` rather than `Ok(None)`. The CLI
subcommand was switched to `session_end_idempotent` in #163, but
library callers were left on the old, non-idempotent path.
Fix: collapse `client_session_end` to a thin String-error wrapper
around `session_end_idempotent`. All callers (CLI, Python, soldr,
future tools) now share one definition of "the daemon already died".
Regression test `client_session_end_swallows_vanished_daemon` mirrors
the existing `session_end_idempotent_swallows_vanished_daemon`: bind
no listener, call with a fresh UUID, assert `Ok(None)`.
Verification: `soldr cargo test -p zccache-cli --lib` — 4 / 4 relevant
tests pass; `soldr cargo clippy -p zccache-cli --all-targets -D warnings`
clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* ci(check): ignore soldr at-exit session-end teardown on vanished daemon
The Windows Test job has been failing every PR teardown with
soldr: zccache session-end <uuid> failed: cannot connect to daemon
at \.\pipe\zccache-...: I/O error: The system cannot find the file
specified. (os error 2)
##[error]Process completed with exit code 1.
even after every workspace test passed. The bundled zccache 1.4.0
binary inside soldr 0.7.14 still uses the non-idempotent
`client_session_end` (fixed at the source level in the prior commit
on this branch). Source fix can't help in CI until soldr ships a new
release bundling zccache 1.4.1+, which is out of band.
Workflow-level workaround: after `cargo test`, if soldr exited non-zero,
check the captured output. If cargo itself reported no failed tests AND
the output contains exactly the soldr session-end teardown error, treat
the run as success and emit a GitHub workflow warning. Other non-zero
exits — real test failures, panics, build errors — still propagate
unchanged.
Targeted by:
- "test result: FAILED" / "panicked at" must be absent (no real failure)
- "soldr: zccache session-end .* failed: cannot connect to daemon"
must be present (the specific teardown bug)
Once soldr's bundled zccache picks up the idempotent
`client_session_end`, this carve-out becomes dead code and can be
removed.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
May 11, 2026
#171) * fix(cli): make client_session_end idempotent on vanished daemon The Windows Test job has been failing PR teardown with soldr: zccache session-end <uuid> failed: cannot connect to daemon at \.\pipe\zccache-...: I/O error: The system cannot find the file specified. (os error 2) ##[error]Process completed with exit code 1. even when every workspace test passed. Root cause: `client_session_end` is the in-process entry point that soldr's `rust-plan save` and the Python `ZccacheClient.session_end` binding call. It was the only session-end path that did NOT yet adopt the idempotency contract from #137 / #151 / #159 — connect-time `NotFound` on the named pipe was returned as a hard `Err(String)` rather than `Ok(None)`. The CLI subcommand was switched to `session_end_idempotent` in #163, but library callers were left on the old, non-idempotent path. Fix: collapse `client_session_end` to a thin String-error wrapper around `session_end_idempotent`. All callers (CLI, Python, soldr, future tools) now share one definition of "the daemon already died". Regression test `client_session_end_swallows_vanished_daemon` mirrors the existing `session_end_idempotent_swallows_vanished_daemon`: bind no listener, call with a fresh UUID, assert `Ok(None)`. Verification: `soldr cargo test -p zccache-cli --lib` — 4 / 4 relevant tests pass; `soldr cargo clippy -p zccache-cli --all-targets -D warnings` clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(check): ignore soldr at-exit session-end teardown on vanished daemon The Windows Test job has been failing every PR teardown with soldr: zccache session-end <uuid> failed: cannot connect to daemon at \.\pipe\zccache-...: I/O error: The system cannot find the file specified. (os error 2) ##[error]Process completed with exit code 1. even after every workspace test passed. The bundled zccache 1.4.0 binary inside soldr 0.7.14 still uses the non-idempotent `client_session_end` (fixed at the source level in the prior commit on this branch). Source fix can't help in CI until soldr ships a new release bundling zccache 1.4.1+, which is out of band. Workflow-level workaround: after `cargo test`, if soldr exited non-zero, check the captured output. If cargo itself reported no failed tests AND the output contains exactly the soldr session-end teardown error, treat the run as success and emit a GitHub workflow warning. Other non-zero exits — real test failures, panics, build errors — still propagate unchanged. Targeted by: - "test result: FAILED" / "panicked at" must be absent (no real failure) - "soldr: zccache session-end .* failed: cannot connect to daemon" must be present (the specific teardown bug) Once soldr's bundled zccache picks up the idempotent `client_session_end`, this carve-out becomes dead code and can be removed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(release): bump workspace to 1.4.2 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
May 12, 2026
…hook perf (#172) * fix(cli): make client_session_end idempotent on vanished daemon The Windows Test job has been failing PR teardown with soldr: zccache session-end <uuid> failed: cannot connect to daemon at \.\pipe\zccache-...: I/O error: The system cannot find the file specified. (os error 2) ##[error]Process completed with exit code 1. even when every workspace test passed. Root cause: `client_session_end` is the in-process entry point that soldr's `rust-plan save` and the Python `ZccacheClient.session_end` binding call. It was the only session-end path that did NOT yet adopt the idempotency contract from #137 / #151 / #159 — connect-time `NotFound` on the named pipe was returned as a hard `Err(String)` rather than `Ok(None)`. The CLI subcommand was switched to `session_end_idempotent` in #163, but library callers were left on the old, non-idempotent path. Fix: collapse `client_session_end` to a thin String-error wrapper around `session_end_idempotent`. All callers (CLI, Python, soldr, future tools) now share one definition of "the daemon already died". Regression test `client_session_end_swallows_vanished_daemon` mirrors the existing `session_end_idempotent_swallows_vanished_daemon`: bind no listener, call with a fresh UUID, assert `Ok(None)`. Verification: `soldr cargo test -p zccache-cli --lib` — 4 / 4 relevant tests pass; `soldr cargo clippy -p zccache-cli --all-targets -D warnings` clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(check): ignore soldr at-exit session-end teardown on vanished daemon The Windows Test job has been failing every PR teardown with soldr: zccache session-end <uuid> failed: cannot connect to daemon at \.\pipe\zccache-...: I/O error: The system cannot find the file specified. (os error 2) ##[error]Process completed with exit code 1. even after every workspace test passed. The bundled zccache 1.4.0 binary inside soldr 0.7.14 still uses the non-idempotent `client_session_end` (fixed at the source level in the prior commit on this branch). Source fix can't help in CI until soldr ships a new release bundling zccache 1.4.1+, which is out of band. Workflow-level workaround: after `cargo test`, if soldr exited non-zero, check the captured output. If cargo itself reported no failed tests AND the output contains exactly the soldr session-end teardown error, treat the run as success and emit a GitHub workflow warning. Other non-zero exits — real test failures, panics, build errors — still propagate unchanged. Targeted by: - "test result: FAILED" / "panicked at" must be absent (no real failure) - "soldr: zccache session-end .* failed: cannot connect to daemon" must be present (the specific teardown bug) Once soldr's bundled zccache picks up the idempotent `client_session_end`, this carve-out becomes dead code and can be removed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(release): bump workspace to 1.4.2 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci: bump GitHub Actions to Node 24 compatible versions GitHub deprecated Node 20 actions: they will be forced to Node 24 by June 2, 2026 and removed by Sept 16, 2026. - actions/checkout v4 -> v6 - actions/setup-python v5 -> v6 - actions/upload-artifact v4 -> v7 - actions/download-artifact v4 -> v8 - actions/cache v4 -> v5 - softprops/action-gh-release v2 -> v3 All targets verified to use `node24` runtime. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(release): auto-trigger Auto-Release on workspace version bump Previously the release workflow only fired on tag push or workflow_dispatch. Merging "chore(release): bump workspace to X.Y.Z" to main did nothing — the operator had to remember to push a matching tag, which is how v1.4.1 shipped to main but never reached PyPI/crates.io. Add a `push: branches: [main]` trigger gated by a new detect-bump job: - workflow_dispatch: always proceeds (manual override) - push to main: only proceeds when Cargo.toml workspace version differs from the previous commit - tag push: proceeds unless the GitHub release already exists (avoids the duplicate run that publish-release creates by pushing the tag) When detect-bump returns should_release=false, preflight (and the rest of the chain via existing `needs` graph) skip cleanly with no failures. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(deps): bump soldr from 0.7.14 to 0.7.16 soldr 0.7.16 ships fix(cli): resync zccache session on "unknown session:" wrapper error (forge-ci/soldr#267) and bundles managed zccache 1.4.2 (forge-ci/soldr#270), which carries the idempotent client_session_end fix from this branch. Updates all setup-soldr@v0 invocations across workflows and the build-target composite action, plus the dev dependency in pyproject.toml. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * perf(stop-hook): route every stage through soldr cargo zccache-ci's stages were a mix of toolchains: Full mode: lint -> uv run python -m ci.lint --fix (uses soldr cargo) cross-check -> cargo check --target musl ... (bare cargo) test -> cargo test ... (bare cargo) Quick mode: quick-check -> uv run cargo check ... (bare cargo via uv) soldr passes `--target <host triple>` to cargo, so its invocations land in `target/x86_64-pc-windows-msvc/debug/`. Bare cargo with no `--target` lands in `target/debug/`. The two trees don't share rlib/ rmeta artifacts — only the proc-macro/build-script subtree. Cold-cache bench in this branch showed `clippy --all-targets` populates both dirs in a single invocation (615MB to msvc, 522MB to debug for proc-macros). The downstream test stage then re-compiled the whole workspace from scratch because its `target/debug/` was missing the real rlibs. zccache showed a 0% hit rate for a normal stop-hook run. Switching every stage to `soldr cargo` consolidates to one target dir (`target/x86_64-pc-windows-msvc/debug/`) so clippy's artifacts are reused by test/check. zccache's rustc-wrapper cache also starts hitting. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- 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.
Summary
Request::SessionEndon an unknown (but well-formed) UUID as an idempotent no-op success (Response::SessionEnded { stats: None }) instead of returningResponse::Error.Why
The Stop hook (which runs
zccache-ci) failed with:zccache-cikills the running daemon(s) mid-run so cargo can replace the target binaries on Windows. Sessions are tracked in the daemon's in-memory state, so once the daemon dies all session IDs are forgotten. Build wrappers likesoldrkeepZCCACHE_SESSION_IDin the child environment and then callzccache session-end <id>at exit, hitting a fresh daemon that has no record of the UUID. The result was a spurious failure that broke the Stop hook chain.This matches CLAUDE.md's "Speed above all. Ship fast" + "Simplicity first. No over-engineering." principle. We're not persisting sessions across restarts — we just acknowledge that a session whose daemon already died is implicitly ended, so cleanup at exit should succeed.
Changes
crates/zccache-daemon/src/server.rs:SessionEndreturnsSessionEnded { stats: None }when the session doesn't exist (only when the UUID parses).crates/zccache-daemon/src/server.rs: Newcli_session_end_unknown_uuid_is_idempotentintegration test.crates/zccache-daemon/src/server.rs: Update existingcli_session_end_invalid_iddoc-comment so it accurately reflects what it tests (malformed-UUID error path).docs/architecture/ipc.md: Record the new idempotent contract.Test plan
soldr cargo check --workspace --all-targets— cleansoldr cargo clippy --workspace --all-targets -- -D warnings— cleansoldr cargo fmt --all— no changes after running./test— passes (one pre-existingp2_windows_long_path_spillfailure inzccache-artifactkv_stress, unrelated to this change and reproducible onmain)🤖 Generated with Claude Code