fix: zilliztech/claude-context#419 - #425
Open
Zewang0217 wants to merge 1 commit into
Open
Conversation
Zewang0217
marked this pull request as ready for review
August 13, 2026 04:26
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.
Summary
Fixes the sync-from-cloud "recovery" logic in
syncIndexedCodebasesFromCloud()force-marking an in-progress indexing run ascompleted, silently truncating the index to whatever partial batch count happened to exist in Milvus at the time.The guard at
packages/mcp/src/handlers.ts:299skips recovery for any codebase whose local snapshot status isindexing, leaving the real run to finish normally.Why this fixes it
The recovery loop only checked whether a cloud collection was missing from
getIndexedCodebases(). A codebase that's actively indexing is tracked separately (statusindexing), so it's not in that indexed set — but its partial chunk batches are already in Milvus, since chunks flush to the DB inEMBEDDING_BATCH_SIZE-sized batches as the background task progresses. The recovery branch saw "cloud has rows, not locally indexed" and adopted the collection ascompletedusing whatever row count existed at that instant.That made indexing of large codebases report "✅ fully indexed" after only the first batch or two, at a nondeterministic truncation point (we observed 100, 200, and 400 files marked complete on the same ~2,600-file codebase), with no error and no
indexfailedstatus to signal the corruption.Verification
packages/mcp/src/handlers.sync-cloud.test.tswith two cases:indexingwith partial rows in Milvus staysindexingafter sync; it's not added to the indexed list.node --import tsx --test "src/**/*.test.ts"→ 8/8 tests green.Implementation details
A single early
continuein the recovery loop whensnapshotManager.getCodebaseStatus(cloudCodebase) === 'indexing'. The change is intentionally narrow — it only excludes codebases the server already knows are mid-run, so genuinely unknown collections (the legitimate recovery case) are unaffected.Closes #419.