Skip to content

fix(cache): invalidate map cache on dirty working tree changes#3

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-65b7
Draft

fix(cache): invalidate map cache on dirty working tree changes#3
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-65b7

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 31, 2026

Bug and impact

ctx map could return stale repository maps while developing with uncommitted changes. After the first run on a dirty repo, subsequent edits did not invalidate the map-level cache, so agents received outdated signatures/ranking until the repo was committed or --no-cache was used.

Root cause

git_commit_key() returned a stable dirty-<hash> derived only from the scan directory paths when the working tree was dirty. The commit message claimed mtime-based invalidation, but porcelain/status was never incorporated—so the map cache key stayed constant across edits.

Fix

For dirty git repos, the cache key is now dirty-<HEAD>-<hash(git status --porcelain)>, invalidating whenever the working tree changes. Clean repos still use the HEAD SHA.

Validation

  • Added test_git_commit_key_dirty_changes_with_working_tree
  • cargo test --lib cache:: — 6 passed
  • cargo test --locked — full suite passed
Open in Web View Automation 

git_commit_key() used only a hash of directory paths for dirty repos,
so ctx map returned stale output after uncommitted edits. Include
git status --porcelain in the dirty key (with HEAD SHA) so the cache
invalidates on any working-tree change.

Co-authored-by: Jaime Basso <JaimeJunr@users.noreply.github.com>
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