Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
fix(export): handle contextual turtle iris
mikemikimike8d5479d22f7c
diff --git a/semantica/export/rdf_exporter.py b/semantica/export/rdf_exporter.pyindex c5f95ed6..5b2b1585 100644--- a/semantica/export/rdf_exporter.py+++ b/semantica/export/rdf_exporter.py@@ -516,9 +516,9 @@ class RDFSerializer:rel_type = rel.get("type", DEFAULT_RELATION_TYPE)lines.append(- f"<{self._as_turtle_iri(source_id)}> "- f"<{self._as_turtle_iri(rel_type)}> "- f"<{self._as_turtle_iri(target_id)}> ."+ f"<{self._as_turtle_iri(source_id, merged_namespaces)}> "+ f"<{self._as_turtle_iri(rel_type, merged_namespaces)}> "+ f"<{self._as_turtle_iri(target_id, merged_namespaces)}> .")if include_temporal:diff --git a/tests/export/test_rdf_exporter_turtle_iris.py b/tests/export/test_rdf_exporter_turtle_iris.pyindex ccf27a82..6faa3d72 100644--- a/tests/export/test_rdf_exporter_turtle_iris.py+++ b/tests/export/test_rdf_exporter_turtle_iris.py@@ -56,3 +56,22 @@ def test_turtle_preserves_absolute_iris():RDF.type,URIRef("urn:example:Person"),) in parsed+++def test_turtle_expands_context_prefixes_and_normalizes_malformed_iris():+ """Prefixes expand and malformed URI-like values are minted."""+ turtle = RDFExporter().export_to_rdf(+ {+ "@context": {"ex": "https://example.org/"},+ "entities": [{"id": "http://[invalid", "type": "ex:Person"}],+ "relationships": [],+ },+ format="turtle",+ )+ parsed = Graph().parse(data=turtle, format="turtle")++ assert (+ URIRef("https://semantica.dev/ns#http%3A%2F%2F%5Binvalid"),+ RDF.type,+ URIRef("https://example.org/Person"),+ ) in parsed