Skip to content

perf(memory): re-index edited files when code recall finds them - #475

Merged
mrnasil merged 1 commit into
mainfrom
perf/code-recall-reindex-edited
Nov 25, 2026
Merged

mrnasil merged 1 commit into
mainfrom
perf/code-recall-reindex-edited

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

What

Code search (per-turn recall, memory code-search, the tool) now checks the files behind its FTS candidates and indexes again any file modified after it was indexed, then searches once more. A file that no longer exists drops out.

Why

#473 refreshes the code index at session start only. A file the agent edits during the session is recalled with its old text and stale line ranges until the next session, which is exactly the code the conversation is about.

Cost

One stat per distinct candidate path (≤256 candidates, usually far fewer files); re-indexing happens only for files that actually changed.

Notes

  • The re-indexed file keeps all its chunks (still bounded by the 400 KB file limit), so an edit that grows the file does not lose its new code to the cap.
  • Tests that inserted chunks for paths that did not exist now create those files; otherwise search treats them as deleted.

Tests

  • search_reindexes_candidate_files_edited_since_indexing: an edited file returns its new text and shifted line range, a deleted one disappears from hits and the index.
  • cargo test -p whycodes-memory, fmt, clippy, budgets; memory line coverage measured locally (only the pre-existing Windows-only misses remain).

🤖 Generated with Claude Code

The code index is refreshed at session start only, so a file the agent
edits mid-session is recalled with its old text and line ranges until
the next session. Code search now checks the files behind its FTS
candidates (one stat each) and indexes again any that changed since
they were indexed before ranking; a deleted file drops out. The file
keeps all its chunks so an edit that grows it does not lose the new
code to the cap.

Tests that insert chunks for paths now create those files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit 56defc3 into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/code-recall-reindex-edited branch November 25, 2026 11:36
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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