fix: harden model catalog projections
This commit is contained in:
@@ -21,7 +21,8 @@ def _write_cfg(tmp_path, raw):
|
||||
return cfg
|
||||
|
||||
|
||||
def _cfg(tmp_path, *, transport="thoth_rest", base_url="http://dwh.example.invalid", collection="psd", model="qwen3-embedding:0.6b"):
|
||||
def _cfg(tmp_path, *, transport="thoth_rest", base_url="http://dwh.example.invalid",
|
||||
collection="psd", model="qwen3-embedding:0.6b", dimensions=1024):
|
||||
return {
|
||||
"schemaVersion": 1,
|
||||
"workspace": {"schema_version": 3, "id": "psd", "name": "PSD", "language": "it"},
|
||||
@@ -34,7 +35,10 @@ def _cfg(tmp_path, *, transport="thoth_rest", base_url="http://dwh.example.inval
|
||||
"connection": {"host": "h", "port": 5432, "database": "warehouse", "schema": "dw", "user": "reader", "password": "secret"},
|
||||
},
|
||||
"vectors": {"type": "qdrant", "base_url": "http://qdrant:6333", "collection": collection, "collection_lifecycle": "self_heal"},
|
||||
"embeddings": {"provider": "ollama_internal", "base_url": "http://embedding:11434", "model": model, "dimensions": 1024},
|
||||
"embeddings": {
|
||||
"provider": "ollama_internal", "base_url": "http://embedding:11434",
|
||||
"id": f"ollama/{model}", "model": model, "dimensions": dimensions,
|
||||
},
|
||||
"roots": {"artifacts": str(tmp_path / "artifacts"), "indexes": str(tmp_path / "indexes")},
|
||||
"paths": {"artifacts": str(tmp_path / "artifacts"), "indexes": str(tmp_path / "indexes"), "sessions": str(tmp_path / "sessions")},
|
||||
}
|
||||
@@ -52,6 +56,16 @@ def test_canonical_json_is_deterministic_and_key_ordered(cfg):
|
||||
assert keys == ["schemaVersion", "dwh", "vector", "embedding", "roots"]
|
||||
|
||||
|
||||
def test_catalog_embedding_identity_and_dimensions_drive_effective_config(tmp_path):
|
||||
cfg = _write_cfg(tmp_path, _cfg(tmp_path, model="bge-m3", dimensions=1536))
|
||||
document = __import__("json").loads(canonical_effective_config_json(cfg))
|
||||
|
||||
assert document["embedding"] == {
|
||||
"id": "ollama/bge-m3", "model": "bge-m3", "dimensions": 1536,
|
||||
}
|
||||
assert document["vector"]["dimensions"] == 1536
|
||||
|
||||
|
||||
def test_canonical_excludes_credentials_and_evidence(cfg):
|
||||
doc = canonical_effective_config_json(cfg)
|
||||
assert "secret" not in doc
|
||||
|
||||
Reference in New Issue
Block a user