fix(incremental): reconcile reverted file content - #860
Conversation
Compare indexed file hashes with current bytes so an edit followed by a revert is reparsed even when the git diff is empty or another file keeps it non-empty. Closes tirth8205#817
|
The fix itself is sound and the regressions are valid; I confirmed both new tests fail on main. My concern is where the scan runs. _find_content_mismatches (incremental.py:711) is invoked unconditionally at the top of incremental_update, so it stats, reads, and sha256s every indexed file on every call. On the CLI path _reconcile_stale_files already does a full scan, so there it roughly doubles read cost (103ms to 170ms no-op on a 2000-file repo here). Watch mode is the real problem: batches call incremental_update with reconcile_stale=False precisely to stay proportional to events, and this adds a full-repo read to every debounced batch (0ms to 62ms at 2000 files, linear in repo bytes). Watch does not need the scan: a revert generates its own event, so the file is already in the batch and the existing hash check covers it. Please gate the scan on reconcile_stale or a dedicated flag. Optional: pass the computed hashes forward so mismatched files are not read and hashed again in the quick-check loop. |
|
Thanks for the benchmark. I gated the content scan on |
code-review-graph reviewOverall risk: 0.60 (MEDIUM) — 9 changed function(s)/class(es), 0 affected flow(s), 4 test gap(s) Risk-scored changes
Test gaps
Token savings: this graph-backed report used ~55,534 fewer tokens (~96%) than reading every changed file in full (estimated, chars/4 approximation). Powered by code-review-graph — local-first analysis; no code leaves the CI runner. |
Problem
An incremental update discovers work solely from the VCS diff. If a file is edited, indexed, and then reverted to bytes identical to the diff base, that file disappears from the next diff. The graph keeps nodes and edges from the intermediate content until an unrelated event causes that path to be reparsed.
This also happens when another file keeps the diff non-empty: the reverted file is simply absent from the changed-path set and is never considered.
Fix
Filenodes.Hash comparison is independent of git history, so it works regardless of which valid diff base the caller selects.
Tests
mainand passes with this change.Closes #817