feat(evidence): structure v3 domain rules for review

This commit is contained in:
Codex
2026-08-26 12:38:30 +02:00
parent 9d4f994d3e
commit 9898726069
9 changed files with 254 additions and 24 deletions
+39
View File
@@ -262,6 +262,34 @@ def test_v3_curated_markdown_replaces_frontmatter_tables_with_readable_sections(
assert parsed == evidence
def test_v3_domain_rule_is_structured_without_changing_its_canonical_text(tmp_path):
rule = (
"Il dominio Ablazione descrive la procedura; indicazioni principali: fibrillazione "
"atriale, flutter; appartiene all'universo procedurale. Fact centrale: "
"`clinical.fact_ablazione`, collegata a `clinical.dim_patient`. Granularità: una riga "
"per procedura. Domande tipiche: numero di procedure per anno; pazienti distinti per "
"anno; distribuzione per indicazione."
)
base = _domain_evidence_v3()
evidence = base.model_copy(
update={"payload": base.payload.model_copy(update={"rule": rule})},
)
text = dump_curated_markdown(evidence)
parsed = parse_curated_markdown(
text,
path=tmp_path / "curated" / "domain" / "dominio-ablazione.md",
)
assert "## Regola\n\n<!-- tht:raw-rule:" in text
assert "- Il dominio Ablazione descrive la procedura;" in text
assert "- **indicazioni principali:** fibrillazione atriale, flutter;" in text
assert "### Fact centrale:" in text
assert "### Granularità:" in text
assert "### Domande tipiche:" in text
assert parsed.payload.rule == rule
def test_v3_curated_markdown_renders_enum_values_as_a_list_instead_of_a_table(tmp_path):
evidence = CuratedEvidence.model_validate({
**COMMON,
@@ -294,6 +322,17 @@ def test_v3_curated_markdown_rejects_visible_metadata_that_drifted_from_canonica
parse_curated_markdown(text)
def test_v3_curated_markdown_rejects_rule_presentation_that_drifted_from_raw_text():
text = dump_curated_markdown(_domain_evidence_v3()).replace(
"La fact centrale è",
"La tabella centrale è",
1,
)
with pytest.raises(ValueError, match="not canonical"):
parse_curated_markdown(text)
def test_v2_curated_markdown_renders_domain_content_in_the_markdown_body(tmp_path):
evidence = _domain_evidence_v2()
path = tmp_path / "curated" / "domain" / "dominio-ablazione.md"