Skip to content

fix: filter false-positive "changed" files in incremental detection#17

Merged
SutuSebastian merged 1 commit into
mainfrom
fix/incremental-false-positive-changed
Apr 8, 2026
Merged

fix: filter false-positive "changed" files in incremental detection#17
SutuSebastian merged 1 commit into
mainfrom
fix/incremental-false-positive-changed

Conversation

@SutuSebastian

@SutuSebastian SutuSebastian commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Incremental detection (getChangedFiles) reported uncommitted files as "changed" on every run, even when their content hash already matched the index — caused by git status --porcelain always including dirty working-tree files
  • Now compares content hashes against the DB during detection, so only truly modified files enter the indexing pipeline
  • Eliminates misleading Incremental: 1 changed logs and unnecessary read+hash work in indexFiles

Test plan

  • bun run check (format, lint, typecheck, tests) all green
  • Verified on external project (merchant-dashboard-v2, 1859 files, dirty working tree) — second consecutive run correctly shows 0 changed, 0 deleted / Index is up to date

Summary by CodeRabbit

Bug Fixes

  • Resolved a false positive issue in incremental change detection where files with uncommitted modifications were repeatedly marked as changed even when their content remained unchanged. This fix improves the accuracy of file change identification and reduces unnecessary reprocessing during incremental indexing operations, enhancing overall indexing efficiency.

getChangedFiles unions git-diff with git-status, but uncommitted files
reported by `git status --porcelain` reappear on every run even when
their content hash already matches the index. This caused misleading
"Incremental: 1 changed" logs and unnecessary read+hash work inside
indexFiles on every invocation.

Compare content hashes in getChangedFiles itself so only truly modified
files enter the changed list.
@SutuSebastian SutuSebastian added the bug Something isn't working label Apr 8, 2026
@SutuSebastian SutuSebastian self-assigned this Apr 8, 2026
@changeset-bot

changeset-bot Bot commented Apr 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 39ef64f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/codemap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9de35510-caf4-42bf-b788-08bacbe43de8

📥 Commits

Reviewing files that changed from the base of the PR and between b5c2570 and 39ef64f.

📒 Files selected for processing (2)
  • .changeset/fix-incremental-false-positive.md
  • src/application/index-engine.ts

📝 Walkthrough

Walkthrough

This change fixes incremental change detection in the indexing engine by modifying getChangedFiles to compare file content hashes against the index instead of relying on existence checks. This prevents unchanged files from being repeatedly marked as changed when the working tree contains uncommitted modifications.

Changes

Cohort / File(s) Summary
Incremental Change Detection Fix
src/application/index-engine.ts
Modified getChangedFiles to compute and compare file content hashes against existingHashes instead of using statSync existence checks. Only marks files as changed when content hash differs from index. Handles missing/unreadable files by placing them in deleted instead of changed.
Changelog Entry
.changeset/fix-incremental-false-positive.md
Documents the fix for incremental change detection false positives in @stainless-code/codemap patch release.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit dug deep through the code,
Hash comparisons lightened the load,
No ghosts in the queue,
Just changes that's true,
Incremental runs skip the redundant road! 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main fix: filtering false-positive changed files in incremental detection, which matches the core problem and solution in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/incremental-false-positive-changed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SutuSebastian SutuSebastian merged commit e962326 into main Apr 8, 2026
9 checks passed
@SutuSebastian SutuSebastian deleted the fix/incremental-false-positive-changed branch April 8, 2026 11:08
@github-actions github-actions Bot mentioned this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant