feat(evidence): add table-free v3 and design guidance
This commit is contained in:
@@ -221,6 +221,79 @@ def _domain_evidence_v2() -> CuratedEvidence:
|
||||
})
|
||||
|
||||
|
||||
def _domain_evidence_v3() -> CuratedEvidence:
|
||||
return CuratedEvidence.model_validate({
|
||||
**COMMON,
|
||||
"schema_version": 3,
|
||||
"title": "Dominio Ablazione",
|
||||
"kind": "domain",
|
||||
"purposes": ["disambiguation", "schema_linking", "rewriting"],
|
||||
"applies_to": {
|
||||
"concepts": ["ablazione", "studio elettrofisiologico", "SEE"],
|
||||
"tables": ["clinical.fact_ablazione"],
|
||||
"columns": ["clinical.fact_ablazione.patient_id"],
|
||||
},
|
||||
"payload": {
|
||||
"rule": (
|
||||
"Il dominio Ablazione rappresenta la procedura transcatetere.\n\n"
|
||||
"La fact centrale è `clinical.fact_ablazione`."
|
||||
),
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
def test_v3_curated_markdown_replaces_frontmatter_tables_with_readable_sections(tmp_path):
|
||||
evidence = _domain_evidence_v3()
|
||||
path = tmp_path / "curated" / "domain" / "dominio-ablazione.md"
|
||||
|
||||
text = dump_curated_markdown(evidence)
|
||||
parsed = parse_curated_markdown(text, path=path)
|
||||
|
||||
assert text.startswith("<!-- tht:metadata:")
|
||||
assert not text.startswith("---\n")
|
||||
assert not any(line.startswith("|") for line in text.splitlines())
|
||||
assert "> **Dominio** · Italiano" in text
|
||||
assert "**Scopi:** Disambiguazione · Collegamento allo schema · Riscrittura" in text
|
||||
assert "## Ambito di applicazione" in text
|
||||
assert "### Concetti\n\n- ablazione\n- studio elettrofisiologico\n- SEE" in text
|
||||
assert "### Tabelle\n\n- `clinical.fact_ablazione`" in text
|
||||
assert "### Colonne\n\n- `clinical.fact_ablazione.patient_id`" in text
|
||||
assert "<summary>Dettagli tecnici e provenienza</summary>" in text
|
||||
assert parsed == evidence
|
||||
|
||||
|
||||
def test_v3_curated_markdown_renders_enum_values_as_a_list_instead_of_a_table(tmp_path):
|
||||
evidence = CuratedEvidence.model_validate({
|
||||
**COMMON,
|
||||
"schema_version": 3,
|
||||
"kind": "enum",
|
||||
"payload": {
|
||||
"column": "clinical.episode.discharge_status",
|
||||
"values": {"D": "dimesso", "T": "trasferito | altra struttura"},
|
||||
},
|
||||
})
|
||||
|
||||
text = dump_curated_markdown(evidence)
|
||||
|
||||
assert "## Valori\n\n- `D`: dimesso\n- `T`: trasferito | altra struttura" in text
|
||||
assert not any(line.startswith("|") for line in text.splitlines())
|
||||
assert parse_curated_markdown(
|
||||
text,
|
||||
path=tmp_path / "curated" / "enum" / "discharge-status.md",
|
||||
) == evidence
|
||||
|
||||
|
||||
def test_v3_curated_markdown_rejects_visible_metadata_that_drifted_from_canonical_data():
|
||||
text = dump_curated_markdown(_domain_evidence_v3()).replace(
|
||||
"**Scopi:** Disambiguazione",
|
||||
"**Scopi:** Testo alterato",
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user