Skip to content

eval-cache: track local sources copied into the store during evaluation#2899

Open
domenkozar wants to merge 1 commit into
mainfrom
fix/track-eval-source-copies
Open

eval-cache: track local sources copied into the store during evaluation#2899
domenkozar wants to merge 1 commit into
mainfrom
fix/track-eval-source-copies

Conversation

@domenkozar

Copy link
Copy Markdown
Member

Fixes #2886 and #2893 — two reports of the same root cause: local files and directories pulled into the Nix store by path coercion (e.g. scripts.foo.exec = ./foo.sh; or languages.rust.import ./.) were not recorded as eval-cache dependencies, so editing them returned stale devenv build/shell results until the cache was manually refreshed with --refresh-eval-cache.

Root cause

devenv's eval-cache dependency tracker observes Nix's structured log stream, capturing messages up to lvlTalkative. The copied source '…' -> '…' event — emitted whenever a path is copied into the store via coercion — was a free-text log line at lvlChatty (one level above the capture threshold), so it was never observed. builtins.path/filterSource worked only because they separately emit devenv path: at Talkative.

Fix

Rather than chase verbosity levels (raising the global capture knob would ingest unbounded per-derivation instantiated … chatter), source copies are now a structured activity, which the JSON/FFI logger delivers regardless of verbosity.

Nix backend (cachix/nix devenv-2.34, commit 4bc81008c, pin bumped here): copyPathToStore emits an actEvalCopySource activity carrying the source and destination store paths as fields (the activity text preserves the previous human-readable line for -vv).

This repo:

  • Parse the eval-copy-source activity into an EvalOp::CopiedSource (eval_op.rs, internal_log.rs, nix_log_bridge.rs).
  • Copied directories are now hashed recursively over their contents (new recursive flag + file_input.recursive column) so edits to nested files invalidate the cache; readDir-only directories keep the cheaper name-only hashing to avoid spurious invalidation.
  • Bump the cachix/nix pin (flake.lock + devenv.lock).

Verification

End-to-end against the patched Nix, with no --refresh-eval-cache:

Unit tests: 169 devenv-core + 223 eval-cache/cache-core green.

🤖 Generated with Claude Code

Local files and directories pulled into the Nix store by path coercion
(e.g. `scripts.foo.exec = ./foo.sh;` or `languages.rust.import ./.`) were
not recorded as eval-cache dependencies, so editing them returned stale
`devenv build`/shell results until the cache was manually refreshed.

The "copied source" event was only emitted as a free-text log line at
lvlChatty, above devenv's lvlTalkative capture threshold, so it was never
observed. The Nix backend (cachix/nix devenv-2.34) now emits it as a
structured `eval-copy-source` activity carrying the source and destination
paths; activities are delivered regardless of verbosity.

- parse the `eval-copy-source` activity into an `EvalOp::CopiedSource`
- copied directories are hashed recursively over their contents (new
  `recursive` flag + `file_input.recursive` column) so edits to nested
  files invalidate the cache; `readDir`-only directories keep the cheaper
  name-only hashing
- bump the cachix/nix pin to the commit emitting the activity

Fixes #2886, #2893.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Suggested Reviewers

Based on git blame analysis of the changed lines, the following contributors have significant experience with the modified code:

  • @sandydoo - 100.0% of changed lines (5 lines)

Please consider reviewing this PR as you have authored significant portions of the code being modified. Your expertise would be valuable! 🙏

This comment was automatically generated by git-blame-auto-reviewer

Last updated: 2026-06-04T02:58:48.352Z

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying devenv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1ddd71a
Status: ✅  Deploy successful!
Preview URL: https://a59938af.devenv.pages.dev
Branch Preview URL: https://fix-track-eval-source-copies.devenv.pages.dev

View logs

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.

devenv build returns stale rust output

1 participant