mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
fix(export): keep caller data out of the shipped ns# namespace Every JSON-LD context set @vocab to https://semantica.dev/vocab/, which 404s, so every bare term in caller data (extracted entity/ relationship types, arbitrary metadata keys) minted under a namespace the package never ships. The obvious fix, pointing @vocab at SEMANTICA_NS instead, turned out to be worse than the dead link: since that namespace is real and populated, every bare term a caller happens to use now expands into something that looks like official Semantica vocabulary. An extracted type "ORG" became ns#ORG, a class the vocabulary never defines. A metadata key "source" attached a plain string value to sem:source, an owl:ObjectProperty that already exists in semantica-ns.ttl with a resource-valued range, silently corrupting its semantics. @vocab is now removed from all five contexts (four in json_exporter.py, one in rdf_exporter.py) rather than repointed. Every document already used explicit semantica: prefixes for its own terms, so nothing else in the output changes; an unscoped bare term now simply fails to expand, which is standard JSON-LD behavior for a context that doesn't know it, instead of being silently claimed by our namespace. Two call sites needed to stop handing caller data to @type/bare terms in the first place: - Entity nodes are always typed semantica:Entity now, with the caller's label carried as a semantica:type string instead of minted into @type. This matches how relationship nodes already carried their type. sem:type's domain in semantica-ns.ttl opens up to cover entities as well as relationships, following the sem:confidence precedent, since the property is now legitimately emitted for both. - semantica:metadata gets an explicit @json term definition, so a caller's metadata dict travels as one rdf:JSON literal instead of having its keys expand as separate predicates. A metadata key can no longer collide with a real ontology term no matter what the caller names it. Both JSONExporter and RDFExporter.serialize_to_jsonld got the same treatment, since they build separate JSON-LD structures for the same underlying data. The regression tests assert the negative space this bug lived in: no context declares @vocab, no caller type label appears as an rdf:type under ns#, and no caller metadata key appears as a predicate under ns# at all, only as content inside the single JSON literal. Closes #1146