fix(mcp): clear the indexing pin when the 0/0 guard rejects a result - #427
Open
EricSeastrand wants to merge 1 commit into
Open
fix(mcp): clear the indexing pin when the 0/0 guard rejects a result#427EricSeastrand wants to merge 1 commit into
EricSeastrand wants to merge 1 commit into
Conversation
`SnapshotManager.setCodebaseIndexed()` refuses to persist `0 files / 0 chunks / completed` (the Issue zilliztech#295 force-reindex-loop guard, added in zilliztech#296). The guard returns early — but the `indexingCodebases.delete()` that ends the indexing state lives *below* the guard, so the codebase is left pinned in `indexingCodebases` forever. User-visible effect: `get_indexing_status` reports "currently being indexed, Progress: 100.0%" indefinitely, and after a restart the same entry comes back as "interrupted (MCP server restarted)". `force: true` does not help, because the codebase never leaves the indexing set. The index job itself has already finished — nothing is running. This is easy to hit whenever a scan legitimately yields zero files (for example an over-broad ignore pattern): the guard is doing the right thing by refusing the write, but it leaves the codebase in a state no user action can clear. Fix: instead of a bare `return`, record the codebase as `indexfailed` with an actionable message. `setCodebaseIndexFailed()` already clears the indexing entry, so the terminal state is honest ("failed, here's why") rather than a frozen 100%. Adds `packages/mcp/src/snapshot.zero-guard.test.ts`, which fails on `master` (the path stays in `getIndexingCodebases()`) and passes with the fix, plus a companion assertion that a normal non-zero index is still recorded as `indexed`. It isolates via `HOME`/`USERPROFILE` the same way `snapshot.request-options.test.ts` does, so no new test seam is needed.
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.
Problem
SnapshotManager.setCodebaseIndexed()refuses to persist0 files / 0 chunks / completed— the Issue #295 force-reindex-loop guard, which I added in #296. The guard is correct, but it returns early, and thethis.indexingCodebases.delete(codebasePath)that ends the indexing state lives below it:https://github.com/zilliztech/claude-context/blob/6fc318b/packages/mcp/src/snapshot.ts#L428-L440
So a rejected result leaves the codebase pinned in
indexingCodebaseswith no way out.Symptoms
get_indexing_statusreports "currently being indexed, Progress: 100.0%" forever, while nothing is running — the index job finished in milliseconds.index_codebasewithforce: truechanges nothing, because the codebase never leaves the indexing set.How it is reached
Any scan that legitimately yields zero files after filtering. In my case a repo whose
.dockerignoreis a single*line —loadIgnorePatterns()globs every.*ignorefile in the repo root, so the entire corpus was filtered out and the indexer completed with0/0. (That ignore-file question is a separate PR; this one is only about the terminal state.) Any over-broad ignore pattern, or an empty/binary-only directory, gets there the same way.Fix
Replace the bare
returnwithsetCodebaseIndexFailed(...)and an actionable message. That helper already clears the indexing entry, so the codebase lands in an honest terminal state (indexfailed, with a reason) instead of a frozen 100%. The #295 protection is unchanged —0/0/completedis still never persisted asindexed.Test
packages/mcp/src/snapshot.zero-guard.test.ts:master— aftersetCodebaseIndexing(path, 100)+ a0/0/completedresult, the path is still ingetIndexingCodebases();getCodebaseStatus()isindexfailed;indexed(guard not over-firing).It isolates via
HOME/USERPROFILEexactly like the existingsnapshot.request-options.test.ts, so no new constructor/test seam was needed.pnpm --filter @zilliz/claude-context-mcp test→ 8/8 passing;tsc --noEmitclean.