fix: harden reviewer workflow and memory handling
This commit is contained in:
@@ -9,7 +9,13 @@ la rende un passo del workflow. Questi test fissano il contratto harness-side:
|
||||
from datetime import datetime
|
||||
|
||||
from tht.decisions import DecisionRecord, append_decision
|
||||
from tht.memory import declined_promotion_seqs, reusable_promotions
|
||||
from tht.memory import (
|
||||
MemoryRecord,
|
||||
declined_promotion_seqs,
|
||||
memory_vector_records,
|
||||
promote,
|
||||
reusable_promotions,
|
||||
)
|
||||
from tht.session.models import SessionManifest
|
||||
from tht.workflow import load_workflow
|
||||
|
||||
@@ -62,3 +68,48 @@ def test_reusable_promotions_exclude_declined(tmp_path):
|
||||
subject="fact_a", detail="seq:1") # seq 3
|
||||
cand = reusable_promotions(tmp_path, _manifest(), tmp_path / "registry.jsonl")
|
||||
assert [c.decision_seq for c in cand] == [2]
|
||||
|
||||
|
||||
def test_reusable_promotions_deduplicate_identical_memory_content(tmp_path):
|
||||
append_decision(tmp_path, type="concept_clarified", subject="paziente attivo",
|
||||
detail="flag_attivo = TRUE", rationale="scelta reviewer")
|
||||
append_decision(tmp_path, type="concept_clarified", subject="paziente attivo",
|
||||
detail="flag_attivo = TRUE", rationale="scelta reviewer")
|
||||
|
||||
cand = reusable_promotions(tmp_path, _manifest(), tmp_path / "registry.jsonl")
|
||||
|
||||
assert [c.decision_seq for c in cand] == [1]
|
||||
|
||||
|
||||
def test_only_concept_clarified_is_proposed_or_promoted(tmp_path):
|
||||
append_decision(tmp_path, type="table_promoted", subject="fact_a",
|
||||
detail="tabella principale")
|
||||
append_decision(tmp_path, type="table_excluded", subject="fact_b",
|
||||
detail="tabella non pertinente")
|
||||
append_decision(tmp_path, type="concept_clarified", subject="paziente attivo",
|
||||
detail="flag_attivo = TRUE")
|
||||
registry = tmp_path / "registry.jsonl"
|
||||
|
||||
candidates = reusable_promotions(tmp_path, _manifest(), registry)
|
||||
promoted = promote(tmp_path, _manifest(), seqs=[1, 2, 3], registry_path=registry)
|
||||
|
||||
assert [(c.decision_seq, c.type) for c in candidates] == [(3, "concept_clarified")]
|
||||
assert [(c.decision_seq, c.type) for c in promoted] == [(3, "concept_clarified")]
|
||||
|
||||
|
||||
def test_legacy_table_records_are_not_published_as_memory_vectors():
|
||||
records = [
|
||||
MemoryRecord(
|
||||
id="mem-0001", ts=datetime(2026, 1, 1), session_id="s1",
|
||||
decision_seq=1, type="table_promoted", subject="fact_a",
|
||||
),
|
||||
MemoryRecord(
|
||||
id="mem-0002", ts=datetime(2026, 1, 1), session_id="s1",
|
||||
decision_seq=2, type="concept_clarified", subject="paziente attivo",
|
||||
detail="flag_attivo = TRUE",
|
||||
),
|
||||
]
|
||||
|
||||
vectors = memory_vector_records(records)
|
||||
|
||||
assert [record.ref for record in vectors] == ["mem-0002"]
|
||||
|
||||
Reference in New Issue
Block a user