fix: harden task3 qdrant compatibility boundaries

This commit is contained in:
2026-08-11 07:34:44 +02:00
parent 0724a73300
commit 99e0024973
11 changed files with 410 additions and 227 deletions
+47
View File
@@ -218,6 +218,53 @@ def test_vector_index_schema_json_is_single_document(monkeypatch, tmp_path):
assert payload["counts"]["added"] == 2
def test_vector_index_schema_json_maps_require_existing_delete_race(monkeypatch, tmp_path):
cfg = _qdrant_runtime_config(tmp_path)
_write_schema_artifacts(tmp_path)
monkeypatch.setattr("tht.cli.vector_cmd.make_embedder", lambda _: SimpleNamespace(embed_documents=lambda docs: [[0.1] * 1024 for _ in docs]))
keyword_indexes = {
"content_hash", "document_id", "kind", "record_key", "record_kind",
"vector_generation", "workspace_id", "workspace_revision",
}
deleted = False
class Response:
def __init__(self, status_code, payload=None):
self.status_code = status_code
self.ok = status_code < 400
self._payload = payload
self.text = "" if payload is None else "{}"
def json(self):
return self._payload
def request(method, url, **kwargs):
nonlocal deleted
if method == "POST" and url.endswith("/points/scroll"):
return Response(200, {"result": {"points": [], "next_page_offset": None}})
if method == "GET" and url.endswith("/collections/psd-clinical"):
if deleted:
return Response(404, {"status": {"error": "missing"}})
response = Response(200, {"result": {
"config": {"params": {"vectors": {"size": 1024, "distance": "Cosine"}}},
"payload_schema": {
key: {"data_type": "keyword"} for key in keyword_indexes
},
}})
deleted = True
return response
if method == "PUT" and "/points?wait=true" in url:
return Response(404, {"status": {"error": "missing"}})
raise AssertionError((method, url))
monkeypatch.setattr("requests.request", request)
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
assert response.exit_code == 1
assert response.stdout == '{"code":"semantic_index_incompatible","status":"failed"}\n'
assert response.stderr == ""
def test_vector_index_schema_json_failure_is_safe(monkeypatch, tmp_path):
import json