fix(evidence): retain referenced vector generations
This commit is contained in:
@@ -137,3 +137,30 @@ def test_owned_copy_uses_validated_descriptor_bytes_when_source_is_replaced(tmp_
|
||||
owned = store.materialize_document(document.document_id, tmp_path / "session" / "evidence.md")
|
||||
assert owned.read_text() == content
|
||||
assert hashlib.sha256(owned.read_bytes()).hexdigest() == document.content_hash.removeprefix("sha256:")
|
||||
|
||||
|
||||
def test_materialized_snapshot_uses_identified_manifest_when_active_changes(tmp_path):
|
||||
from tht.corpus.models import CanonicalDocument
|
||||
import hashlib
|
||||
|
||||
def doc(content, fingerprint):
|
||||
return CanonicalDocument(
|
||||
document_id="doc:" + hashlib.sha256(content.encode()).hexdigest(),
|
||||
source_id="fs:item", source_uri="file:///item",
|
||||
source_fingerprint="sha256:" + fingerprint * 64,
|
||||
content_hash="sha256:" + hashlib.sha256(content.encode()).hexdigest(),
|
||||
content=content, pipeline_version="evidence-v1",
|
||||
)
|
||||
|
||||
store = CorpusStore(tmp_path / "corpus")
|
||||
old = doc("old", "a")
|
||||
old_generation = store.stage(CorpusManifest(documents=(old,)), {old.document_id: old.content})
|
||||
store.publish(old_generation)
|
||||
snapshot = store.active_manifest()
|
||||
new = doc("new", "b")
|
||||
new_generation = store.stage(CorpusManifest(documents=(new,)), {new.document_id: new.content})
|
||||
store.publish(new_generation)
|
||||
path = store.materialize_document(
|
||||
snapshot.documents[0].document_id, tmp_path / "owned.md", generation=snapshot.manifest_id,
|
||||
)
|
||||
assert path.read_text() == "old"
|
||||
|
||||
Reference in New Issue
Block a user