Repository navigation
Description
Raised in the review of #2158.
Export has now written a shape that Fluree's own insert refuses three times. Each time it was found after the fact and fixed with a point test:
- pre-4.2 raw
f:reifies*facts (e88b2e9); - stored blank-node labels the Turtle reader rejects (Export writes blank-node labels that its own Turtle parser rejects #1956, fixed in fix: Fluree re-inserts its own export of SPARQL UPDATE blank nodes #2156);
- an annotated or list-valued
rdf:type. JSON-LD export writes it as anrdf:typeproperty, which the JSON-LD insert refused (fixed in fix(export): write stored lists in their stored order #2158).
One harness that runs every stored shape through every export format would catch the next one before it ships.
Proposal
Build one fixture ledger holding every stored shape:
- lists: of literals, of references, and one with a decimal in it (stored values that skip V3 translation);
- an annotated plain value, an annotated type, and a list of types;
- blank nodes minted by SPARQL UPDATE:
[ … ],( … ), and<< … >>with no reifier; - legacy blank-node labels:
_:fdb-…-#bnpl0(SPARQL UPDATE before fix: Fluree re-inserts its own export of SPARQL UPDATE blank nodes #2156) and labels holding/and:(imports by Fluree 4.1.4 or earlier); - the same shapes inside a named graph.
Read it from novelty, from the index, and from novelty over an index. For each, export it in every format (Turtle, TriG, JSON-LD, N-Triples, N-Quads), insert the export into a fresh ledger, and compare the copy with the source.
Comparison
Comparing exact triples doesn't work across the whole matrix:
- escaped legacy labels re-insert as new blank nodes;
- N-Triples and N-Quads write a list as its
rdf:first/rdf:restchain, which re-inserts as stored triples rather than a list.
Instead, export the source and the copy as N-Quads and compare the two as RDF datasets, ignoring blank-node labels. A list and its chain are the same RDF graph, so this one check covers every format.
The workspace has no helper for that. testsuite-sparql has are_results_isomorphic, but that crate is outside the workspace. A small test helper is enough for a fixture with no symmetric nodes: parse the N-Quads, then relabel each blank node by a hash of its neighbours, refined until it stops changing.
These checks stay format-specific:
- Turtle, TriG and JSON-LD keep list-ness and order, checked with a crawl as
it_export_listsdoes; - stored labels that are valid keep their ids, as
it_stable_blank_nodeschecks.
Where things stand
it_export_lists::lists_export_in_order_and_reinsert_as_the_same_lists (#2158) already covers part of this. It runs lists, an annotated type, a list of types and an annotated plain value through every format and all three sources, and re-inserts the Turtle, TriG and JSON-LD exports. Legacy labels have their own test in it_stable_blank_nodes (#2156).
Still missing:
- legacy labels and SPARQL UPDATE blank nodes in the shared fixture;
- named-graph versions of every shape except lists;
- a full comparison for the N-Triples and N-Quads re-inserts.
#2159 changes how lists are read and written, so this is best written after it lands.
A matrix this wide may turn up new export bugs, and each would be its own fix. Two likely places:
- annotations inside a named graph, since export documents a limit there on its base-index scan path;
- legacy labels in a named graph.
Activity