Skip to content

Comments

fix(cache): prevent diff from corrupting disk cache#158

Closed
rocketman-code wants to merge 1 commit intomainfrom
fix/diff-cache-corruption
Closed

fix(cache): prevent diff from corrupting disk cache#158
rocketman-code wants to merge 1 commit intomainfrom
fix/diff-cache-corruption

Conversation

@rocketman-code
Copy link
Owner

Summary

  • Pass no_cache=true in build_snapshot_from_working_tree so the working-tree side of a diff neither reads nor writes the disk cache, preventing cross-contamination from the git-ref side's reduced graph.

Closes #142

What was happening

When running chainsaw diff <ref> --entry <file>, the git-ref side builds a reduced graph (no node_modules, read from git tree) and writes it to the disk cache. The working-tree side then calls loader::load_graph(entry, false) (no_cache=false), which reads the contaminated cache entry and produces incorrect results. Subsequent chainsaw trace commands also read the corrupted cache until it is manually cleared.

The fix

Change the no_cache argument from false to true in build_snapshot_from_working_tree, matching the behavior already used by build_snapshot_from_ref. This ensures neither side of a diff pollutes the shared cache.

Test plan

  • cargo test --workspace passes (all 274 tests)
  • cargo clippy --workspace --all-targets -- -D warnings passes (via pre-commit hook)
  • Manual: chainsaw diff HEAD~1 --entry <file> followed by chainsaw trace <file> produces correct, consistent results

@rocketman-code
Copy link
Owner Author

Closing: patch contents already on main. Branch has zero diff after rebase.

@rocketman-code rocketman-code deleted the fix/diff-cache-corruption branch February 22, 2026 23:31
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.

bug: diff cache corruption when working tree reads cache written by git-ref side

1 participant