fix: exclude schema tables from session memories

This commit is contained in:
2026-07-23 15:54:27 +02:00
parent 9b5fca59e8
commit 2e1bb621a0
2 changed files with 106 additions and 4 deletions
+51
View File
@@ -203,6 +203,57 @@ def test_memory_projection_does_not_repeat_detail_as_marker_rationale(tmp_path):
}
def test_memory_projection_excludes_standalone_schema_tables_but_keeps_mappings(tmp_path):
manifest = create_session("q", _db(), tmp_path)
session_dir = tmp_path / manifest.id
decisions = [
_decision(1, "table_promoted", "fact_procedure", "Tabella dei fatti"),
_decision(2, "memory_promoted", "fact_procedure", "seq:1"),
_decision(3, "table_excluded", "dim_time", "Dimensione temporale"),
_decision(4, "memory_promotion_declined", "dim_time", "Dimensione temporale"),
_decision(
5,
"concept_clarified",
"ablazione valida",
"Mappata su `fact_procedure.ablazione_transcatetere = TRUE`.",
),
_decision(6, "memory_promoted", "ablazione valida", "seq:5"),
_decision(
7,
"memory_promotion_declined",
"conteggio annuale",
"`COUNT(DISTINCT patient_id)` raggruppato per `dim_time.year`.",
),
]
(session_dir / "schema_linking.json").write_text(json.dumps({
"question": "q",
"candidates": [{"kind": "table", "name": "fact_procedure"}],
"joins": [],
"excluded": [{"kind": "table", "name": "dim_time"}],
"open_questions": [],
}))
(session_dir / "review_decisions.jsonl").write_text(
"\n".join(d.model_dump_json() for d in decisions) + "\n"
)
by_key = {doc["key"]: doc for doc in build_documents(manifest, session_dir)}
assert json.loads(by_key["memories"]["content"]) == [
{
"status": "approved",
"subject": "ablazione valida",
"detail": "Mappata su `fact_procedure.ablazione_transcatetere = TRUE`.",
"rationale": "",
},
{
"status": "declined",
"subject": "conteggio annuale",
"detail": "`COUNT(DISTINCT patient_id)` raggruppato per `dim_time.year`.",
"rationale": "",
},
]
def test_filesystem_and_snapshot_builders_share_the_same_projection(tmp_path):
manifest, session_dir, question, report, decisions = _rich_session(tmp_path)
snapshot = SessionSnapshot(