fix: prune orphaned service data on rename/removal (#75)#89
Merged
Conversation
…ml (#75) When a service is renamed or removed from config.yaml, the old service name's points remain in both the code symbols and git commits Qdrant collections, showing up in unfiltered searches. Add a shared prune_orphaned_services() utility (via PrunableStore protocol) that compares indexed service names against the configured set and deletes orphaned data. Wire it into both IndexPipeline.index_all and GitHistoryPipeline.index_all so it runs automatically on every full reindex (POST /reindex and POST /reindex-history).
…erage An empty configured-services set (e.g. config.yaml with services: []) would previously cause every indexed service to be treated as orphaned and deleted. Also ensures the collection exists before pruning, filters the "unknown" service placeholder out of get_indexed_services, and adds tests for the new pruning behavior across cleanup.py, pipeline.py, git_history.py, and qdrant.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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 #75 — when a service is renamed or removed from
config.yaml, its old points remain orphaned in both the code symbols and git commits Qdrant collections, showing up in unfiltered searches.Changes
server/indexer/cleanup.py— Defines aPrunableStoreprotocol and a sharedprune_orphaned_services()function that compares indexed service names against the configured set and deletes orphaned data.server/store/commit_store.py— Addedget_indexed_services()(scrolls commits, collects distinct service names) anddelete_by_service()(deletes all commit points for a service).server/store/qdrant.py— Addedget_indexed_services()(delegates to existingget_service_stats(), filtering out the internal"unknown"placeholder so it can never be treated as an orphaned service name).server/indexer/pipeline.py— Callsensure_collection()thenprune_orphaned_services()at the start ofIndexPipeline.index_all().server/indexer/git_history.py— Callsensure_collection()thenprune_orphaned_services()at the start ofGitHistoryPipeline.index_all().Safety fix (post-review)
Code review flagged that an empty configured-services set (e.g.
config.yamlwithservices: [], or the key missing) would previously causeprune_orphaned_services()to treat every indexed service as orphaned and wipe the entire store. Fixed: the function now refuses to prune and logs a warning when the configured set is empty, since that's far more likely to be a config error than an intentional wipe-everything request.Behavior
POST /reindex(no service)POST /reindex-history(no service)POST /reindexwith"service": "foo"reindex()MCP tool (no service arg)reindex(service="foo")MCP toolconfig.yamlhas no configured services (empty/missing)Testing
uv run pytest), including 10 new tests added in this update:tests/test_cleanup.py(new) — orphan deletion, configured-service protection, empty-config guard, no-op on empty store, sorted multi-orphan outputtests/test_pipeline.py/tests/test_git_history.py—index_all()prunes orphans before indexing, and skips pruning when no services are configuredtests/test_store.py—QdrantStore.get_indexed_services()excludes the"unknown"placeholderruff checkandruff format --checkpass clean