feat: complete catalog-driven preprocessing
Publish documentation / publish (push) Successful in 2m12s
Publish documentation / publish (push) Successful in 2m12s
This commit is contained in:
@@ -32,6 +32,9 @@ class _FakeVectorStore:
|
||||
def existing_hashes(self, collection, kinds):
|
||||
return {}
|
||||
|
||||
def delete_kinds(self, collection, kinds):
|
||||
return 0
|
||||
|
||||
def upsert(self, collection, records):
|
||||
self.upserts.append((collection, records))
|
||||
return len(records)
|
||||
@@ -58,6 +61,7 @@ roots:
|
||||
sessions: {tmp_path / 'sessions'}
|
||||
artifacts: {tmp_path / 'artifacts'}
|
||||
indexes: {tmp_path / 'indexes'}
|
||||
catalog_metadata_snapshot: {tmp_path / 'catalog-metadata.json'}
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
@@ -68,22 +72,34 @@ embeddings:
|
||||
return cfg
|
||||
|
||||
|
||||
def _write_schema_artifacts(tmp_path: Path) -> None:
|
||||
(tmp_path / "artifacts" / "mschema").mkdir(parents=True, exist_ok=True)
|
||||
(tmp_path / "artifacts" / "mschema" / "physical.yaml").write_text(
|
||||
"""
|
||||
database: analytics
|
||||
schema: mart
|
||||
introspected_at: 2026-01-01T00:00:00+00:00
|
||||
tables:
|
||||
fact_patient:
|
||||
comment: Patients
|
||||
columns:
|
||||
id:
|
||||
type: bigint
|
||||
"""
|
||||
)
|
||||
(tmp_path / "artifacts" / "mschema" / "annotations.yaml").write_text("tables: {}\n")
|
||||
def _write_catalog_snapshot(tmp_path: Path) -> None:
|
||||
(tmp_path / "catalog-metadata.json").write_text(json.dumps({
|
||||
"schemaVersion": 1,
|
||||
"workspaceId": "psd-clinical",
|
||||
"databaseId": "db-1",
|
||||
"databaseName": "analytics",
|
||||
"schemaName": "mart",
|
||||
"metadataContentRevision": 1,
|
||||
"tables": [{
|
||||
"id": "table-1",
|
||||
"name": "fact_patient",
|
||||
"description": "Patients",
|
||||
"descriptionSource": "curated",
|
||||
"columns": [{
|
||||
"id": "column-1",
|
||||
"name": "id",
|
||||
"ordinalPosition": 1,
|
||||
"dataType": "bigint",
|
||||
"isNullable": False,
|
||||
"defaultExpression": None,
|
||||
"primaryKeyPosition": 1,
|
||||
"sensitive": False,
|
||||
"description": None,
|
||||
"descriptionSource": None,
|
||||
}],
|
||||
}],
|
||||
"relationships": [],
|
||||
}))
|
||||
|
||||
|
||||
def _memory_record() -> MemoryRecord:
|
||||
@@ -104,7 +120,7 @@ def _memory_record() -> MemoryRecord:
|
||||
|
||||
def test_vector_index_schema_accepts_qdrant_only_runtime_config(tmp_path, monkeypatch):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
_write_catalog_snapshot(tmp_path)
|
||||
store = _FakeVectorStore()
|
||||
|
||||
monkeypatch.setattr("tht.adapters.factory.build_vector_store", lambda cfg, require_write: store)
|
||||
@@ -118,7 +134,7 @@ def test_vector_index_schema_accepts_qdrant_only_runtime_config(tmp_path, monkey
|
||||
|
||||
def test_vector_index_schema_json_is_pristine_and_reports_artifacts(tmp_path, monkeypatch):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
_write_catalog_snapshot(tmp_path)
|
||||
store = _FakeVectorStore()
|
||||
|
||||
monkeypatch.setattr("tht.adapters.factory.build_vector_store", lambda cfg, require_write: store)
|
||||
@@ -131,12 +147,8 @@ def test_vector_index_schema_json_is_pristine_and_reports_artifacts(tmp_path, mo
|
||||
assert json.loads(response.stdout) == {
|
||||
"artifactIdentities": [
|
||||
{
|
||||
"digest": _sha_file(tmp_path / "artifacts" / "mschema" / "annotations.yaml"),
|
||||
"kind": "schema_annotations",
|
||||
},
|
||||
{
|
||||
"digest": _sha_file(tmp_path / "artifacts" / "mschema" / "physical.yaml"),
|
||||
"kind": "physical_schema",
|
||||
"digest": _sha_file(tmp_path / "catalog-metadata.json"),
|
||||
"kind": "catalog_metadata_snapshot",
|
||||
},
|
||||
],
|
||||
"code": "ok",
|
||||
@@ -146,6 +158,7 @@ def test_vector_index_schema_json_is_pristine_and_reports_artifacts(tmp_path, mo
|
||||
"columns": 1,
|
||||
"deleted": 0,
|
||||
"records": 2,
|
||||
"relationships": 0,
|
||||
"tables": 1,
|
||||
"unchanged": 0,
|
||||
"updated": 0,
|
||||
@@ -160,7 +173,7 @@ def test_vector_index_schema_json_is_pristine_and_reports_artifacts(tmp_path, mo
|
||||
|
||||
def test_vector_index_schema_json_failure_is_pristine(tmp_path, monkeypatch):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
_write_catalog_snapshot(tmp_path)
|
||||
|
||||
def boom(cfg, require_write):
|
||||
raise VectorStoreError("semantic_index_incompatible")
|
||||
|
||||
Reference in New Issue
Block a user