feat(evidence): structure v3 domain rules for review
This commit is contained in:
@@ -367,9 +367,9 @@ def test_migrate_workspace_evidence_rewrites_v1_units_as_v3_without_a_model_call
|
||||
assert report.unchanged == ()
|
||||
assert migrated.schema_version == 3
|
||||
assert migrated.payload.rule == "La fascia pediatrica comprende i minori."
|
||||
assert "## Regola\n\nLa fascia pediatrica comprende i minori." in curated_path.read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
text = curated_path.read_text(encoding="utf-8")
|
||||
assert "## Regola\n\n<!-- tht:raw-rule:" in text
|
||||
assert "La fascia pediatrica comprende i minori." in text
|
||||
assert report.findings == ()
|
||||
|
||||
|
||||
@@ -393,6 +393,41 @@ def test_migrate_workspace_evidence_rewrites_v2_units_as_table_free_v3(tmp_path)
|
||||
assert not any(line.startswith("|") for line in text.splitlines())
|
||||
|
||||
|
||||
def test_migrate_workspace_evidence_rewrites_legacy_v3_rule_presentation(tmp_path):
|
||||
source_text = "I pazienti sotto i 18 anni sono pediatrici."
|
||||
evidence = _evidence(source_text).model_copy(update={"schema_version": 3})
|
||||
_write_workspace(tmp_path, evidence, source_text)
|
||||
curated_path = tmp_path / "evidence" / "curated" / "domain" / "fascia-pediatrica.md"
|
||||
legacy_text = curated_path.read_text(encoding="utf-8")
|
||||
legacy_text = legacy_text.replace(
|
||||
"## Regola\n\n<!-- tht:raw-rule:",
|
||||
"## Regola\n\n<!-- tht:legacy-raw-rule:",
|
||||
1,
|
||||
)
|
||||
# Recreate the exact pre-structured v3 body from the canonical value.
|
||||
start = legacy_text.index("<!-- tht:field:rule -->")
|
||||
end = legacy_text.index("<!-- /tht:field:rule -->", start)
|
||||
legacy_rule = (
|
||||
"<!-- tht:field:rule -->\n"
|
||||
"## Regola\n\n"
|
||||
f"{evidence.payload.rule}\n"
|
||||
)
|
||||
curated_path.write_text(
|
||||
legacy_text[:start] + legacy_rule + legacy_text[end:],
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
report = migrate_workspace_evidence(tmp_path, git_status=lambda _: ())
|
||||
|
||||
migrated_text = curated_path.read_text(encoding="utf-8")
|
||||
assert report.migrated == ("evidence:fascia-pediatrica",)
|
||||
assert report.unchanged == ()
|
||||
assert "## Regola\n\n<!-- tht:raw-rule:" in migrated_text
|
||||
assert load_curated_tree(tmp_path / "evidence" / "curated")[0].payload.rule == (
|
||||
evidence.payload.rule
|
||||
)
|
||||
|
||||
|
||||
def test_migrate_workspace_evidence_rejects_dirty_curated_files_in_a_nested_workspace(tmp_path):
|
||||
subprocess.run(["git", "init", "--quiet", str(tmp_path)], check=True)
|
||||
workspace_root = tmp_path / "psd-clinical"
|
||||
|
||||
Reference in New Issue
Block a user