feat: add qdrant vector adapter

This commit is contained in:
2026-08-08 17:43:15 +02:00
parent c875fa52ce
commit 7109ee15c4
8 changed files with 830 additions and 6 deletions
@@ -0,0 +1,98 @@
# Task 5 Report — Implement the Qdrant VectorStore adapter
## Status
Implemented on 2026-08-08 in `/Users/mp/projects/ThothII/.worktrees/git-workspace-registry`.
## RED evidence
Command:
```bash
cd harness
./.venv/bin/pytest tests/test_qdrant_vector_store.py tests/test_vector_port_contract.py -q
```
Observed before implementation:
- exit code `2`
- collection failed during import because the adapter did not exist yet
Representative failures:
- `ModuleNotFoundError: No module named 'tht.adapters.vector.qdrant'`
## GREEN evidence
Focused behavior suite:
```bash
cd harness
./.venv/bin/pytest tests/test_qdrant_vector_store.py tests/test_vector_port_contract.py -q
```
- exit code `0`
- `31 passed, 1 warning`
Touched-file lint:
```bash
cd harness
./.venv/bin/ruff check tht/adapters/vector/qdrant.py tht/adapters/vector/__init__.py \
tht/ports/vector.py tht/vectorstore/records.py tht/vectorstore/store.py \
tests/test_qdrant_vector_store.py tests/test_vector_port_contract.py
```
- exit code `0`
- `All checks passed!`
Patch hygiene:
```bash
git diff --check
```
- exit code `0`
## What changed
- added `QdrantVectorStore` with direct `requests`-based REST calls for:
- `GET /collections/{collection}`
- `PUT /collections/{collection}`
- `PUT /collections/{collection}/index`
- `PUT /collections/{collection}/points?wait=true`
- `POST /collections/{collection}/points/query`
- `POST /collections/{collection}/points/scroll`
- `POST /collections/{collection}/points/delete?wait=true`
- implemented idempotent collection provisioning for `1024` dimensions and `Cosine` distance
- created deterministic UUIDv5 point IDs from workspace, semantic kind, and canonical record key
- preserved canonical record identity and only upserted/deleted points matching the exact workspace
and generation filters
- added Qdrant payload helpers so stored payloads carry:
- `workspace_id`
- grouped semantic `kind` (`schema`, `evidence`, `memory`)
- original `record_kind`
- canonical `record_key`
- `content_hash`
- existing Thoth metadata fields
- mapped Qdrant payloads back into existing `VectorHit` objects without losing the original
Thoth kind
- exported the new adapter from the public vector adapter package and added focused contract tests
- sanitized timeout and malformed-response failures so CLI-facing callers do not leak raw endpoint
details
## Self-review
- confirmed collection mismatch fails without any delete/recreate path
- confirmed every query/scroll/delete operation includes a workspace filter
- confirmed the adapter never deletes or rewrites unrelated Qdrant points
- added keyword payload indexes for all filter-critical fields used here, including `document_id`
for exact Evidence filtering
## Concerns
- the requested `adversarial-review` skill could not run its full external reviewer flow in this
environment because the skill’s referenced `brain/` files are missing at
`/Users/mp/.agents/skills/adversarial-review`; I performed a manual adversarial self-review
instead
- the focused suite still emits one pre-existing warning from `testcontainers.postgres`