Repository navigation
fix(daemon): auto-classify warm + warn on bad persisted depgraph (#320) - #337
Merged
Merged
Conversation
Issue #320 reported that a fresh zccache daemon emitted `verdict=Cold reason=cold_skip` on every lookup of warm rebuilds even when the on-disk `depgraph.bin` from a prior session was present and valid. The daemon was already loading the depgraph at startup, but a load failure (version mismatch / corruption) only logged via `tracing::warn!` — which gets swallowed by the daemon's `detach_stdio()` and so was invisible in both stderr and the per-session `last-session.log`. Option 2 from the issue: classify the session by what is on disk, not by session lineage. No new flag, no protocol bump. Changes: - `zccache-depgraph`: add `classify_load(path) -> DepGraphLoadOutcome` with structured `Loaded` / `Missing` / `VersionMismatch` / `Corrupt` / `IoError` variants. Each non-`Loaded` variant carries a human-readable warning via `DepGraphLoadOutcome::warning(path)`. Unit-tested in `snapshot.rs`. - `zccache-daemon` main: replace ad-hoc load+log with `classify_load`. Print warnings to stderr at startup AND forward them to `DaemonServer::set_depgraph_load_warning` so the daemon can mirror them into every session log at `SessionStart`. This makes the cold fallback visible in `last-session.log`. - `zccache-daemon` server: new `Mutex<Option<String>>` field on `SharedState` plus `handle_session_start` mirrors the warning into the session log on the first write. - Integration tests covering: valid file → warm, missing → no warning, corrupt → warning, version-mismatch → warning, loaded-but-artifact- missing → still classified warm (artifact existence is a downstream miss, not a classifier responsibility). No `PROTOCOL_VERSION` bump (no wire change). `--no-depgraph-cache` behavior is preserved. Closes #320 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
May 22, 2026
PR #336 added a `profile: bool` field to `Request::SessionStart` while PR #337 (merged minutes earlier) added a test that constructs SessionStart without it. Independently both compiled; together they don't. Add the missing field so main builds. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
May 22, 2026
* feat(cli): zccache defender-exclusions helper for Windows cache root Cold zccache builds on Windows pay multi-minute Defender real-time-scan penalties on every cached artifact write. The pathology is invisible to zccache telemetry — the daemon sees its writes complete; the wall clock balloons between `write()` and the bytes landing on disk. Add a `zccache defender-exclusions` subcommand with three modes that collapse the fix into a single, copy-pasteable command: - `check`: prints exclusion status (human-readable + `--json`), non-destructive, no elevation required. - `add`: adds the cache root (and any sibling `runtime/`) via `Add-MpPreference -ExclusionPath`. Requires admin; exits non-zero with a "re-run from elevated shell" message otherwise — never attempts UAC. - `remove`: symmetric undo of `add`. On non-Windows the subcommand prints `Defender exclusion is Windows-only.` and exits 0 so cross-platform scripts can call it unconditionally. The Windows daemon emits a one-line stderr warning on startup when the cache root isn't excluded. Suppressible via `ZCCACHE_QUIET=1`. Non-fatal. Path-set computation, token-elevation detection (`GetTokenInformation` / `TokenElevation`), the quiet-env predicate, and the PowerShell subprocess plumbing live in `zccache-core::defender` so the daemon's first-run banner and the CLI subcommands share one implementation. Closes #273 * fix(test): set profile: false in depgraph warm classify test PR #336 added a `profile: bool` field to `Request::SessionStart` while PR #337 (merged minutes earlier) added a test that constructs SessionStart without it. Independently both compiled; together they don't. Add the missing field so main builds. 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 23, 2026
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 #320.
Summary
zccache v1.8.1 emitted
verdict=Cold reason=cold_skipfor every lookup onwarm rebuilds even when the persisted
depgraph.binfrom a prior session waspresent. The daemon was already loading the depgraph at startup, but a load
failure (version mismatch / corruption) only logged via
tracing::warn!,which gets swallowed by the daemon's
detach_stdio()— so the cold fallbackwas invisible in both stderr and
last-session.log.This PR ships Option 2 from the issue: classify the session by what is on
disk, not by session lineage. No new flag, no protocol version bump.
Changes
zccache-depgraph— newclassify_load(path) -> DepGraphLoadOutcomewith structured
Loaded/Missing/VersionMismatch/Corrupt/IoErrorvariants. Each non-Loadedvariant emits a human-readablewarning via
DepGraphLoadOutcome::warning(path). Unit-tested insnapshot.rs.zccache-daemonmain.rs — replace ad-hoc load+log withclassify_load. Print the warning to stderr at startup AND forward it toDaemonServer::set_depgraph_load_warningso the daemon mirrors it intoevery session log at
SessionStart. The cold fallback is now visible inlast-session.log.zccache-daemonserver.rs — newdepgraph_load_warning: Mutex<Option<String>>field onSharedState;handle_session_startappends the stashed warning to the session log on the first write.
tests/depgraph_warm_classify_test.rs) — fiveignored-by-default tests covering the acceptance criteria:
Warm,is_coldreturnsfalse(AC zccache: compiler cache designed for speed #1, Fix cross-platform path handling in linker detection #2, [WIP] Add build badges for Windows, Linux, and Mac #3).(AC No-op: Build badges already present on main #4).
(artifact existence is a downstream miss).
Non-changes
PROTOCOL_VERSIONunchanged — no wire format change.--no-depgraph-cachepath is preserved verbatim.depgraph_persistence_testintegration tests still pass.Test plan
soldr cargo fmt --allsoldr cargo clippy --workspace --all-targets -- -D warningssoldr cargo test --workspace --lib— 1370+ unit tests pass, includingfive new
classify_load_*tests insnapshot.rs.soldr cargo test -p zccache-daemon --test depgraph_warm_classify_test -- --ignored— all 5 new integration tests pass.soldr cargo test -p zccache-daemon --test depgraph_persistence_test -- --ignored— existing 3 persistence tests still pass.🤖 Generated with Claude Code