Skip to content

Conversation

Michaelzag
Copy link

@Michaelzag Michaelzag commented Sep 5, 2025

Shared Vector Store Adapter (Qdrant) — Extraction

Related GitHub Issue

Refs: #6223

Note: This PR does not close #6223. It partially addresses the requested "vector database adapter" work by extracting a shared adapter module and providing the Qdrant implementation. Follow‑up PRs can extend this adapter as needed. No additional vector store implementations are included here.

Description

This PR extracts Qdrant vector‑store logic from Code Index into a shared, provider‑agnostic adapter. It keeps Code Index behavior the same, generalizes settings labels from “Qdrant …” to “Vector Database …”, and removes the legacy client after verifying tests.

Key implementation points:

  • New shared adapter module under src/services/vector-store/:
    • interfaces.ts: VectorDatabaseAdapter, VectorRecord, VectorFilter, DatabaseCapabilities, VectorStoreConfig.
    • errors.ts: adapter‑level error taxonomy.
    • filters.ts: FilterTranslator + QdrantFilterTranslator (directory prefix, delete filters via pathSegments.*).
    • collection-manager.ts: ensure‑once cache per collection:dimension.
    • adapters/qdrant.ts: QdrantAdapter with URL/port normalization, ensure + dimension mismatch recreate, payload index creation, upsert shaping, search, delete‑by‑filter.
    • factory.ts: VectorStoreFactory.create() (Qdrant only for now).
  • Code Index integration:
    • src/services/code-index/vector-store-adapter.ts: wrapper implementing IVectorStore by delegating to shared adapter; preserves parity and no‑op delete when collection missing.
    • src/services/code-index/service-factory.ts: switches to shared factory + wrapper; preserves config and dimension resolution.
  • UI: generalized i18n labels to “Vector Database URL/API Key” across all locales (no config schema changes).
  • Removed legacy files: src/services/code-index/vector-store/qdrant-client.ts and its tests.
  • Optional collection isolation: an optional collectionSuffix is supported; default behavior is unchanged.

Compatibility

  • No breaking changes. Code Index continues to work with the same configuration and data.
  • Collection naming remains stable; an optional suffix is available for isolated collections when required. (Conversation Memory #7537 will use this)

Test Procedure

  • Contract tests cover ensure, upsert/search, filter translation, and delete‑by‑filter.
  • Qdrant adapter tests cover URL/port handling, payload index creation, and collection suffix.
  • Wrapper tests cover directory‑prefix filters and delete‑by‑paths behavior.
  • Full repo type‑check, lint, and tests are green.

Pre-Submission Checklist

  • Issue Linked
  • Scope limited to the linked issue
  • Self-Review performed
  • Tests updated/added
  • Documentation impact considered
  • Read and agree to CONTRIBUTING

Screenshots / Videos

Follow‑ups

  • Conversation Memory can use this adapter with a collection suffix and a KV filter translator (separate PR) without touching Code Index. (yay!)

Important

Extracts Qdrant vector-store logic into a shared adapter module, updates Code Index integration, and generalizes UI labels.

  • Behavior:
    • Extracts Qdrant vector-store logic into a shared adapter module under src/services/vector-store/.
    • Generalizes settings labels from "Qdrant ..." to "Vector Database ...".
    • Removes qdrant-client.ts and its tests from src/services/code-index/vector-store/.
  • Adapter Module:
    • Adds interfaces.ts, errors.ts, filters.ts, collection-manager.ts, adapters/qdrant.ts, and factory.ts.
    • Implements QdrantAdapter with URL/port normalization, collection management, and CRUD operations.
  • Code Index Integration:
    • Updates vector-store-adapter.ts to use the shared adapter.
    • Modifies service-factory.ts to switch to the shared factory and adapter.
  • UI:
    • Updates i18n labels to "Vector Database URL/API Key" across all locales.
  • Testing:
    • Adds contract tests for adapter operations.
    • Updates existing tests to reflect the new adapter structure.

This description was created by Ellipsis for b63ebfb. You can customize this summary. It will automatically update as commits are pushed.

… add collection suffix; remove legacy client; generalize labels

- Add shared vector-store module (interfaces, factory, filters, errors, collection manager)
- Implement Qdrant adapter with URL normalization, ensure+recreate, payload indexes, search/delete
- Add Code Index wrapper and update service factory (no behavior changes)
- Support optional collectionSuffix for isolated collections
- Update tests for factory/adapter; remove legacy client/tests
- Generalize settings labels to "Vector Database" across locales

Refs: RooCodeInc#6223
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this well-structured refactoring! The extraction of Qdrant vector store logic into a shared, provider-agnostic adapter pattern is clean and maintains backward compatibility while setting up a solid foundation for future vector database integrations.

Positive aspects:
✅ Clean separation of concerns with the adapter pattern
✅ Maintains backward compatibility - no breaking changes
✅ Good test coverage with contract tests, unit tests, and integration tests
✅ Proper error handling with custom error taxonomy
✅ Smart collection management with ensure-once caching
✅ Thoughtful i18n updates generalizing from "Qdrant" to "Vector Database"

I've left some suggestions inline that could improve the implementation further, but overall this is a solid architectural improvement that aligns well with the incremental approach requested in issue #6223.

@Michaelzag
Copy link
Author

I'll address those roomote suggestions. Heading home for the day so it will likely be over the weekend or Tuesday.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 5, 2025
- Fix collection manager concurrency race conditions with in-flight tracking
- Integrate custom error classes (UnsupportedProviderError, DimensionMismatchError, CollectionInitError)
- Make provider types flexible (string) instead of hard-coded 'qdrant'
- Implement dynamic provider registry with auto-updating error messages
- Fix cross-platform path handling by normalizing to forward slashes
- Clean up unused parameter with meaningful logging for dimension changes
- Add comprehensive CollectionManager unit tests (19 tests)
- Enhance factory tests for new provider registration functionality
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Sep 6, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 6, 2025
@Michaelzag Michaelzag marked this pull request as ready for review September 10, 2025 13:16
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Sep 10, 2025
Michaelzag and others added 2 commits September 10, 2025 09:25
Typographical inconsistency: "URL del database vettoriale non valida" should likely be "non valido" to match the masculine form used elsewhere (e.g., in 'URL Ollama non valido').

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Typographical suggestion: In the string "URL de base de données vectorielle", consider adding the article "la" for grammatical consistency (e.g., "URL de la base de données vectorielle").

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hannesrudolph
Copy link
Collaborator

@Michaelzag you still on this?

@Michaelzag
Copy link
Author

Ya the pr is waiting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: PR [Needs Prelim Review]

Development

Successfully merging this pull request may close these issues.

Support for Alternative Vector Databases in Codebase Indexing

3 participants