fix: preserve literal types in focus quoted triples and document tracing (#769)

The triples client returns Uri/Literal (str subclasses), not Term
objects.  _quoted_triple() treated all values as IRIs, so literal
objects like skos:definition values were mistyped in focus
provenance events, and trace_source_documents could not match
them in the store.

Added to_term() to convert Uri/Literal back to Term, threaded a
term_map from follow_edges_batch through
get_subgraph/get_labelgraph into uri_map, and updated
_quoted_triple to accept Term objects directly.
This commit is contained in:
cybermaggedon 2026-04-08 13:37:02 +01:00 committed by GitHub
parent 4b5bfacab1
commit e81418c58f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 25 deletions

View file

@ -465,11 +465,18 @@ def exploration_triples(
return triples
def _quoted_triple(s: str, p: str, o: str) -> Term:
"""Create a quoted triple term (RDF-star) from string values."""
def _quoted_triple(s, p, o) -> Term:
"""Create a quoted triple term (RDF-star).
Accepts either Term objects (preserving original types) or plain
strings (treated as IRIs for backward compatibility).
"""
s_term = s if isinstance(s, Term) else _iri(s)
p_term = p if isinstance(p, Term) else _iri(p)
o_term = o if isinstance(o, Term) else _iri(o)
return Term(
type=TRIPLE,
triple=Triple(s=_iri(s), p=_iri(p), o=_iri(o))
triple=Triple(s=s_term, p=p_term, o=o_term)
)