Skip to content

fix: let Turtle preprocessing own namespace discovery - #58

Merged
jdsika merged 1 commit into
mainfrom
fix/serializer-owned-namespace-discovery
Sep 11, 2026
Merged

fix: let Turtle preprocessing own namespace discovery#58
jdsika merged 1 commit into
mainfrom
fix/serializer-owned-namespace-discovery

Conversation

@jdsika

@jdsika jdsika commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Stacked on #57; merge that first and this diff reduces to its own commit.

Summary

  • Let the Turtle serializer decide which namespaces earn a declaration, per
    term position, instead of forcing a QName split on every IRI in the graph.
    Splitting unconditionally invented http://a.example/% as the namespace of
    the valid IRI <http://a.example/%25>, and that declaration is not readable,
    so deterministic_turtle refused valid graphs whose subject, object or
    datatype IRI has no prefixed name.
  • Traverse triples in lexical predicate order during preprocessing, so the
    generated ns1, ns2, … names stay a function of the graph rather than of
    its insertion order, and present every triple exactly once so the reference
    counts that decide blank-node and collection layout are unchanged.
  • Keep the store-order preparation for the formats whose serializers discover
    namespaces while traversing: RDF/XML output is byte-identical.
  • Add 61 term-position, binding, keyword-predicate, traversal-count,
    insertion-order and cross-process cases, and document the presentation change.

Presentation change

Turtle-family output no longer declares a namespace that only a subject, object
or datatype used; those terms are written as complete IRIs, so "42"^^ns2:integer
becomes "42"^^<http://www.w3.org/2001/XMLSchema#integer> unless the caller
bound the namespace. One-time diff, documented in the changelog with the
remedy: bind the namespaces you want compact.

Boundary this does not cross

A predicate whose split is not a valid IRI is still refused. The namespace
there is the RDFLib serializer's own choice, reproduced on rdflib 6.3.2 and
7.6.0, and canonicalize_rdf_graph, which writes predicates in full,
serializes those graphs. No dependency grammar is patched locally.

Verification

  • Source suite: 1,170 tests pass, 96.21% runtime coverage.
  • Full suite at both dependency endpoints: 1,170 pass on rdflib 6.3.2 with
    pyoxigraph 0.5.4 and on rdflib 7.6.0 with pyoxigraph 0.5.11.
  • Failing-before evidence: both example IRIs in subject, object and datatype
    position raised at the previous base and now serialize and reparse
    isomorphically through every Turtle-family alias, normal and degraded.
  • Explicit before/after byte comparison over bound, unbound, shared-list and
    degraded graphs: RDF/XML, JSON-LD, N-Triples and pyoxigraph Turtle bytes
    unchanged; the Turtle-family delta is only the removed declarations.
  • Ruff, mypy, reference validator and requirement checker pass offline.
  • Exact-wheel suite: 1,168 pass with two expected source-only skips.
  • The platform/Python CI matrix must pass before merge.

No public signature, dependency requirement or version changes.

@jdsika
jdsika force-pushed the fix/serializer-owned-namespace-discovery branch from 5768472 to 6f0c9fe Compare September 11, 2026 07:32
Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
@jdsika
jdsika force-pushed the fix/serializer-owned-namespace-discovery branch from 6f0c9fe to 455f6aa Compare September 11, 2026 07:36
@jdsika
jdsika merged commit 945e4cc into main Sep 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant