Repository navigation
RDF 1.2: rdf:reifies triple terms on the text ingest paths, and TriG-star inside GRAPH blocks - #1832
Conversation
…riples, and N-Quads ingest paths The canonical RDF 1.2 reification spelling — and the only star construct N-Triples/N-Quads have — now produces the same `f:reifies*` bundle as `<< s p o ~ r >>` and JSON-LD `@annotation`. - Lexer: `)>>` is a `TripleTermEnd` token; a bare `)` still closes a collection. - Parser: an object-position `<<(` under `rdf:reifies` emits the base triple plus the reifier attachment. Under any other predicate, nested, or inside an annotation body it keeps the specific deferred error; an annotation tail on the reification statement itself is rejected. - N-Quads → TriG regrouping treats a (possibly nested) `<<( … )>>` as one object term. - Docs: the Turtle/TriG/N-Quads ingest rows and the "current limits" list were stale — Turtle-star asserting forms and the compact `<< s p o ~ r >>` reifier in SPARQL WHERE already work; TriG-star inside GRAPH blocks, triple terms as values, the triple-term functions, and CONSTRUCT projection remain deferred.
`{| … |}`, `~ r`, `<< s p o ~ r >>` in either position, and
`r rdf:reifies <<( s p o )>>` now parse inside `GRAPH { }` blocks (and so
on N-Quads statements with a graph label). Each attachment becomes a
`RawReifiedTriple` on the block, with the base triple asserted alongside;
the transactional path emits the same named-graph `f:reifies*` templates
that JSON-LD `@graph` + `@annotation` produces, and bulk import spools the
same bundle under the block's g_id.
Kept contained to the structured GRAPH-block path: the streaming Turtle
parser, `FlakeSink`, `ImportSink`, and the default-graph text path are
untouched. Non-star TriG runs the same branches it did (the per-object
star check already existed to reject); non-star blocks carry one empty
Vec. `reified_triple_bundle` takes the graph slot explicitly.
Deferred shapes keep specific errors: `<<( … )>>` as a value, nested
triple terms, star inside an annotation body, and annotations in the
`#txn-meta` graph.
Adds a `trig` case to `insert_formats` so the named-graph ingest path has
a bench; before/after against the saved baseline was flat.
…iple-term Brings in #1823 (rules see claims), which put Turtle-star on the upsert / graph sync / memory-import paths through GraphCollectorSink — the same parser this branch taught `r rdf:reifies <<( s p o )>>` and TriG GRAPH-block star forms. Conflicts were docs only; each keeps both sides' facts: - concepts/edge-annotations, cookbook-edge-annotations, transactions/turtle: main's per-path coverage, anonymous-reifier re-send semantics, VERSION directive and rdf:type caveat, plus this branch's rdf:reifies <<( )>>, N-Triples / N-Quads, and GRAPH-block annotations. Main's "TriG: default graph only" and "<<( )>> rejected at parse time" lines are dropped. - reference/compatibility merged cleanly but carried the same two stale limits; corrected here. Build fix: main's `named_graph_block_refuses_a_reserved_reifies_predicate` builds a NamedGraphBlock without this branch's `reified` field. testsuite-sparql/Cargo.lock picks up fluree-db-query's indexmap dependency, which main's lock was already missing.
`upsert_payload_id` (from main) hashes each GRAPH block's triples to scope
anonymous blank nodes to the payload, but not the block's `reified` list,
which predates it on this branch. Anonymous reifiers in a block are
positional (`-r1`, …) and the body triples are pushed before the base
triple, so `:a :b :c {| :q 1 |}, :d .` and `:a :b :c, :d {| :q 1 |} .`
hash identically: the second upsert re-skolemizes the same reifier onto a
different edge and fails the single-target invariant instead of adding a
claim, as the documented upsert contract says it should.
Also pins `rdf:reifies <<( s p o )>>` on the upsert and graph sync paths,
which now reach it through the collector sink.
…registers The expected .nt of every RDF 1.2 Turtle eval test spells its reifiers as `r rdf:reifies <<( s p o )>>`, which now parses, so 25 eval and 3 syntax entries started passing. The handler left reifier attachments out of the comparison, so those passes only checked plain triples; it now spells each attachment as three stand-in triples on both sides. Breaking just the `rdf:reifies` attachment in the parser fails all 23 rt / bnode / annotation eval tests again, so the comparison has teeth. Eval graphs are compared as sets: the parser asserts the base triple for each `rdf:reifies`, and an expected graph that also states `s p o .` would otherwise differ from the action by a duplicate. Remaining RDF 1.2 entries are nested / non-rdf:reifies triple terms and annotation-of-annotation. construct-5's SPARQL register reason is updated: its expected graph parses now and it fails on D-4 annotation projection.
aaj3f
left a comment
There was a problem hiding this comment.
@bplatz this was one of those times where I figured I should spend at least a little more time with the PR since I've been in a lot of the same code, but--for better or worse--I have almost no comments of my own to add. This makes sense and seems right to me. I'll leave Claude's review below:
The two commits since I last looked are both real catches, and both survived me trying to disprove them. The upsert skolem fix is the subtle one — two TriG payloads that differ only in which object carries an anonymous {| |} hash identically without it, because the body triple and the base triple land on stmt_triples in the same order either way, and I reproduced the exact single-target failure the body describes by removing the loop. And the W3C harness change is what makes the 28 register removals mean something: with the attachment comparison in and just the rdf:reifies emission broken in the parser, rdf12_turtle_eval drops from 25 passing to 2 — your 23 — so those entries came off the register because the behaviour is really there, not because the comparison stopped looking. I ran all three RDF suites locally at the CI submodule commit: 0 failures, registers exactly right.
The 09-14 merge-order ask is closed the way I hoped: with #1823 in, I re-ran the write-path matrix on the builder the consensus layer dispatches every server write to, and upsert now takes default-graph star, GRAPH { } star and a file mixing both, with every annotation hydrating in its own graph; import does the same; and the VERSION "1.2" / @version prologue that used to kill extract_prefix_block is fine on every .ttl path. So the doc sentence I flagged last time is now simply true everywhere TriG is read. All five earlier mutations still go red at this head, plus two new ones for the new commits; clippy --all-targets and fmt are clean on the three crates and in testsuite-sparql.
What's left is small and mostly pre-existing, and I'd fold it in rather than leave it: (1) a VERSION "1.2" prologue on a TriG file is refused on upsert and import with undefined prefix: …, because trig_meta.rs::parse_statement has no version arm and the fallback skipper swallows the first @prefix line — main has the same gap, but this PR is the one that makes TriG an RDF 1.2 surface and turtle.md:520 says the directive is accepted anywhere; a six-line arm fixes it. (2) insert is still listed in the TriG row of the concept table and the cookbook, and insert_turtle never reads a GRAPH block. (3) The parse-time #txn-meta refusal keys on the sidecar spelling <#txn-meta>; a GRAPH <urn:fluree:{ledger}#txn-meta> star block commits at this head — that's main's txn-meta write hole extended to annotation bundles, and it's #1838's stage() guard that closes it (I confirmed the same probe is refused on the composed tree), so just a comment here, not a fix.
On #1838, since the two are up together: they share tx.rs and turtle.md; the docs conflict is a clean union, and tx.rs auto-merges but doesn't compile — #1838's two new unit tests build NamedGraphBlock without your new reified field, the same one-line fix your merge commit already made for main's test. With that in, every test from both PRs passes on the composed tree. I'd land #1838 first — it's approved and green, and its guard closes the txn-meta hole above — and rebase this with reified: Vec::new() on those two tests and a re-touch of the turtle.md TriG section; the full write-up is in the composition note.
Adherence to repo commitments:
- Patterns/abstractions: ✔
reifies_termfollows therdf_type_terminterning pattern; the skolem fix reuses the payload-hash mechanism; the harness fix reuses the action parser for the expected side.⚠️ The transactional TriG path still hand-builds the bundle the sharedreified_triple_bundlebuilds for import, and that function's doc comment is now stale about its own graph slot. - Performance (speed first, memory second): ✔ No hot path; the hash loop is a zero-iteration no-op for non-star TriG; lexer/parser costs unchanged from 09-14. Nit: still no
bench.ymlrun on the branch. - Testing: ✔ Five end-to-end tests wired through
grp_misc.rs/grp_import.rs, all seen by name, seven mutations red and restored; W3C RDF suites green locally and in CI with registers only shrinking.⚠️ N-Quads still has no end-to-end pin (capability re-verified by hand). - Conventions: ✔ Every commit including the merge carries a real body that matches what the diff does; clippy/fmt clean; docs updated — with the three precision items above.
Verified locally at 6ab09ca6d: 164 turtle + 304 transact lib tests green; the five end-to-end tests green by name; seven mutations red and restored; W3C rdf12_turtle_eval 25/29, rdf12_turtle_syntax 62/67, rdf11_turtle 302/313 with 0 failures; write-path, import, prologue and #txn-meta matrices on the server's builder; clippy --all-targets -D warnings and fmt clean on fluree-graph-turtle, fluree-db-transact, fluree-db-api, testsuite-sparql; git status --porcelain clean.
Approving so you can merge when ready — but the VERSION-on-TriG arm and the two doc rows are cheap enough that I'd rather see them in this PR than in the backlog, and if #1838 goes first, the reified: Vec::new() on its two tests is the whole rebase.
| - one named reifier on two different triples — a reifier denotes exactly one edge (see [the single-target invariant](../concepts/edge-annotations.md#one-annotation-one-edge-single-target-invariant)); | ||
| - an annotation on an `rdf:type` edge (`:s a :C {| … |}`) on the paths that convert Turtle to JSON-LD first (`upsert`, `graph sync`, memory import) — JSON-LD has no place to hang an annotation on a `@type` value. `insert` and SPARQL UPDATE accept it; | ||
| - TriG: annotations inside a `GRAPH { }` block — same rule as SPARQL UPDATE (default graph only); use JSON-LD `@annotation` for named-graph edges. | ||
| - TriG: annotations in the `#txn-meta` graph — its triples become commit metadata, not edges. |
There was a problem hiding this comment.
docs/transactions/turtle.md:520 — optional, fold-in-now (pre-existing on main, surfaced by this section now covering TriG). This sentence promises the RDF 1.2 version directive "is accepted anywhere a directive may appear and ignored", and that's true for every .ttl path now that #1823 is in — I re-ran VERSION "1.2" and @version "1.2" . through insert_turtle, upsert_turtle, sync_named_graph and bulk import and all four take them. It is not true for TriG. A file that starts VERSION "1.2" and then has a GRAPH { } block is refused on upsert_turtle and on import with undefined prefix: rdf (or ex, whichever @prefix comes first), star or no star.
The mechanism is in trig_meta.rs::parse_statement (:546-604, not in this diff): there are arms for KwPrefix | KwSparqlPrefix, KwBase | KwSparqlBase, KwGraph and the compact <iri> { form, and everything else falls to parse_default_triple (:1315), which advances to the next Dot. VERSION "1.2" has no dot, so the skipper swallows the following @prefix … . line into a default-graph span, that prefix is never registered, and the block's first prefixed term fails at expand_prefixed. @version "1.2" . carries a dot, so only that statement is swallowed and it works. main's trig_meta.rs has no KwVersion / KwSparqlVersion either, so your PR didn't introduce this — but yours is the one that makes TriG an RDF 1.2 surface, and an RDF 1.2 TriG exporter emits exactly this prologue.
The fix is a sibling of the existing directive arms: match KwVersion | KwSparqlVersion, advance over the keyword and the string literal, take the trailing Dot for the @version form, and push the span onto self.directives so the reconstructed default-graph Turtle keeps the directive (the streaming parser already accepts it). Six lines and one test_trig_star_*-style case. I recognize this is minor and non-blocking — but if you agree it's right, I'd rather see it folded in here than tracked-and-forgotten, since this is the PR whose docs make the promise.
| | **SPARQL 1.2 UPDATE** | `INSERT DATA { :s :p :o {\| ... \|} }`, `~ <reifier>`, optional `INSERT { } WHERE { }` templates | Use this when integrating with SPARQL pipelines or when porting from RDF 1.2 / SPARQL-star. **Default graph only:** an annotation tail inside an explicit `GRAPH { }` block, or under a `WITH <g>` template, is rejected — use the JSON-LD surface for named-graph edge annotations. See [SPARQL 1.2 surface](#sparql-12--rdf-12-surface) below for the per-operation rules. | | ||
| | **Turtle file ingest** (`insert`, `upsert`, bulk `import`, `fluree graph sync`, memory import) | RDF 1.2 annotation tail: `{\| ... \|}`, `~ reifier`, `<< s p o >>` | Same on-disk shape as `@annotation`. Every form asserts the base edge (Fluree reifies asserted edges, so `<< s p o >>` is asserting here). Rejected at parse time: `<<( ... )>>` triple terms, nested annotations, annotations on collections. Paths that convert to JSON-LD first (`upsert`, `graph sync`, memory import) also reject an annotation on an `rdf:type` edge. TriG: no annotations inside `GRAPH { }` blocks (default graph only, as for SPARQL UPDATE). See [Turtle ingest](../transactions/turtle.md#edge-annotations-rdf-12--turtle-star). | | ||
| | **SPARQL 1.2 UPDATE** | `INSERT DATA { :s :p :o {\| ... \|} }`, `~ <reifier>`, optional `INSERT { } WHERE { }` templates | Use this when integrating with SPARQL pipelines or when porting from RDF 1.2 / SPARQL-star. **Default graph only:** an annotation tail inside an explicit `GRAPH { }` block, or under a `WITH <g>` template, is rejected — use the JSON-LD surface or TriG-star for named-graph edge annotations. See [SPARQL 1.2 surface](#sparql-12--rdf-12-surface) below for the per-operation rules. | | ||
| | **Turtle / N-Triples / TriG / N-Quads ingest** (`insert`, `upsert`, bulk `import`, `fluree graph sync`, memory import) | RDF 1.2 asserting forms: `:s :p :o ~ <reifier> {\| ... \|}`, `<< :s :p :o ~ :r >>` in subject or object position, and the canonical `:r rdf:reifies <<( :s :p :o )>>` (the only star spelling N-Triples and N-Quads have) — in the default graph and inside TriG `GRAPH { }` blocks alike | Same on-disk bundle as `@annotation`. An annotation inside a `GRAPH { }` block, or on an N-Quads statement with a graph label, is written into that graph with the edge's graph identity, exactly as JSON-LD `@graph` + `@annotation` does. Every form asserts the base edge (Fluree reifies asserted edges, so `<< s p o >>` and `rdf:reifies <<( s p o )>>` are asserting here). Rejected with a specific error: `<<( ... )>>` anywhere other than the object of `rdf:reifies`, nested triple terms, star constructs inside an annotation body, annotations on collections, and annotations in the `#txn-meta` graph. Paths that convert to JSON-LD first (`upsert`, `graph sync`, memory import) also reject an annotation on an `rdf:type` edge. See [Turtle ingest](../transactions/turtle.md#edge-annotations-rdf-12--turtle-star). | |
There was a problem hiding this comment.
docs/concepts/edge-annotations.md:30 — optional, fold-in-now. Two precision points on this row, both small. First, the row header lists insert among the paths, and the cookbook row (cookbook-edge-annotations.md:15) says "insert, upsert, import and graph sync all accept … and TriG GRAPH { } blocks accept them too" — a reader will take that as insert reading TriG, and it doesn't: insert_turtle rejects any GRAPH block with expected subject, found KwGraph (your body's "Noted, not fixed here"). #1838 adds the "TriG goes through upsert, not insert" note to turtle.md, but not to these two pages; a parenthetical "(TriG via upsert / import)" on both rows would close it.
Second, "annotations in the #txn-meta graph" being "rejected with a specific error" holds for the sidecar spelling only — see the trig_meta.rs:760 comment below. It's probably enough to say "in a <#txn-meta> block" here.
| self.advance(); | ||
|
|
||
| let reified = std::mem::take(&mut self.reified); | ||
| if graph_iri == TXN_META_GRAPH_IRI && !reified.is_empty() { |
There was a problem hiding this comment.
fluree-db-transact/src/parse/trig_meta.rs:760 — optional; worth a comment line, and it's really merge-order context. This check compares graph_iri == TXN_META_GRAPH_IRI, i.e. the literal "#txn-meta" the sidecar path keys on. I probed the other spelling on the builder: GRAPH <urn:fluree:{ledger}#txn-meta> { ex:alice ex:knows ex:bob {| ex:confidence 0.9 |} . } — the ledger's real txn-meta IRI, from fluree_db_core::txn_meta_graph_iri — is an ordinary NamedGraphBlock to this parser, resolves through the registry to g_id 1 in tx.rs, and commits at this head, annotation bundle and all. For plain triples that's exactly main's #txn-meta write hole that #1838 closes at the top of stage() (its trig_data_writes_refuse_the_txn_meta_graph uses the full IRI), so this isn't yours to fix and shouldn't be fixed here — this parser has no ledger context, which is why #1838 put the guard where write targets are decided. On the composed tree the same probe is refused with transaction targets reserved system graph <…#txn-meta>. I'd just add a sentence to this comment saying it covers the sidecar spelling and the full-IRI write target is a stage() concern, so the next reader doesn't take it as the whole rule.
| for triple in &block.triples { | ||
| let _ = write!(w, "\0{triple:?}"); | ||
| } | ||
| for reified in &block.reified { |
There was a problem hiding this comment.
fluree-db-api/src/tx.rs:68 — praise, verified. This is a subtle catch and the commit body's mechanism is exactly right: attach_reifier pushes onto reified (trig_meta.rs:818), the annotation body lands on stmt_triples during parse_predicate_object_list(&reifier) (:990), and the base statement's ParsedTriple is pushed after the object list returns (:1029), so :a :b :c {| :q 1 |}, :d . and :a :b :c, :d {| :q 1 |} . really do produce identical triples and differ only in reified. With this loop removed the second upsert fails with annotation subject [10:fdb-upsert…-0--r1] would reify a malformed or multi-target edge … Duplicate("f:reifiesObject") — same skolem id for both payloads — and with it present both claims land. Non-star TriG is untouched by construction: the loop body runs zero times, so the byte stream fed to the hasher is identical to before. I also like that it's the same {…:?} mechanism the triples already use rather than a second scheme.
| }), | ||
| } | ||
| } | ||
| for r in graph.reifications() { |
There was a problem hiding this comment.
testsuite-sparql/src/rdf_handlers.rs:177 — praise, verified. Parsing the expected .nt with the same parser as the action and spelling each attachment as three stand-in triples is what turns those 25 newly-passing eval entries into evidence: I replaced sink_emit_reified_triple with a no-op in parse_reifies_triple_term (base triple still asserted) and rdf12_turtle_eval went from 25 passed / 0 failed to 2 passed / 23 failed — your body's number. The dedup at :218-227 is RDF set semantics, not a loosening. And the registers only shrink: 0 entries added, 28 removed across the PR, with check_testsuite policing stale entries, so the trim is exactly the set that flipped. Ran locally with the submodule content at the same gitlink CI checks out (efccbc6b8): eval 25/29, syntax 62/67, RDF 1.1 302/313, 0 failures.
| /// guard already, so this only fires on shapes the base emission also | ||
| /// rejected. | ||
| pub(crate) fn reified_triple_bundle( | ||
| g: Option<Sid>, |
There was a problem hiding this comment.
fluree-db-transact/src/generate/flakes.rs:476 — optional, carried forward. Claude caught this one on 09-14 and it still stands, with one new wrinkle: import.rs:661 calls this shared builder with the graph slot while tx.rs:2414-2461 hand-builds the same five templates, so the doc comment's "the construction sequence lives in exactly one place" is now half true; and the paragraph just above this line still says "Plain-Turtle surfaces are default-graph only … → g = None" right above a signature that now takes g: Option<Sid>. The equality test has teeth (dropping the f:reifiesGraph push at tx.rs:2447 reds trig_star_in_graph_block_matches_jsonld_named_graph_annotation — re-verified at this head), so I don't think there's a cheap unification. Minimally, update this doc comment to say the graph slot is set by TriG bulk import and that the transactional TriG path is a second, test-pinned builder. Minor — but if you agree, I'd rather it went in now than into the backlog.
| TokenKind::String | TokenKind::LongString | TokenKind::StringEscaped(_) | ||
| ); | ||
| i += 1; | ||
| // An RDF 1.2 triple term `<<( s p o )>>` (possibly nested) is one |
There was a problem hiding this comment.
fluree-db-transact/src/parse/nquads.rs:137 — optional, carried forward. The depth walk is right and I still can't break it, and I re-ran an actual .nq file at this head — _:r1 rdf:reifies <<( … )>> . in the default graph and _:r2 rdf:reifies <<( … )>> <g> . under a label — and both hydrate through graph-scoped annotation queries. So the capability is real; the gap is only that nothing in it_import.rs pins it (the import_single_nt_file_then_query / import_nt_directory_then_query tests don't use rdf:reifies), and the regrouper is the one component here with no end-to-end net under it. The test I ran is about 40 lines; happy to hand it over if that's useful.
| let subject = p.parse_tt_subject()?; | ||
| let predicate = p.parse_predicate()?; | ||
| let object = p.parse_tt_object()?; | ||
| p.expect(&TokenKind::TripleTermEnd)?; |
There was a problem hiding this comment.
fluree-graph-turtle/src/parser.rs:1321 — optional nit, carried forward. Commenting here because expect() (:483-493) isn't in this diff. It formats token kinds with {:?}, so the near-miss most likely to be typed by hand — <<( :a :b :c ) >>, whitespace before the closer — reports expected TripleTermEnd, found RParen, while TokenKind's Display (which this PR extends with )>> at token.rs:247) already has the user-facing spelling. {} would read expected ')>>', found ')'. Touches every expect message, so genuinely optional.
| ledger | ||
| } | ||
|
|
||
| /// TriG goes through the transact builder's `upsert_turtle`: the plain |
There was a problem hiding this comment.
fluree-db-api/benches/insert_formats.rs:213 — optional, carried forward. gh run list --workflow bench.yml still shows only nightly main runs, so "before/after against a saved baseline: flat" remains a local result; since #1802 the way to put it on record is gh workflow run bench.yml --ref feat/rdf12-reifies-triple-term -f compare_only=true. I read the paths and have no perf concern — this is about citability.
| // `)>>` closes an RDF 1.2 triple term; bare `)` stays a collection | ||
| // close. One extra peek on the `)` branch only. | ||
| ')' => { | ||
| if input.starts_with(">>") { |
There was a problem hiding this comment.
fluree-graph-turtle/src/lex/lexer.rs:949 — praise, re-verified. Still the line I'd most expect to bite later, and it still doesn't: the only inputs whose tokens change are collections inside << … >>, which parse_rt_subject / parse_rt_object reject at the ( before the closer is reached, so the error text is byte-identical before and after. Disabling the rule reds six unit tests at this head.
…iple-term Brings in #1838. Two resolutions: - docs/transactions/turtle.md: union of both TriG sections; main's copy of the claims-file upsert paragraph is dropped, as this branch already has it. - fluree-db-api/src/tx.rs: #1838's two new NamedGraphBlock tests gain the `reified: Vec::new()` field this branch added (auto-merged but did not compile).
`trig_meta.rs::parse_statement` had no arm for `VERSION` / `@version`, so the statement fell to the default-triple skipper, which advances to the next `.`. `VERSION "1.2"` carries no dot, so the following `@prefix` line was swallowed with it and the first prefixed term in a GRAPH block failed with `undefined prefix`, on both `upsert` and bulk `import`. The directive now parses like `@prefix` / `@base` and its span is kept in the reconstructed Turtle, whose parser validates the specifier. Review follow-ups on the same PR: - End-to-end pins for TriG with a VERSION header on upsert and import, and for N-Quads `rdf:reifies <<( )>>` import in the default graph and under a graph label (the regrouper had no end-to-end test). - Docs: TriG is read by `upsert` / `import`, not `insert`; the parse-time txn-meta refusal covers a `<#txn-meta>` block. - The txn-meta check in `parse_graph_block` notes that the full txn-meta IRI is refused in `stage()`. - `reified_triple_bundle`'s doc comment reflects its TriG-import caller and names the transactional TriG builder and the test pinning its parity.
Addressed in 0e3329d |
TriG import spools each reifier bundle under the block's g_id whether or not the bundle carries `f:reifiesGraph`, so graph-scoped annotation queries could not tell the two apart: passing `None` as the graph to `reified_triple_bundle` in `import_trig_commit` left every existing test green, including `import_trig_star_named_graph_annotation_is_queryable`. The new test checks the edge identity instead. The imported bundle must decode to the GRAPH block's graph, and a SPARQL `DELETE DATA` of the base edge in that graph must cascade to the bundle. With the graph slot dropped, each assertion fails independently; the cascade half shows the user-visible consequence, a claim outliving the edge it reifies.
Turtle and TriG parse errors formatted token kinds with `{:?}`, so a
hand-typed near miss like `<<( :a :b :c ) >>` reported
`expected TripleTermEnd, found RParen`. `TokenKind`'s `Display` is now the
user-facing spelling, with punctuation and keywords quoted as written and
value tokens named by kind (`an IRI`, `a prefixed name`, `end of input`),
and every token-bearing error in the Turtle parser and the TriG scanner uses
it: that input now reads `expected ')>>', found ')'`.
Nothing matched on the old text. The three places that quoted
`expected subject, found KwGraph` (turtle.md, a test doc comment, a W3C
register comment) now quote `found 'GRAPH'`.
What
Closes two RDF 1.2 ingest gaps on the Turtle-family surfaces, and brings the edge-annotation docs back in line with what already worked.
r rdf:reifies <<( s p o )>>on Turtle, N-Triples, and N-Quads. This is the canonical spelling every RDF 1.2 asserting form desugars to, and the only star construct N-Triples and N-Quads have. It now produces the samef:reifies*bundle as<< s p o ~ r >>and JSON-LD@annotation.)>>is aTripleTermEndtoken; a bare)still closes a collection.<<(underrdf:reifiesemits the base triple plus the reifier attachment. Under any other predicate, nested, or inside an annotation body it keeps the specific deferred error; an annotation tail on the reification statement itself is rejected.<<( … )>>as one object term.TriG-star inside
GRAPH { }blocks.{| … |},~ r,<< s p o ~ r >>in either position, andr rdf:reifies <<( s p o )>>now parse inside named-graph blocks (and so on N-Quads statements with a graph label). Each attachment becomes aRawReifiedTripleon the block with the base triple asserted alongside. The transactional path emits the named-graphf:reifies*templates that JSON-LD@graph+@annotationproduces, and bulk import spools the same bundle under the block's g_id.Why the contained shape
The change is confined to the structured GRAPH-block path in
trig_meta.rsand its two consumers. The streaming Turtle parser,FlakeSink,ImportSink, and the default-graph text path are untouched. Non-star TriG runs the same branches it did before (the per-object star check already existed to reject); non-star blocks carry one emptyVec. Rerouting GRAPH bodies through the streaming parser is the better long-term shape (it would also lift the structured path's lack of[ ]and( )support) but rewrites the non-star TriG path, so it is left for its own PR with its own gate.insert_formatsgains atrigcase so the named-graph ingest path has a benchmark at all. Before/after against a saved baseline: TriG and Turtle cells flat, JSON-LD within noise on a re-run.Semantics to be aware of
-r{N}labels, outside the user-writable blank-node label space.<<( … )>>as a value, nested triple terms, star inside an annotation body, annotations in the#txn-metagraph.Docs
docs/concepts/edge-annotations.md,docs/transactions/turtle.md, and both cookbooks were stale in the other direction too: Turtle-star asserting forms and the compact<< s p o ~ r >>reifier in SPARQLWHEREalready worked. The ingest rows and the "current limits" list now describe the real surface. Still deferred and called out as such: triple terms as values, theTRIPLE/isTRIPLE/SUBJECT/PREDICATE/OBJECTfunctions, CONSTRUCT projection of annotations, and SPARQL UPDATE annotation tails underGRAPH { }/WITH <g>.Testing
rdf:reifiesform (equivalence with the~spelling, lang-tagged object, full-IRI predicate, nested/other-predicate/annotation-tail rejections) and a lexer test for)>>.rdf:reifiesbundle is bit-identical to the JSON-LD@annotationbundle; the TriG-star bundle in a named graph is bit-identical to the JSON-LD@graph+@annotationbundle and hydrates through a named-graph-scoped query; bulk-imported TriG-star annotations (plain and language-tagged) hydrate through a named-graph query. The three end-to-end tests were each verified to fail with the corresponding code path disabled.sparql12_eval_triple_termsregister unchanged.Noted, not fixed here
The transact builder's
insert_turtletakes a fast path that skips GRAPH-block extraction, so TriG only works throughupsert_turtleon that builder. This predates the branch (the W3C harness already works around it) and surfaced again in the new bench case. Follow-up: #1849.Follow-up: #1848 — unify the transactional TriG-star reifier bundle in
tx.rswithreified_triple_bundle.