Skip to content

diag(daemon): expose key_root + path_remap state in depgraph_check log (#353) - #375

Merged
zackees merged 1 commit into
mainfrom
fix/issue-353-diag-key-root
May 24, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/issue-353-diag-key-root

Conversation

@zackees

@zackees zackees commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Investigative diagnostic for issue #353 — cross-runner cache misses despite #337's load-classifier fix.

This PR does NOT speculatively change cache-key logic. It adds two new tags to the existing `[DIAG] depgraph_check` log line so the next experiment in soldr's `cache-delta-experiment.yml` can bisect the failure empirically rather than by guess.

New log fields

```
[DIAG] depgraph_check: -> ctx=<8hex> verdict= reason= key_root= path_remap=
```

  • `key_root=` — the resolved worktree root used to normalize paths in `compute_context_key`. Two runners with divergent `key_root` produce divergent `context_key` hashes and the persisted depgraph won't match any of them.
  • `path_remap=` — one of:
    • `auto` — `ZCCACHE_PATH_REMAP=auto` set AND `find_git_root` resolved a `.git/` ancestor.
    • `auto_no_git` — env var requested but `find_git_root` returned None. This exposes the silent-fallback case the issue's ask Fix cross-platform path handling in linker detection #2 documents.
    • `off` — env var not set.

Investigation summary (posted as issue comment)

  • Rustc absolute path is not in cache keys (only content hash; verified in `daemon/server/rustc.rs:76` + `depgraph/context.rs:428`). Rules out issue ask No-op: Build badges already present on main #4.
  • `env_vars` filters to `CARGO_*` and excludes volatile-path variants (`CARGO_MANIFEST_DIR`, `CARGO_MANIFEST_PATH`, `CARGO_MAKEFLAGS`, `CARGO_INCREMENTAL`).
  • The depgraph load classifier from fix(daemon): auto-classify warm + warn on bad persisted depgraph (#320) #337 is fully visible — `Loaded` / `VersionMismatch` / `Corrupt` / `IoError` / `Missing` all surface a warning into `last-session.log`.
  • The most plausible un-ruled-out failure mode is silent path-remap fallback when `.git/` isn't detected by `find_git_root`. `effective_compile_args` bails out at `let Some(root) = worktree_root else { return expanded_args.to_vec(); }` without adding `--remap-path-prefix`. The new `path_remap=auto_no_git` tag exposes this.

`miss_reason` (acceptance criterion #3) is already shipped in 1.9.0 in `compile_journal` JSON entries (`context_not_found`, `input_fingerprint_mismatch`, `no_artifact_for_key`, `version_skew`, `uncacheable_input`, `unknown`).

How to use this for bisection

Re-run `cache-delta-experiment.yml` once this lands. Diff the two runners' `last-session.log`:

```bash
diff <(grep '[DIAG] depgraph_check' runner-a/last-session.log)
<(grep '[DIAG] depgraph_check' runner-b/last-session.log)
```

If `key_root=` matches and `path_remap=` matches but `ctx=` differs → cache-key derivation has a hidden runner-specific input (escalate to a focused unit test).
If `key_root=` differs → silent path-remap failure on one runner (likely `.git/` not detected); fix is to surface the failure as a hard error or have `find_git_root` walk more aggressively.

🤖 Generated with Claude Code

#353)

Issue #353 reports 0% hit rate in cross-runner `actions/cache@v4` scenarios
despite #320's load-classifier fix shipping. Root cause is suspected to be one
of:

1. The cross-runner case re-enters a different cold-classifier branch.
2. A code path embeds runner-specific state in cache keys.
3. Toolchain reinstall between runs shifts a hash input.

The investigation chain in the issue text rules out (2) for the rustc binary
(content hash, not absolute path; verified in `daemon/server/rustc.rs:76`) and
filters env_vars to `CARGO_*` minus volatile-path variants. But the issue
explicitly asks the maintainer to document `ZCCACHE_PATH_REMAP=auto`'s
auto-detection contract — specifically, the silent-fallback case where the env
var is set but `find_git_root` returns None.

This PR makes that case visible. The `[DIAG] depgraph_check` log line now
includes:

    key_root=<resolved-path-or-cwd-fallback>
    path_remap=<auto|auto_no_git|off>

`auto_no_git` is the new tag: `ZCCACHE_PATH_REMAP=auto` was requested but
`.git/` was not detected anywhere up the CWD ancestry, so `effective_compile_args`
silently fell through without inserting `--remap-path-prefix`. Two runners that
both think they're applying remap but disagree on whether git was found will
produce divergent `key_root` values, divergent `context_key` hashes, and the
`cold_skip` symptom #353 describes.

Helper `diag_path_remap_state(client_env, worktree_root.is_some()) -> &str`
lives in `daemon/server/keys.rs` next to `path_remap_auto_enabled` to keep
handle_compile.rs under the 1500-LOC `loc_guard` cap.

Acceptance criterion #3 from the issue (miss_reason in journal) was already
shipped in #322; this PR adds the complementary human-readable diagnostic for
log-grep bisection. With these two tags present, the cross-runner experiment
in soldr's `cache-delta-experiment.yml` can diff the per-runner DIAG lines and
say definitively whether the regression is (1) key drift or (2) load-side.
@zackees
zackees merged commit 662ca89 into main May 24, 2026
26 checks passed
@zackees
zackees deleted the fix/issue-353-diag-key-root branch May 24, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant