refactor(evidence): migrate runtime consumption (#29)

This commit is contained in:
2026-08-24 02:10:06 +02:00
parent 8b63715b56
commit d5e78febd3
8 changed files with 128 additions and 58 deletions
@@ -10,6 +10,7 @@ from tht.decisions import DecisionRecord
from tht.evidence import (
acquire,
active_searcher,
build_retrieval_entries,
discover,
project_session,
resolve_citation,
@@ -125,6 +126,18 @@ def test_search_facade_preserves_active_filtering_and_global_order(tmp_path):
assert facade_delegate.calls == legacy_delegate.calls
def test_retrieval_entries_preserve_hit_order_and_existing_projection_shape():
hits = [
SimpleNamespace(label="Second", status="reviewed", content="abcdefgh"),
SimpleNamespace(label="First", status=None, content="12345678"),
]
assert build_retrieval_entries(hits, excerpt_chars=5) == [
{"title": "Second", "status": "reviewed", "excerpt": "abcde"},
{"title": "First", "status": None, "excerpt": "12345"},
]
def _canonical_store(root, evidence_id):
content = f"# {evidence_id}\n"
digest = hashlib.sha256(content.encode()).hexdigest()
@@ -159,6 +172,40 @@ def test_citation_facade_matches_active_corpus_resolution(tmp_path):
assert resolve_citation(store, "missing", materialized_root=materialized) == ""
def test_session_projection_routes_corpus_citations_through_the_facade(tmp_path, monkeypatch):
evidence_root = tmp_path / "artifacts" / "evidence"
(tmp_path / "corpus").mkdir()
calls = []
def fake_resolve(store, evidence_id, *, materialized_root=None):
calls.append((store.root, evidence_id, materialized_root))
return f"/materialized/{evidence_id}.md"
monkeypatch.setattr("tht.evidence.resolve_citation", fake_resolve)
linking = SchemaLinking(
question="q",
candidates=[Candidate(
kind="table",
name="fact_procedure",
evidence=["evi-used"],
decision="promoted",
decision_seq=17,
)],
)
assert build_evidence_entries([], linking, evidence_root) == [{
"id": "evi-used",
"file": "/materialized/evi-used.md",
"esito": "usata",
"decision_seq": 17,
}]
assert calls == [(
tmp_path / "corpus",
"evi-used",
tmp_path / "artifacts" / ".materialized-evidence",
)]
def _record(seq, type_, subject):
return DecisionRecord(
seq=seq,