51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""F-05: the service must refuse to start on a corpus/model manifest
|
|
mismatch, not silently search with vectors the collection wasn't built from.
|
|
"""
|
|
import pytest
|
|
|
|
from rag.manifest import ManifestMismatch, check_manifest, manifest_collection
|
|
|
|
|
|
def test_manifest_collection_naming():
|
|
assert manifest_collection("duocthu_v1") == "duocthu_v1__manifest"
|
|
|
|
|
|
def test_matching_manifest_passes():
|
|
check_manifest(
|
|
{"model_id": "cohere.embed-v4:0", "dimensions": 1024},
|
|
"duocthu_v1", "cohere.embed-v4:0", 1024,
|
|
) # no raise
|
|
|
|
|
|
def test_missing_manifest_refuses():
|
|
with pytest.raises(ManifestMismatch, match="no corpus manifest"):
|
|
check_manifest(None, "duocthu_v1", "cohere.embed-v4:0", 1024)
|
|
|
|
|
|
def test_wrong_model_id_refuses_even_with_matching_dimensions():
|
|
"""The exact scenario the finding names: two unrelated models can both
|
|
produce 1024-dim vectors."""
|
|
with pytest.raises(ManifestMismatch, match="model_id"):
|
|
check_manifest(
|
|
{"model_id": "amazon.titan-embed-text-v2:0", "dimensions": 1024},
|
|
"duocthu_v1", "cohere.embed-v4:0", 1024,
|
|
)
|
|
|
|
|
|
def test_wrong_dimensions_refuses():
|
|
with pytest.raises(ManifestMismatch, match="dimensions"):
|
|
check_manifest(
|
|
{"model_id": "cohere.embed-v4:0", "dimensions": 768},
|
|
"duocthu_v1", "cohere.embed-v4:0", 1024,
|
|
)
|
|
|
|
|
|
def test_both_mismatched_reports_both():
|
|
with pytest.raises(ManifestMismatch) as excinfo:
|
|
check_manifest(
|
|
{"model_id": "other-model", "dimensions": 768},
|
|
"duocthu_v1", "cohere.embed-v4:0", 1024,
|
|
)
|
|
assert "model_id" in str(excinfo.value)
|
|
assert "dimensions" in str(excinfo.value)
|