Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

Fix/parse and qdrant vector store (#1508)

yanyushuai5a0d6ea431da
diff --git a/pyproject.toml b/pyproject.toml
index 9a2f9481..95abee0e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -12,7 +12,11 @@ license = { text = "MIT" }
authors = [{ name = "Semantica", email = "[email protected]" }]
maintainers = [{ name = "Semantica", email = "[email protected]" }]
-requires-python = ">=3.8"
+# 3.8 is already unsatisfiable in practice (numpy>=2.0.2 requires >=3.9) and is
+# not exercised by the Install Matrix (3.9-3.12). The floor is 3.9.2 rather
+# than 3.9.0 because cryptography (db-snowflake) excludes 3.9.0/3.9.1 from
+# every release's requires-python, so those patch levels can never resolve.
+requires-python = ">=3.9.2"
classifiers = [
"Development Status :: 5 - Production/Stable",
@@ -22,7 +26,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
@@ -111,7 +114,10 @@ llm-anthropic = ["anthropic>=0.122.0"]
llm-ollama = ["ollama>=0.1.0"]
llm-deepseek = ["openai>=1.0.0"]
llm-novita = ["openai>=1.0.0"]
-llm-litellm = ["litellm>=1.83.9"]
+# litellm>=1.83.10 requires Python>=3.10, and the last 3.9-compatible release
+# (1.83.9) pins python-dotenv==1.0.1, which conflicts with our >=1.2.1 core
+# floor — so no litellm satisfies 3.9 at all. Gate it to 3.10+.
+llm-litellm = ["litellm>=1.83.9; python_version >= '3.10'"]
llm-instructor = ["instructor>=1.15.3"]
llm-all = [
@@ -125,18 +131,41 @@ documents = [
"lxml>=6.1.1",
"beautifulsoup4>=4.15.0"
]
-parse-docling = ["docling>=2.107.0"]
+# every docling release requires Python>=3.10 (no 3.9-compatible version
+# exists to cap to), so gate it like google-adk below rather than split it.
+parse-docling = ["docling>=2.107.0; python_version >= '3.10'"]
+# pdfplumber powers the default PDFParser; not pulled in by any other extra.
+parse-pdf = ["pdfplumber>=0.10.0"]
# ---- SHACL Validation ----
shacl = ["pyshacl>=0.25.0"]
# ---- Database Connectors ----
-db-snowflake = ["snowflake-connector-python>=4.6.0", "cryptography>=49.0.0"]
+# snowflake-connector-python dropped Python 3.9 support at 4.6.0
+# (requires_python >=3.10), so an unqualified >=4.6.0 floor is unsatisfiable
+# on 3.9. Cap 3.9 below it; 3.10+ keeps the newer floor.
+db-snowflake = [
+ "snowflake-connector-python>=4.6.0; python_version >= '3.10'",
+ "snowflake-connector-python>=3.13.0,<4.6.0; python_version < '3.10'",
+ "cryptography>=49.0.0"
+]
db-databricks = ["databricks-sdk>=0.60.0", "databricks-sql-connector>=4.0.0"]
-db-arrow = ["pyarrow>=24.0.0"]
+# pyarrow dropped Python 3.9 support at 24.0.0 (requires_python >=3.10), so an
+# unqualified >=24.0.0 floor is unsatisfiable on 3.9. Cap 3.9 below the last
+# 3.9-compatible release line; 3.10+ is left unconstrained.
+db-arrow = [
+ "pyarrow>=24.0.0; python_version >= '3.10'",
+ "pyarrow>=14.0.0,<24.0.0; python_version < '3.10'"
+]
db-salesforce = ["simple-salesforce>=1.12.0"]
-ingest-parquet = ["pyarrow>=24.0.0"]
-ingest-arrow = ["pyarrow>=24.0.0"]
+ingest-parquet = [
+ "pyarrow>=24.0.0; python_version >= '3.10'",
+ "pyarrow>=14.0.0,<24.0.0; python_version < '3.10'"
+]
+ingest-arrow = [
+ "pyarrow>=24.0.0; python_version >= '3.10'",
+ "pyarrow>=14.0.0,<24.0.0; python_version < '3.10'"
+]
ingest-sap = ["requests>=2.28.0"]
ingest-git = ["GitPython>=3.1.58"]
@@ -242,7 +271,9 @@ agno = ["agno>=1.0.0"]
# crewai core provides BaseTool and BaseKnowledgeSource; crewai-tools is not
# needed (it pulls vulnerable transitive deps like chromadb) and would only
# duplicate the prebuilt tooling users can install separately.
-crewai = ["crewai>=0.80.0"]
+# No un-yanked crewai release supports Python 3.9 (all require >=3.10), so
+# gate the extra to 3.10+.
+crewai = ["crewai>=0.80.0; python_version >= '3.10'"]
langchain = ["langchain-core>=0.3.0"]
google-adk = ["google-adk>=1.27.0; python_version >= '3.10'"]
@@ -267,15 +298,23 @@ dev = [
"isort>=6.1.0",
"flake8>=4.0.0",
"mypy>=0.971",
- "pre-commit>=4.6.0",
+ # pre-commit dropped Python 3.9 support at 4.6.0 (requires_python >=3.10).
+ # Cap 3.9 below it; 3.10+ keeps the >=4.6.0 floor.
+ "pre-commit>=4.0.0,<4.6.0; python_version < '3.10'",
+ "pre-commit>=4.6.0; python_version >= '3.10'",
"jupyter>=1.0.0",
"ipykernel>=6.15.0"
]
# Explorer Dashboard
+# fastapi dropped Python 3.9 support at 0.129.0 (requires_python >=3.10), and
+# every fastapi below that caps starlette<0.53.0 — so the 3.10+ starlette
+# floor is unsatisfiable on 3.9. Cap both on 3.9; 3.10+ keeps the newer floors.
explorer = [
- "fastapi>=0.109.2",
- "starlette>=0.53.0",
+ "fastapi>=0.109.2,<0.129.0; python_version < '3.10'",
+ "fastapi>=0.109.2; python_version >= '3.10'",
+ "starlette>=0.36.3,<0.53.0; python_version < '3.10'",
+ "starlette>=0.53.0; python_version >= '3.10'",
"uvicorn[standard]>=0.22.0",
"websockets>=15.0.1",
"python-multipart>=0.0.7",
@@ -292,7 +331,7 @@ explorer-lite = [
# (CVE-2026-45829) with no fixed release — including it here would fail the CI
# dependency-audit/security gates. Install it explicitly via ``semantica[crewai]``.
all = [
- "semantica[dev,viz,media,infra,cloud,monitoring,watch,llm-all,models-huggingface,embeddings-local,nlp-spacy,documents,ingest-git,graph-embeddings,split-all,graph-all,tripletstore-oxigraph,vectorstore-all,parse-docling,ingest-parquet,ingest-arrow,shacl,explorer,agno,langchain,google-adk]"
+ "semantica[dev,viz,media,infra,cloud,monitoring,watch,llm-all,models-huggingface,embeddings-local,nlp-spacy,documents,ingest-git,graph-embeddings,split-all,graph-all,tripletstore-oxigraph,vectorstore-all,parse-docling,parse-pdf,ingest-parquet,ingest-arrow,shacl,explorer,agno,langchain,google-adk]"
]
# ---------------- ENTRYPOINTS ----------------
diff --git a/requirements-ci.txt b/requirements-ci.txt
index c90c394f..3ee108c2 100644
--- a/requirements-ci.txt
+++ b/requirements-ci.txt
@@ -787,7 +787,9 @@ charset-normalizer==3.5.1 \
--hash=sha256:fd0350afdc3aabd5576f60ea109228bd5538139713c7b094c5cd27c73a98bc6f \
--hash=sha256:fd0a274c0e5f9a21565cd9d3dd749b61f96b7aa1e20a93aa1ba4029518f2e5c0 \
--hash=sha256:fdb8a068947befafba9952162645dc2fecaeb400e64584829ed5e9b2fbe21a7f
- # via requests
+ # via
+ # pdfminer-six
+ # requests
click==8.5.0 \
--hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360 \
--hash=sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34
@@ -1098,6 +1100,7 @@ cryptography==50.0.1 \
# azure-storage-blob
# google-auth
# joserfc
+ # pdfminer-six
cuda-bindings==13.3.1 \
--hash=sha256:04436a9364059c84b8f9636f359eccda1cf814341f5b670c71d80d2f79dbc708 \
--hash=sha256:120fcc53d57903df529c3486962c56528cba5b7d6c57c99537320ed9922c8b86 \
@@ -4299,6 +4302,14 @@ patsy==1.0.3 \
--hash=sha256:79ebf4c93ff4d296e58a9d5be2b2ee31bd49d737cf11d70ffbd8a44b2de42e65 \
--hash=sha256:d3dbebe8fd5f46e29912d030b63c6268647b59bf788a99e2af28a30234cf357c
# via statsmodels
+pdfminer-six==20260107 \
+ --hash=sha256:366585ba97e80dffa8f00cebe303d2f381884d8637af4ce422f1df3ef38111a9 \
+ --hash=sha256:96bfd431e3577a55a0efd25676968ca4ce8fd5b53f14565f85716ff363889602
+ # via pdfplumber
+pdfplumber==0.11.10 \
+ --hash=sha256:7741ea81bf165b474b153e6789d10d18e06b6ddcf3ec84289c3ef2fed6802580 \
+ --hash=sha256:b95b2d28c66efb0a794a83b88c6c6aea5987532a445d20a1cbcfa657022e6e57
+ # via semantica (pyproject.toml)
pexpect==4.9.0 \
--hash=sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523 \
--hash=sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f
@@ -4407,6 +4418,7 @@ pillow==12.3.0 \
# docling-slim
# fastembed
# matplotlib
+ # pdfplumber
# python-pptx
# rapidocr
# torchvision
@@ -5294,7 +5306,9 @@ pypdfium2==5.13.0 \
--hash=sha256:d96929bde3bd64c771ab3558ca1ffd7704cc4d872ab92cd9f8f8b8a20f7f36b8 \
--hash=sha256:d96beb7f379e6c76d874ca93fcd182ac3168dd499056407070f9927fb1061b8e \
--hash=sha256:da5c7b74eebf40b5c1fbe1de01aa1edc8827a79fb1efd999616bc20dcaf77ba4
- # via docling-slim
+ # via
+ # docling-slim
+ # pdfplumber
pypickle==2.0.2 \
--hash=sha256:d3307127314465fe3dc8f0162e11777d5e8284f3a29dc48b0f770d364a85d998 \
--hash=sha256:d577e39cf501c7c80b1387f6d7dc885cf4efeba65f213df41226d1f24881b1e8
diff --git a/semantica/parse/methods.py b/semantica/parse/methods.py
index 9eb44ae7..7c18b69b 100644
--- a/semantica/parse/methods.py
+++ b/semantica/parse/methods.py
@@ -859,10 +859,9 @@ def list_available_methods(task: Optional[str] = None) -> Dict[str, List[str]]:
return method_registry.list_all(task)
-# Register default methods
-method_registry.register("document", "default", parse_document)
-method_registry.register("web", "default", parse_web_content)
-method_registry.register("structured", "default", parse_structured_data)
-method_registry.register("email", "default", parse_email)
-method_registry.register("code", "default", parse_code)
-method_registry.register("media", "default", parse_media)
+# NOTE: the built-in dispatchers (parse_document, parse_web_content, ...) must
+# NOT be registered under their own task's "default" method name. Each
+# dispatcher starts with method_registry.get(<task>, method) and would find
+# itself, re-entering infinitely until RecursionError. "default" is the
+# built-in code path and stays unregistered; users can still register their
+# own "default" (or any other name) to override it.
diff --git a/semantica/vector_store/qdrant_store.py b/semantica/vector_store/qdrant_store.py
index 04083498..6e6b85b6 100644
--- a/semantica/vector_store/qdrant_store.py
+++ b/semantica/vector_store/qdrant_store.py
@@ -384,6 +384,27 @@ class QdrantStore:
except Exception as e:
raise ProcessingError(f"Failed to get collection: {str(e)}")
+ def _ensure_default_collection(self, dim: int = 384) -> QdrantCollection:
+ """Lazily attach the configured collection, creating it on first use.
+
+ Mirrors FAISSStore's automatic index creation so the VectorStore
+ facade can read/write without an explicit create_collection() call.
+ Reuses the existing collection if a previous process created it.
+ """
+ # ``collection_name`` is the option the VectorStore facade and the
+ # docs pass through; accept the legacy ``collection`` spelling too.
+ name = (
+ self.config.get("collection_name")
+ or self.config.get("collection")
+ or "semantica_default"
+ )
+ try:
+ self.create_collection(name, vector_size=dim)
+ except ProcessingError:
+ self.get_collection(name)
+ self.logger.info(f"Auto-initialized Qdrant collection '{name}' (dim={dim})")
+ return self.collection
+
def insert_vectors(
self,
vectors: List[Union[np.ndarray, List[float]]],
@@ -403,6 +424,14 @@ class QdrantStore:
Returns:
Insert response
"""
+ if len(ids) != len(vectors):
+ # Points are paired with zip(vectors, ids), so a mismatched ID
+ # list would silently drop the unpaired vectors while the
+ # completion message still reports the full batch as inserted.
+ raise ValidationError(
+ f"Number of ids ({len(ids)}) must match number of vectors ({len(vectors)})"
+ )
+
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
submodule="QdrantStore",
@@ -411,12 +440,10 @@ class QdrantStore:
try:
if self.collection is None:
- self.progress_tracker.stop_tracking(
- tracking_id, status="failed", message="Collection not initialized"
- )
- raise ProcessingError(
- "Collection not initialized. Call create_collection() or get_collection() first."
- )
+ # len() not truthiness: vectors may be a 2-D ndarray, whose
+ # truth value is ambiguous.
+ dim = int(len(vectors[0])) if len(vectors) else 384
+ self._ensure_default_collection(dim)
if not QDRANT_AVAILABLE:
self.progress_tracker.stop_tracking(
@@ -481,12 +508,7 @@ class QdrantStore:
try:
if self.search_engine is None:
- self.progress_tracker.stop_tracking(
- tracking_id, status="failed", message="Collection not initialized"
- )
- raise ProcessingError(
- "Collection not initialized. Call create_collection() or get_collection() first."
- )
+ self._ensure_default_collection(int(len(query_vector)))
self.progress_tracker.update_tracking(
tracking_id, message="Performing similarity search..."
diff --git a/semantica/vector_store/vector_store.py b/semantica/vector_store/vector_store.py
index e504a455..4e601443 100644
--- a/semantica/vector_store/vector_store.py
+++ b/semantica/vector_store/vector_store.py
@@ -68,6 +68,7 @@ License: MIT
from typing import Any, Dict, List, Optional, Tuple, TypedDict, Union, cast
import concurrent.futures
import inspect
+import uuid
import numpy as np
@@ -482,7 +483,11 @@ class VectorStore:
doc_meta = doc.metadata
elif isinstance(doc, dict):
doc_meta = doc.get("metadata", {})
-
+ elif isinstance(doc, str):
+ # Plain-text documents: keep the text itself in the
+ # payload, otherwise it is silently dropped.
+ doc_meta = {"document": doc}
+
final_metadata[i].update(doc_meta)
return self.store_vectors(vectors, metadata=final_metadata, **options)
@@ -525,6 +530,16 @@ class VectorStore:
if supports_metadata:
return self._backend_store.add_vectors(vectors, metadata=metadata, **options)
return self._backend_store.add_vectors(vectors, **options)
+ elif hasattr(self._backend_store, 'insert_vectors'):
+ # QdrantStore: insert_vectors(vectors, ids, payloads=None)
+ # upserts the points but returns the client's status dict,
+ # while this facade promises callers the stored vector IDs
+ # (decision storage indexes the result at position 0).
+ # metadata entries already carry the source document (folded
+ # in by store()), so they map directly to Qdrant payloads.
+ ids = options.pop('ids', None) or [str(uuid.uuid4()) for _ in range(len(vectors))]
+ self._backend_store.insert_vectors(vectors, ids, payloads=metadata, **options)
+ return ids
else:
raise NotImplementedError(f"Backend store {type(self._backend_store).__name__} does not have add or add_vectors method")
diff --git a/tests/test_issue_1513_slim_core.py b/tests/test_issue_1513_slim_core.py
index e617ac06..5b915c70 100644
--- a/tests/test_issue_1513_slim_core.py
+++ b/tests/test_issue_1513_slim_core.py
@@ -216,16 +216,19 @@ def test_salesforce_ingestor_package_import_missing_hint():
def test_parse_methods_dynamic_default_resolution():
- from semantica.parse.methods import (
- get_parse_method,
- list_available_methods,
- parse_document,
- )
-
- assert get_parse_method("document", "default") == parse_document
+ """"default" must NOT be registered in the method registry: each built-in
+ dispatcher (parse_document, ...) starts with
+ method_registry.get(<task>, method), so a self-registered "default" would
+ resolve to the dispatcher itself and recurse infinitely. "default" stays
+ the built-in code path, reached only by falling through an unregistered
+ lookup, and callers can still register their own "default" to override
+ it."""
+ from semantica.parse.methods import get_parse_method, list_available_methods
+
+ assert get_parse_method("document", "default") is None
methods = list_available_methods()
- assert "default" in methods.get("document", [])
- assert "default" in methods.get("structured", [])
+ assert "default" not in methods.get("document", [])
+ assert "default" not in methods.get("structured", [])
def test_node_embedder_gensim_missing_hint():
diff --git a/tests/test_pyproject_extras.py b/tests/test_pyproject_extras.py
new file mode 100644
index 00000000..d0b71a8d
--- /dev/null
+++ b/tests/test_pyproject_extras.py
@@ -0,0 +1,36 @@
+"""Guard for the aggregate ``all`` extras in pyproject.toml.
+
+Review of #1508 caught ``parse-pdf`` missing from every ``all`` bundle:
+``semantica[all]`` installed the package without pdfplumber, so the default
+PDFParser raised ProcessingError on first use. tomllib is stdlib only from
+Python 3.11, so the bundle block is parsed textually — the repo still
+supports 3.9/3.10.
+"""
+
+import re
+from pathlib import Path
+
+PYPROJECT = Path(__file__).resolve().parents[1] / "pyproject.toml"
+
+
+def _extras_in_all_bundles():
+ """Collect every extra name referenced inside the ``all = [...]`` block."""
+ text = PYPROJECT.read_text(encoding="utf-8")
+ match = re.search(r"^all = \[\n(.*?)^\]", text, re.MULTILINE | re.DOTALL)
+ assert match, "pyproject.toml must define an aggregate 'all' extra"
+
+ names = set()
+ for bundle in re.findall(r"semantica\[([^\]]+)\]", match.group(1)):
+ names.update(part.strip() for part in bundle.split(","))
+ assert names, "'all' bundles must reference at least one extra"
+ return names
+
+
+def test_all_bundles_include_parse_pdf():
+ """An all-features install must include built-in PDF parsing support."""
+ assert "parse-pdf" in _extras_in_all_bundles()
+
+
+def test_all_bundle_extraction_finds_known_extra():
+ """Control: the extraction reads the right block (parse-docling is in)."""
+ assert "parse-docling" in _extras_in_all_bundles()
diff --git a/tests/vector_store/test_backend_facade_contract.py b/tests/vector_store/test_backend_facade_contract.py
index eb853581..4499baa0 100644
--- a/tests/vector_store/test_backend_facade_contract.py
+++ b/tests/vector_store/test_backend_facade_contract.py
@@ -50,10 +50,11 @@ CLOUD_BACKENDS = sorted(_AVAILABILITY_FLAG)
# Backends that store locally and need no connection step.
_LOCAL_BACKENDS = {"inmemory", "faiss", "sqlite", "pgvector"}
-# The facade dispatches store_vectors() to `add` or `add_vectors`. Milvus
-# exposes add_vectors so it already resolves; the other three name their write
-# method differently and fall through to NotImplementedError.
-_NO_WRITE_DISPATCH = {"qdrant", "pinecone", "weaviate"}
+# The facade dispatches store_vectors() to `add`, `add_vectors`, or
+# `insert_vectors`. Milvus exposes add_vectors and qdrant insert_vectors, so
+# both resolve; the remaining two name their write method differently and fall
+# through to NotImplementedError.
+_NO_WRITE_DISPATCH = {"pinecone", "weaviate"}
def _construct(backend):
diff --git a/tests/vector_store/test_qdrant_facade_writes.py b/tests/vector_store/test_qdrant_facade_writes.py
new file mode 100644
index 00000000..328988f9
--- /dev/null
+++ b/tests/vector_store/test_qdrant_facade_writes.py
@@ -0,0 +1,126 @@
+"""Regression tests for the Qdrant write path behind the VectorStore facade.
+
+Qodo review of #1508 found three bugs in the newly wired qdrant dispatch:
+stored IDs were swallowed (the upsert status dict was returned instead),
+mismatched ids/vectors silently truncated the write via zip(), and lazy
+collection init ignored the documented ``collection_name`` option. These
+tests pin all three.
+
+qdrant-client is not installed in this environment, so QDRANT_AVAILABLE is
+patched and PointStruct is replaced with a plain stand-in, following the
+pattern in test_vector_store_deepdive.py and test_qdrant_store.py.
+"""
+
+from unittest.mock import MagicMock, patch
+
+import numpy as np
+import pytest
+
+from semantica.utils.exceptions import ValidationError
+from semantica.vector_store import VectorStore
+from semantica.vector_store.qdrant_store import QdrantStore
+
+VECTORS = [np.array([1.0, 0.0, 0.0]), np.array([0.0, 1.0, 0.0])]
+METADATA = [{"type": "a"}, {"type": "b"}]
+
+
+class _Point:
+ """Stand-in for qdrant_client PointStruct that keeps the point id."""
+
+ def __init__(self, id, vector=None, payload=None):
+ self.id = id
+ self.vector = vector
+ self.payload = payload
+
+
+def _qdrant_facade(**config):
+ """VectorStore built through the real qdrant init path, with the network
+ client and an attached collection replaced by mocks."""
+ store = VectorStore(backend="qdrant", config={"dimension": 3, **config})
+ backend = store._backend_store
+ backend.client = MagicMock()
+ backend.collection = MagicMock()
+ return store
+
+
+@patch("semantica.vector_store.qdrant_store.PointStruct", _Point)
+@patch("semantica.vector_store.qdrant_store.QDRANT_AVAILABLE", True)
+def test_facade_returns_generated_ids_not_upsert_status():
+ """store_vectors() promises callers the stored vector IDs; the qdrant
+ branch used to leak insert_vectors()' upsert status dict instead."""
+ store = _qdrant_facade()
+
+ ids = store.store_vectors(VECTORS, METADATA)
+
+ assert isinstance(ids, list)
+ assert len(ids) == len(VECTORS)
+ assert all(isinstance(i, str) and i for i in ids)
+ upserted = store._backend_store.collection.upsert_points.call_args[0][0]
+ assert [p.id for p in upserted] == ids
+
+
+@patch("semantica.vector_store.qdrant_store.PointStruct", _Point)
+@patch("semantica.vector_store.qdrant_store.QDRANT_AVAILABLE", True)
+def test_facade_returns_caller_supplied_ids_verbatim():
+ store = _qdrant_facade()
+
+ ids = store.store_vectors(VECTORS, METADATA, ids=["doc-a", "doc-b"])
+
+ assert ids == ["doc-a", "doc-b"]
+
+
[email protected]("ids", [["doc-a"], ["doc-a", "doc-b", "doc-c"]])
+@patch("semantica.vector_store.qdrant_store.PointStruct", _Point)
+@patch("semantica.vector_store.qdrant_store.QDRANT_AVAILABLE", True)
+def test_facade_rejects_ids_count_mismatch(ids):
+ """insert_vectors() pairs points with zip(vectors, ids); a mismatched
+ batch must fail loudly instead of silently dropping vectors."""
+ store = _qdrant_facade()
+
+ with pytest.raises(ValidationError, match="must match number of vectors"):
+ store.store_vectors(VECTORS, METADATA, ids=ids)
+ store._backend_store.collection.upsert_points.assert_not_called()
+
+
+@patch("semantica.vector_store.qdrant_store.PointStruct", _Point)
+@patch("semantica.vector_store.qdrant_store.QDRANT_AVAILABLE", True)
+def test_backend_insert_vectors_rejects_count_mismatch():
+ """Direct QdrantStore callers get the same guard as facade callers."""
+ store = QdrantStore()
+ store.client = MagicMock()
+ store.collection = MagicMock()
+
+ with pytest.raises(ValidationError, match="must match number of vectors"):
+ store.insert_vectors(VECTORS, ["only-one"])
+ store.collection.upsert_points.assert_not_called()
+
+
+def _lazy_collection_name(store):
+ """Drive _ensure_default_collection and report the name it selected."""
+ store.client = MagicMock()
+ with (
+ patch.object(store, "create_collection") as create,
+ patch.object(store, "get_collection"),
+ ):
+ store._ensure_default_collection(3)
+ return create.call_args[0][0]
+
+
+def test_lazy_collection_uses_documented_collection_name():
+ """The docs and facade configure qdrant with collection_name=...; lazy
+ init used to look up 'collection' and always fall back to the default."""
+ store = QdrantStore(collection_name="semantica")
+
+ assert _lazy_collection_name(store) == "semantica"
+
+
+def test_lazy_collection_accepts_legacy_collection_alias():
+ store = QdrantStore(collection="legacy_name")
+
+ assert _lazy_collection_name(store) == "legacy_name"
+
+
+def test_lazy_collection_defaults_without_config():
+ store = QdrantStore()
+
+ assert _lazy_collection_name(store) == "semantica_default"
diff --git a/tests/vector_store/test_search_result_schema.py b/tests/vector_store/test_search_result_schema.py
index cdae2337..4080870e 100644
--- a/tests/vector_store/test_search_result_schema.py
+++ b/tests/vector_store/test_search_result_schema.py
@@ -112,7 +112,9 @@ class TestQdrantSearchSchema(unittest.TestCase):
mock_hit.id = "q_1"
mock_hit.score = 0.88
mock_hit.payload = {"category": "x"}
- mock_client.search.return_value = [mock_hit]
+ # search_points prefers the modern query_points API; a MagicMock
+ # exposes it, so the response must carry the hits in .points.
+ mock_client.query_points.return_value = MagicMock(points=[mock_hit])
coll = QdrantCollection(mock_client, "test_col")
results = coll.search_points(np.array([0.1, 0.2]), limit=1)
@@ -132,7 +134,9 @@ class TestQdrantSearchSchema(unittest.TestCase):
mock_hit_high = MagicMock(id="q_hi", score=50.0, payload={})
mock_hit_mid = MagicMock(id="q_mid", score=2.0, payload={})
mock_hit_low = MagicMock(id="q_lo", score=1.0, payload={})
- mock_client.search.return_value = [mock_hit_high, mock_hit_mid, mock_hit_low]
+ mock_client.query_points.return_value = MagicMock(
+ points=[mock_hit_high, mock_hit_mid, mock_hit_low]
+ )
coll = QdrantCollection(mock_client, "test_col")
results = coll.search_points(np.array([0.1, 0.2]), limit=3)
diff --git a/tests/vector_store/test_vector_store_deepdive.py b/tests/vector_store/test_vector_store_deepdive.py
index ed31e5d3..bee512b7 100644
--- a/tests/vector_store/test_vector_store_deepdive.py
+++ b/tests/vector_store/test_vector_store_deepdive.py
@@ -209,12 +209,12 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_client = MagicMock()
mock_qdrant_cls.return_value = mock_client
- # Mock search response
+ # Mock search response (modern query_points API: hits in .points)
mock_hit = MagicMock()
mock_hit.id = "vec_1"
mock_hit.score = 0.9
mock_hit.payload = {"type": "a"}
- mock_client.search.return_value = [mock_hit]
+ mock_client.query_points.return_value = MagicMock(points=[mock_hit])
store = QdrantStore(url="http://localhost:6333")