fix: harden model catalog projections
This commit is contained in:
@@ -40,6 +40,7 @@ def test_manifest_contains_provenance_without_credentials():
|
||||
manifest_id="manifest:abc",
|
||||
created_at=datetime(2026, 7, 12, tzinfo=UTC),
|
||||
pipeline_version="evidence-v1",
|
||||
embedding_id="ollama/nomic-embed-text",
|
||||
embedding_model="nomic-embed-text",
|
||||
embedding_dimensions=768,
|
||||
documents=[document()],
|
||||
@@ -52,6 +53,7 @@ def test_manifest_contains_provenance_without_credentials():
|
||||
assert "etag:abc" in payload
|
||||
assert "evidence-v1" in payload
|
||||
assert "nomic-embed-text" in payload
|
||||
assert '"embedding_id":"ollama/nomic-embed-text"' in payload
|
||||
assert "api_key" not in payload
|
||||
|
||||
|
||||
@@ -93,6 +95,25 @@ def test_manifest_validates_embedding_compatibility_fields():
|
||||
)
|
||||
|
||||
|
||||
def test_schema_v1_manifest_without_canonical_embedding_id_remains_readable():
|
||||
manifest = CorpusManifest.model_validate({
|
||||
"schema_version": 1,
|
||||
"embedding_model": "legacy-model",
|
||||
"embedding_dimensions": 768,
|
||||
})
|
||||
|
||||
assert manifest.embedding_id is None
|
||||
|
||||
|
||||
def test_schema_v2_embedding_generation_requires_canonical_id():
|
||||
with pytest.raises(ValidationError, match="embedding_id"):
|
||||
CorpusManifest(
|
||||
schema_version=2,
|
||||
embedding_model="model-v2",
|
||||
embedding_dimensions=768,
|
||||
)
|
||||
|
||||
|
||||
def test_canonical_metadata_rejects_secrets_and_non_json_values():
|
||||
with pytest.raises(ValidationError, match="credential-like"):
|
||||
CanonicalDocument.model_validate(
|
||||
|
||||
Reference in New Issue
Block a user