fix(incremental): fall back to mtime when stale last_indexed_sha exists — closes #117#125
Merged
Merged
Conversation
…ts — closes #117 Bug: find_changed_files() in scripts/incremental.py tried the git-aware path first. If a last_indexed_sha bookmark existed in the DB (from a previous scan when the workspace was a git repo), it called _git_changed() and _git_untracked(). Both return [] when: (a) there are no changes, OR (b) the workspace is not a git repo / git unavailable — the two cases are indistinguishable. Result: on a non-git workspace with a stale last_indexed_sha, incremental scan returned (changed=[], new=[], deleted=[]) without falling back to the mtime path. File modifications were silently missed. Fix: after retrieving last_indexed_sha, verify the workspace is still a git repo by calling get_current_sha(). If it returns None (workspace is not a git repo or git unavailable), fall through to the mtime-based _find_changed_files_mtime() path instead of trusting the empty git result. Verified: incremental scan now correctly detects file modifications on non-git workspaces with a stale last_indexed_sha bookmark (changed_files_count: 1 instead of 0). All 6 previously-failing test_graph_incremental tests now pass.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Fixes RED TEAM issue #117:
find_changed_files()silently returned empty(changed=[], new=[], deleted=[])on non-git workspaces that had a stalelast_indexed_shabookmark in the DB, causing incremental scan to miss file modifications.Root cause
find_changed_files()inscripts/incremental.pytried the git-aware path first. If alast_indexed_shabookmark existed in the DB (from a previous scan when the workspace was a git repo), it called_git_changed()and_git_untracked(). Both return[]when:The two cases are indistinguishable, so on a non-git workspace with a stale SHA, the function returned empty lists without falling back to the mtime path.
Fix
After retrieving
last_indexed_sha, verify the workspace is still a git repo by callingget_current_sha(). If it returnsNone(workspace is not a git repo or git unavailable), fall through to the mtime-based_find_changed_files_mtime()path instead of trusting the empty git result.Verification
Reproduced the bug from #117 and verified the fix:
All 6 previously-failing
test_graph_incremental.pytests now pass:test_renamed_function_reflected_in_graph✅test_added_function_reflected_in_graph✅test_removed_function_reflected_in_graph✅test_graph_has_no_orphan_edges_after_removal✅test_incremental_scan_with_modification_updates_graph✅test_auto_scans_on_fresh_workspace✅Test plan
Risk
Low. The fix only adds a git-repo verification check before trusting git-diff results. If the workspace IS a git repo, behavior is unchanged. If it's NOT a git repo, we now correctly fall back to mtime instead of silently returning empty.