feat(evidence): build semantic fragments from typed units
This commit is contained in:
@@ -52,6 +52,59 @@ def test_frontmatter_can_end_at_eof_without_inventing_content():
|
||||
assert document.content == ""
|
||||
|
||||
|
||||
def test_normalize_preserves_validated_curated_evidence_for_semantic_projection():
|
||||
source = SourceObject(
|
||||
source_id="filesystem:fascia-pediatrica",
|
||||
uri="file:///safe/evidence/curated/formula/fascia-pediatrica.md",
|
||||
fingerprint="sha256:" + "a" * 64,
|
||||
metadata={"relative_path": "curated/formula/fascia-pediatrica.md"},
|
||||
)
|
||||
raw = (
|
||||
"---\n"
|
||||
"schema_version: 1\n"
|
||||
"id: evidence:fascia-pediatrica\n"
|
||||
"title: Fascia pediatrica\n"
|
||||
"kind: formula\n"
|
||||
"purposes: [sql_generation]\n"
|
||||
"applies_to:\n"
|
||||
" columns: [clinical.patient.birth_date]\n"
|
||||
"language: it\n"
|
||||
"provenance:\n"
|
||||
" source_file: source/paziente.md\n"
|
||||
" source_sha256: sha256:" + "b" * 64 + "\n"
|
||||
" supporting_excerpts: [Pazienti con età inferiore a 18 anni.]\n"
|
||||
"review_items: []\n"
|
||||
"formula:\n"
|
||||
" concept: fascia pediatrica\n"
|
||||
" columns: [clinical.patient.birth_date]\n"
|
||||
" sql: CASE WHEN age < 18 THEN 'pediatric' END\n"
|
||||
"---\n"
|
||||
).encode()
|
||||
|
||||
document = normalize(AcquiredDocument(source=source, content=raw, media_type="text/markdown"), "pipe:v1")
|
||||
|
||||
assert document.content == raw.decode()
|
||||
assert document.title == "Fascia pediatrica"
|
||||
assert document.metadata["curated_evidence"]["id"] == "evidence:fascia-pediatrica"
|
||||
assert document.metadata["curated_evidence"]["payload"]["concept"] == "fascia pediatrica"
|
||||
|
||||
|
||||
def test_only_curated_markdown_is_treated_as_canonical_evidence_without_relative_metadata():
|
||||
source = SourceObject(
|
||||
source_id="filesystem:notes",
|
||||
uri="file:///safe/evidence/curated/formula/notes.txt",
|
||||
fingerprint="sha256:" + "a" * 64,
|
||||
)
|
||||
|
||||
document = normalize(
|
||||
AcquiredDocument(source=source, content=b"ordinary note", media_type="text/plain"),
|
||||
"pipe:v1",
|
||||
)
|
||||
|
||||
assert document.content == "ordinary note"
|
||||
assert "curated_evidence" not in document.metadata
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"frontmatter",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user