Skip to content

fix: typed dataset and graph references: one grammar, one resolver - #2007

Merged
bplatz merged 63 commits into
mainfrom
feat/typed-dataset-references
Oct 20, 2026
Merged

bplatz merged 63 commits into
mainfrom
feat/typed-dataset-references

Conversation

@aaj3f

@aaj3f aaj3f commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This is more than any one issue below needs, on purpose. Dataset and graph references were strings that each site interpreted on its own, and the sites disagreed: SPARQL couldn't read the config graph JSON-LD could (#1512), graph() refused names db() took (#1961), and the CLI silently ignored a from naming the ledger's own graph (#1972). So rather than patch each site, this parses a reference once, at the edge, into a typed value, with one grammar and one resolver for reads and writes, so every surface reads it the same way and there's one place to reason about and tune. Fwiw, it's one of five PRs taking this approach, with #2006, #2008, #2009 and #2010.

A dataset or graph reference — FROM, FROM NAMED, JSON-LD from/fromNamed, USING/WITH, a SERVICE endpoint, db()/graph(), the ledger path of a route — used to be text that every surface split and classified on its own. Before this PR there were seven parsers of the address grammar and nine string-shape classifiers, and they disagreed about #, @ and urn:fluree:. This PR parses a reference once, at the edge, into typed values in fluree-db-core, and resolves it through one table. Most of the fixes below fall out of that: each was a surface where a classifier guessed wrong.

This is part 1 of two. It changes how references are parsed and resolved, not which execution lane the server or the embedded API picks for a shape: each shape runs where it ran before, with two exceptions that follow from reading a query the way the engine's parser reads it. A JSON-LD dataset written under opts now takes the lane the same dataset takes at the top level (the parser has always read opts first), and the CLI's router sends a query whose dataset names a graph or another branch to the connection path, which reads it (#1972). Moving shapes between lanes is lane consolidation, which comes in a follow-up PR (part 2); see the end.

Base. main, with #2019 merged (3da440dbc). This branch's own 52 commits sit on #2019's last head, b061c5fcd, and main is merged in (85183e83f; a0050eb49 at ba694ee79; 1fbb44a4b at 58b53238a; 6ad964919 at ba4a982ec, with #2102; 03e4b43ed at f3c3b00ec; 86cd7e2c2 at 04e1a6d37, with #2120; 893521fb1 at 1d06ae2ef, with #2009 and #2119; 06190d23c at d9a1d2004, with #2122, #2126, #2127, #2131 and #2133; d68a3e871 at 4a0d14a1a, with #2109, #2118 and #2137).

Where #1997's review left off. This also picks up the rest of bplatz's review comment on #1997: #1997 (comment). #1997 made the ledger's own address name its default graph in an update's default-graph positions (WITH, a JSON-LD top-level graph). This PR makes it do so in every graph position of a query and an update, including templates, data quads, TriG blocks and bulk import — see "Graph positions" below.

Fixes #1972
Fixes #1961
Fixes #1982
Fixes #1512
Follow-up: #1975
Follow-up: #1996

Since the last review (bplatz, 2026-10-19)

main is merged in again (86cd7e2c2; BENCHMARKING.md keeps both table rows). Every item from the review is addressed here, in six commits; main is then merged in with #2009, and four more commits finish the keyword consolidation, fix what that merge broke, and pin it (see "Merged with #2009", below the table):

  • ba06dd75c, core: one graph-name table and one address lexer.
    • TargetLedger reads names through GraphNameTable, which also answers which IRI a reserved slot is registered under. A reserved keyword in a graph position (L:feature#config, and the branch's own urn:fluree: spelling) now names the graph at its slot. On a branch made from an indexed ledger, a write lands where FROM <L:feature#config> reads; before, it registered a new graph.
    • fluree_db_binary_index::HeadGraphNames is the one registry-then-binary-store lookup. The API's view and dataset paths, transact, and LedgerView/GraphNames all read through it.
    • A keyword resolves before the exact-registry lookup, as main checked DEFAULT_GRAPH_IRI first. A graph an earlier version registered as urn:default no longer shadows the default graph in FROM/USING/WITH.
    • AddressText is the one place an address's text splits at # and @. LedgerRef::parse and DatasetRef::parse split through it, and so do the member identifier and the pinned member's alias.
  • d6bbda4b5, transact: an update's USING <urn:g1>, USING NAMED <ex:g> or "fromNamed": ["urn:g1"] naming a graph the ledger lacks contributes nothing again. Only an address that can be nothing but another ledger (USING <other>) is a 400.
  • a82e3953b, sparql: under a BASE, a ledger address that names its branch or a time (my_db:main, mydb@t:3) is taken as written, since no relative IRI is spelled that way. A bare name (mydb) still follows BASE: the W3C dataset tests depend on BASE resolving FROM <data-g1.ttl>, which is lexically the same kind of text. That is the one difference from main here; see the table.
  • 42c41706f, api/cli: with no registry to consult (fluree query --remote), text that reads both as a graph IRI and as another ledger's address is that address, so FROM <other:main> and {"from": "other:main"} go to /query, as on main. Each JSON-LD source is parsed once.
  • 7adc15fd8, server: the ledger routes (/query, /stream/query, /explain) await their ledger's min-t before they read its registry. The SPARQL routes keyed the header's min-t to whatever the dataset parser reported, so FROM <urn:g1> waited on a ledger named urn:g1; both languages now share path_ledger_min_t. scope_registry propagates a load error other than not-found. A proxy-storage peer reads the registry too: its queries load through the same cached handle.
  • 7db0c3aab, api/cli: a local query reads the head its route was chosen on (Fluree::db_with_default_context_from_handle, and an --at twin), so naming a dataset no longer costs a second ledger load.

Against main, for the shapes this round touches:

Shape main the last head (6ad964919) now
fluree query --remote, FROM <other:main> or {"from": "other:main"} /query ledger route, 400 "Ledger mismatch" /query
--remote, FROM NAMED <urn:x> (a graph of the remote ledger) /query, read as a ledger ledger route, the graph /query, read as a ledger; FROM NAMED <mydb:main#urn:x> reads the graph
An update's USING <urn:g1>, USING NAMED <ex:g>, "fromNamed": ["urn:g1"], no such graph matches nothing 400 "names ledger" matches nothing
BASE declared, FROM <mydb@t:3> or <my_db:main> as written BASE-resolved, names no ledger as written
BASE declared, FROM <mydb> as written BASE-resolved BASE-resolved, as SPARQL specifies
A graph registered as urn:default by an earlier version, WITH <urn:default> DELETE … reads and retracts the default graph reads that graph, retracts from the default graph reads and retracts the default graph
On a branch of an indexed ledger, a write to GRAPH <L:feature#config> a graph named by the text a new graph under urn:fluree:L:feature#config the config graph
JSON-LD ledger route, Fluree-Min-T: N, "from": "urn:g1" or "fromNamed": ["urn:g1"], the graph registered by commit N the graph (any urn: text read as one) on a head behind N: 400 (from), 404 (fromNamed) the graph, after the wait
SPARQL ledger route, Fluree-Min-T with FROM <urn:g1> waits on a ledger named urn:g1, which doesn't exist the same waits on the path's ledger
Proxy-storage peer, ledger route, {"from": "other:main"} 400 "Ledger mismatch" 404 GraphNotFound 400 "Ledger mismatch"

Merged with #2009

#2009 landed after the review; 893521fb1 merges it (with #2119). Both PRs grew a typed graph-name module and an answer for the ledger's own address in a graph position, so the merge keeps one of each, and aa60ba924 moves the last readers that spelled the keywords themselves onto the one table:

#2009's tests run unchanged (the one edit to its files is it_txn_meta.rs calling GraphSource::parse). Against main with #2009, the tables hold, except that a JSON-LD graph written mydb#config or a bare mydb was a 400 there (no absolute IRI). 06190d23c and d68a3e871 merge main again, conflicting only in imports (fluree-db-api's re-exports; stage.rs, where #2109's FactIdentity DELETE resolution and this branch's graph resolution sit in separate hunks).

What changes for users

Grammar

A ledger address is [urn:fluree:]name[:branch][@<tag>:<value>][#<graph>], parsed by one parser (LedgerRef::parse). Two rules keep it from swallowing graph IRIs:

  • A branch may not begin with /. http://ex.org/g used to parse as ledger http, branch //ex.org/g; it is now never a ledger id. The rule lives in LedgerId::parse, so it holds for every caller of that function, not only at the input edges. Stored records deserialize through LedgerId::parse_persisted and are unaffected, and branches that merely contain / (feature/x) still parse. (A branch whose name begins with /, creatable from v4.0.0 through v4.2.1, is not addressable; see "Persisted data".)
  • @ starts a time pin only before a known tag (t:, time:/iso:, commit:, recorded:, snapshot:). In a ledger position any other @ is a malformed pin (400); in a dataset position it means the text is not an address, so <http://ex.org/@alice/g> and mailto:a@b are graph IRIs.

A dataset-position string is classified as an address, a graph IRI, or ambiguous (lexically both, like mydb:main): scheme://… or two or more : before any #/@ is a graph IRI (a urn:fluree: address excepted); a pinned address is an address; name:branch is ambiguous; a bare name is an address. An address with a known pin tag and a bad value (mydb:main@t:abc) or with nothing after its # (mydb:main#) is a malformed address (400) in either spelling, urn:fluree: included; an IRI that is no address keeps an empty fragment (http://ex.org/ns#). An empty string is neither, and is a 400 in every dataset position ({"from": ""} included). SPARQL dataset IRIs are expanded against the prologue (prefixed names, BASE) on every route before classification. An IRI written in full is taken as written, and a prefixed name whose prefix the query does not declare (FROM ledger:main) is the address as written. Under a BASE, an address that names its branch or a time (my_db:main, mydb@t:3) is no relative IRI and is taken as written; a bare name (mydb) is one, and BASE resolves it.

One resolution table

Where a surface reads one ledger (a ledger route, a view, an update's WHERE, the CLI with a target), each reference in a dataset position resolves in that ledger, in order:

  1. The ledger's own address in any spelling (mydb, mydb:main, urn:fluree:mydb:main), with no pin and no graph: the default graph.
  2. A keyword (default or urn:default, txn-meta, config): that graph, whatever the registry holds under the text.
  3. The text as an exact registered graph IRI, reserved graphs included. A branch inherits its source's graph registrations, so the main branch's urn:fluree:mydb:main#config resolves on a branch, and a user graph may itself be named urn:fluree:….
  4. An address of this ledger with a graph (mydb:main#config, mydb#http://ex.org/g): that graph; a reserved one by its slot.
  5. Another ledger's address: 400, naming both ledgers. A graph the ledger does not have: 404 err:db/GraphNotFound. Where the surface cannot read the registry (the CLI against a remote server), text that reads both as a graph IRI and as another ledger's address is that ledger.

The connection route (POST /query, query_from()) has no target ledger, so there an address names a ledger (and its graph). A keyword, or an IRI that cannot be a ledger address (http://ex.org/g), is a 400 that says to name the ledger, instead of a nameservice lookup of the IRI as a ledger id. An IRI that can also be read as an address (urn:g1, ex:g) is still looked up as a ledger there, and is a 404 when there is none.

A FROM NAMED member is named by its IRI as written, pin included: FROM NAMED <L@t:2> answers GRAPH <L@t:2>, GRAPH ?g binds L@t:2, and two pins of one ledger are two members. The time-stripped name (GRAPH <L>) still matches while exactly one member claims it; it is not enumerated by GRAPH ?g.

Graph positions

Every graph position of a ledger reads the ledger's own address one way, for reads and writes alike: GRAPH <iri> in a query or in an update's WHERE, an update template's GRAPH <iri>, an INSERT DATA / DELETE DATA quad, a TriG block in a transaction or a bulk import, WITH, and the JSON-LD forms (top-level graph, a node's @graph, ["graph", …]). One table in fluree-db-core (TargetLedger::graph_position) answers:

The name (ledger mydb:main) reads writes
the ledger's own address, in any spelling the default graph the default graph
urn:default the default graph refused as a graph name, except WITH <urn:default> and a JSON-LD top-level "graph": "urn:default", which write the default graph
the address with a reserved keyword: mydb:main#config, mydb#txn-meta that reserved graph, at its slot (on a branch, under its source's urn:fluree: IRI) the config graph; a #txn-meta write is refused
the address with a graph IRI: mydb:main#http://ex.org/g the graph http://ex.org/g the graph http://ex.org/g
a registered graph IRI that graph that graph
any other IRI nothing a new graph by that IRI

No write registers a graph under the ledger's own address. The address with a time names no graph in these positions, and the reserved graphs keep the IRIs they are registered under. A GRAPH ?g template writes the graph its binding names in this table, which is the graph the WHERE read. GRAPH ?g lists a graph only under a name that reads it back. Every resolution is one borrowed registry lookup; only an IRI that starts with the ledger's name is parsed as an address.

What changes, on ledger mydb:main:

Shape Before Now
A template, data quad, TriG block or bulk-import block GRAPH <mydb:main> (any spelling) wrote a graph named by the text; under the canonical spelling, one a query's GRAPH ?g did not list writes the default graph
A template GRAPH <mydb:main#http://ex.org/g> (and the quad, TriG and import forms) wrote a graph named mydb:main#http://ex.org/g writes http://ex.org/g, the graph FROM <mydb:main#http://ex.org/g> reads
INSERT { GRAPH ?g {…} } USING NAMED <mydb:main> WHERE { GRAPH ?g {…} } nothing (the member did not resolve) reads and writes the default graph
A ?g bound to urn:fluree:mydb:main by an update's top-level values, then GRAPH ?g nothing, when the ledger had never stored a urn:fluree: IRI the default graph, as GRAPH <urn:fluree:mydb:main>
GRAPH <mydb:main> in an update's WHERE with no USING the graph registered under mydb:main, if any the default graph, as in a query
GRAPH <urn:fluree:mydb:main> or GRAPH <mydb> in a query (GRAPH <mydb:main> already read the default graph) the graph registered under that text, if any the default graph
GRAPH ?g over a graph registered under the address by an earlier version hidden from a query; listed as mydb:main in an update's WHERE listed as mydb:main#mydb:main by both, a name that reads it back
A write to GRAPH <mydb:main@t:1>, or to GRAPH <mydb:main#mydb:main> when no such graph exists wrote a graph named by the text 400
COPY / MOVE / ADD … TO <mydb:main> with no graph registered there created one 400: name the default graph DEFAULT
CLEAR/DROP/ADD/COPY/MOVE naming GRAPH <mydb:main#<g>> the graph named by the text the graph <g>; DROP GRAPH <mydb:main> still names the graph registered under the address, never the default graph
CREATE GRAPH <mydb:main> registered a graph named mydb:main nothing to create: the default graph exists
A write to GRAPH <mydb:main#config> or <mydb#txn-meta>, in any form wrote a graph named by the text the config graph, or a 400 for #txn-meta, as for the urn:fluree: names
JSON-LD "graph": "mydb:main" (top-level, ["graph", …] or a node's @graph) with no mydb prefix defined 400, undefined prefix under strict compact-IRI checking the default graph, as "from": "mydb:main" already read; a name that is no address of the ledger being written is still that 400

A graph an earlier version registered under the address keeps its data. It is reached as <mydb:main#mydb:main> (one under mydb:main#config as <mydb:main#mydb:main#config>) in every position above and by the graph-management verbs, which also reach it by the address alone. To move it into the default graph: ADD GRAPH <mydb:main> TO DEFAULT ; DROP GRAPH <mydb:main>. The contract is written once, in docs/concepts/datasets-and-named-graphs.md ("The ledger's own address in a graph position"), and the SPARQL and JSON-LD update pages point to it.

JSON-LD update templates take no graph variable, so the GRAPH ?g template shapes have no JSON-LD twin; every fixed-graph shape has one.

Status codes

Condition Before Now
Unknown graph in a dataset clause on the ledger routes (SPARQL and JSON-LD) or in a view's SPARQL FROM 500 404 err:db/GraphNotFound (new @type)
No dataset on the connection route 500 "Missing dataset specification" 400
A keyword, or an IRI that cannot be a ledger address, alone on the connection route 404 LedgerNotFound, or 400 invalid ledger id 400 with a hint
Malformed address (bad pin, nothing after #), in either spelling 400, or 500 400
An empty from on a ledger route ([] or "") 500 400
Another ledger on a ledger-scoped surface 400 "Ledger mismatch" 400 (unchanged; the message names both ledgers)
A pinned SPARQL FROM member on a view (one view is one snapshot) 500 400
A JSON-LD dataset on a view naming anything but the view's own ledger, whole answered from the view's head and default graph, as if absent 400 pointing at query_from()
SERVICE to a ledger that is not a dataset member silently answered from the current dataset 400; no rows under SILENT
SERVICE to a ledger the dataset holds at more than one time answered from whichever member came first 400; no rows under SILENT
A nameservice lookup that fails inside a query (a graph-source probe or lookup) the probe read as "native graph, no mapping", 200; the other lookups 400 500 err:system/NameServiceError
A write to the address with a time, L#L with no such graph, or a graph-management destination at the address wrote or created a graph named by the text 400
A well-formed ledger id that does not exist 404, text contains "not found" unchanged (pinned by test)
Multi-query statuses see "Multi-query envelopes"

Per surface

  • Ledger routes (/query/{L}, /stream/query/{L}, /explain/{L}, /query/{ledger} parses the path ledger once but authorizes, loads and compares its raw spelling #1982): the path is parsed once into the canonical id, and auth, loading and every comparison read that id. /query/urn:fluree:L:main loads, and /query/L with FROM <L:main> (or the reverse) is no longer a mismatch. Each FROM/FROM NAMED and JSON-LD from/fromNamed resolves through the table with the ledger's graph registry: an IRI containing # or @ is a graph, not ledger syntax; the short alias and the URN of the path's own ledger name it; a graph IRI in fromNamed is a graph. A single JSON-LD from, a string or a source object (by @id or id, as the parser reads it), must name the path's ledger in some spelling (L, urn:fluree:L:main), or it is a 400 "Ledger mismatch"; a from array and fromNamed may still name other ledgers, as before. The JSON-LD dataset is read where the engine's parser reads it (opts before the top level, from before ledger, fromNamed before from-named), so an opts.from naming another ledger is a 400 however the top level reads, and an opts dataset takes the lane its top-level twin takes (it used to be ignored: {"opts": {"from": "L@t:1"}} answered at head). The read check on the path's ledger runs before the body's dataset is resolved in that ledger, on every ledger route, and so does the wait for the request's Fluree-Min-T, which is the path ledger's. A proxy-storage peer resolves against the registry as well. /explain/{L} accepts the within-ledger graph IRIs /query/{L} accepts (partly: see Deviations).
  • Connection route (POST /query): the ledger a JSON-LD body's view reads, and the ledger its request is labeled and authorized by, are read with the same precedence, so {"from": "a:main", "opts": {"from": "b:main"}} runs on b:main, which the parser reads, and {"opts": {"from": "a:main"}} runs on a:main (it failed with a missing ledger).
  • graph() and db() (graph() does not accept #graph fragments or urn:fluree: ids that db() accepts #1961): graph() takes every address db() takes (L#txn-meta, L#<graph IRI>, urn:fluree:L, L@t:5). A pin in the address is honored by both; one that disagrees with graph_at's is a 400. .transact() through a graph-qualified or pinned handle is a 400, since a transaction applies to the whole ledger at head.
  • Views: a JSON-LD query on a view reads that view's ledger, whole, at the view's time. Its dataset, read as the parser reads it, may name only that: the ledger's own address, in any spelling, with nothing of its own beside it. Anything else it can say (another ledger or one that does not exist, a pin, a graph of this ledger by address, keyword or object, named graphs, a history range, or a dataset that does not parse) used to be ignored, and the query answered from the view's head and default graph. All five view entry points (buffered and tracked, with and without the graph-source providers, and the streaming planner) now refuse them with a 400 that points at query_from(), which reads them. The connection path's one-ledger shortcut and a one-ledger dataset hand the view a dataset it already holds, and are not refused. SPARQL FROM <L#config>, FROM <L#iri>, FROM <L> and keywords resolve on the view (Config Graph query doesn't work with SPARQL #1512).
  • Union default graph (# PRAGMA union-default-graph, f:queryDefaults): the union reads exactly the graphs GRAPH ?g lists, as native ledger graphs.
  • SERVICE <fluree:ledger:X>: X must be a dataset member, or, with no dataset, the query's own ledger. Anything else is a 400 that points at FROM NAMED, and contributes no rows under SILENT. An endpoint is never loaded on the spot. urn:fluree: spellings work; a pin or a graph in an endpoint is malformed. X is read at one time: a dataset holding X at two times (two pins are two members) is refused the same way, and with one time the member read is fixed (the default graph, else the first named member by name) instead of whichever a hash map yielded first.
  • Updates: USING, USING NAMED, WITH and the JSON-LD update keys from, fromNamed and graph resolve in the transaction's ledger through the same table. The ledger's own address names its default graph, in the single and the multi-USING branch alike; L#config names the config graph; a registered IRI names its graph; a graph the ledger does not have contributes nothing, so DELETE … USING <typo> WHERE … deletes nothing (it used to read the real default graph), and that includes an IRI that also reads as another ledger's address (urn:g1). An address that can only name another ledger, or a pinned address, is a 400. JSON-LD "from": "L:main" is accepted (it was an undefined-prefix error), and so is "graph": "L:main" for the ledger being written. fix: unresolvable graph references fail closed, and TriG directives apply in document order #1997's check for the ledger's own address and resolution step 0 are one predicate now (LedgerRef::is_own_address), so L#default reads the same in both. A top-level values IRI reads in the WHERE as its IRI, whichever namespace it is in. The graph positions are above.
  • Bulk import: a TriG block named by the ledger's address loads into the default graph, and L#<g> into <g>, through the same table.
  • Graph-source probes: R2rmlProvider::has_r2rml_mapping returns a Result, and a failed lookup fails the query instead of reading as an empty native graph. Graphs loaded as ledger graphs (the primary, native dataset members, and union members) are never probed, so a query over native data does not depend on the graph-source registry being reachable. A failed nameservice lookup at any graph-source site (the probe, and the mapping, table and SQL-source lookups) is a new QueryError::Nameservice, which the API and the server answer with 500 err:system/NameServiceError, the type ApiError::NameService already has: it is the backend's fault, so clients may retry it and monitoring does not count it as a bad request.
  • CLI (fluree query: a from naming the target ledger's own named graph or #txn-meta is silently ignored #1972): fluree query decides between the target's view and the connection path by resolving the dataset in the target ledger, not by comparing base names. JSON-LD bodies go through the same API function the server uses (see Public Rust API), with the parser's key precedence. A JSON-LD from naming one of the ledger's graphs (by keyword, registered IRI or address, in string or object form), its #txn-meta, or another branch now reads what it names, and one naming a missing ledger reports it missing: the body reaches the connection path with each graph of the ledger rewritten as {"@id": <ledger>, "graph": <g>}. fluree query --remote … --at posts the query as written to the pinned path (/query/{L}@t:N, available since v4.2.2): a GRAPH with no dataset clause reads the ledger's named graph at that time, a JSON-LD from naming a graph is kept (it was overwritten), and a SPARQL query with its own FROM is accepted (it was refused). A server older than v4.2.2 refuses the pinned path; on that reply only, the CLI falls back to the old rewrite (see Deviations). Locally, --at with a JSON-LD from naming a graph of the ledger is now a usage error ("--at is not supported on the connection/federated query path"); it used to read the wrong graph without a word. A local query that stays on the ledger reads the head its route was chosen on. With --remote, the CLI holds no registry, so text that reads both as a graph IRI and as another ledger's address goes to the connection path, as on main.
  • Advisories: a dataset naming only named graphs has an empty default graph (SPARQL 1.1 §13.2). QueryResult::advisories now carries a typed QueryAdvisory::EmptyDefaultGraph when the query reads that default graph, computed once from the lowered query for both languages, including patterns inside EXISTS/NOT EXISTS. The CLI prints it to stderr; rows are unchanged. The HTTP x-fdb-warning header keeps its route-level walkers for now.
  • Multi-query: see the next section.

Multi-query envelopes

An envelope resolves one t per ledger at entry. Each sub-query now runs as written, and every ledger it reads is read at the snapshot:

  • The snapshot travels as data. The dispatcher hands the per-ledger times to execution, and the connection path reads each dataset member that names no time of its own at its ledger's t, once it has parsed the dataset as it does for any query. The envelope no longer rewrites a sub-query's text or from value. A member keeps the name the query wrote it by, so GRAPH ?g over FROM NAMED <L> binds L in an envelope, as it does outside one. Every spelling reads at the snapshot: a prefix the query or the envelope's @context declares, BASE or the envelope's @base, urn:fluree:, a \u escape.
  • One reading of each sub-query's dataset drives validation, the snapshot, the distinct-ledger bound, the asOf rules and the server's min-t: a SPARQL sub-query is read from the text the dispatcher runs (its own, with the envelope's @context prefixes and @base applied), and a JSON-LD sub-query from the body it runs, its opts merged from the envelope's, the sub-query's and its own, the body's winning (effective_jsonld_body). A ledger named in fromNamed / from-named or in opts at any layer is counted, resolved at entry, listed in snapshot.ledgers and covered by min-t, as one named in from was. A member is keyed by the ledger it names, so urn:fluree:mydb and mydb:main are one ledger (a urn:fluree: SPARQL member with no asOf used to fail the envelope with a 500). A missing ledger named anywhere fails the envelope with its 404, as a missing from ledger did.
  • The outer opts may add to a sub-query's dataset, but not change a part the body names. When the body names its default graphs, its named graphs or a history end, and the envelope's or the sub-query's opts would make it read a different one, the envelope is a 400 (DatasetConflict). Outer opts that repeat the body's value (the parts are compared as written, so the same ledger in another spelling counts as a change), add named graphs the body doesn't name, or name no dataset at all (identity, policy, tracking), compose as before. A body must still name its own from.
  • Under an envelope asOf, a member that names its own time, wherever it is named, collides. The parser's reading decides: a t that is not an integer, or an at that is not a string, names no time, so that member reads at the asOf. A to anywhere is a history query, refused. A dataset the parser cannot read refuses the envelope with the parser's message. A sub-query that does not parse, in either language, reads nothing and is reported under its alias while its siblings run, as on fix(server): query routes read a request's dataset the way the engine does #2019; that includes a parse error the parser recovers from.
  • A member that names a graph rather than a ledger (a bare graph IRI or keyword) counts no ledger; the sub-query reports the connection path's 400 for it.

Public Rust API

The typed references change a few public shapes, so embedders will notice: LedgerRef's fields become private typed accessors, GraphSource's parsed fields become accessors (GraphSource::parse / TryFrom<&str> / FromStr replace new / from_str), HistoryTimeRange takes a LedgerId, R2rmlProvider::has_r2rml_mapping returns a Result, ApiError::GraphNotFound, QueryError::Nameservice and two MultiQueryValidationError variants are new on enums that aren't #[non_exhaustive], two pub multi-query snapshot functions are removed, DataSetDb gains a pub field that a struct literal needs, and Txn loses #1997's template_default_graph. TargetLedger::new takes a &dyn GraphNameTable, which closures and GraphRegistry implement. The embedder surface on the hard keep list is pinned by a compile test (the_embedder_surface_on_the_hard_keep_list_still_compiles). The full list:

Every public API change, and what's kept source-compatible

Changed:

  • fluree-db-core: new module dataset_ref with GraphIri, GraphSel, LedgerRef, DatasetRef, MemberRef, TargetLedger, TargetGraph, TargetError, GraphPosition. LedgerRef replaces the raw-string struct of the same name (pub id, at: Option<String>, fragment: Option<String>, time_spec()): its fields are private and typed (id(), at(), graph(), is_bare(), is_own_address(), with_at, with_graph, into_parts). TargetLedger resolves dataset positions (resolve, graph) and graph positions (graph_position, enumeration_name, which returns None for a graph no name reads back, names_this_ledger). GraphSel::keyword reads urn:default as default; with fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009 merged, that is a change to fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009's GraphSel::keyword, whose table is now GraphSel::bare_keyword. TimeSpec and ACCEPTED_TIME_SPEC_SPELLINGS move here from fluree-db-api, re-exported at both old paths, From<LedgerIdTimeSpec> included. LedgerId::parse refuses a branch beginning with /.
  • fluree-db-core, this round: TargetLedger::new(id, &dyn GraphNameTable) (GraphNameTable is new; GraphRegistry and any Fn(&str) -> Option<GraphId> implement it), AddressText (the address lexer), DatasetRef::is_address_with_branch_or_time. fluree-db-binary-index: HeadGraphNames. fluree-db-api: GraphNames::table, Fluree::db_with_default_context_from_handle, Fluree::db_at_with_default_context_from_handle. With the merge: GraphSel::bare_keyword; in fluree-db-transact, AddressName and a GraphName::Address variant (fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009's enum, which no release carried).
  • fluree-db-api::GraphSource keeps pub identifier: String and pub policy_override. The pub fields time_spec, source_alias and graph_selector become accessors (time_spec(), alias(), reference(), address(), written()); GraphSource::new/from_str/with_graph become GraphSource::parse/TryFrom<&str>/FromStr/GraphSource::ledger(LedgerRef). with_time, with_alias, with_policy are unchanged.
  • dataset::GraphSelector is an alias of GraphSel (Iri(String) becomes Named(GraphIri), plus Config). Its constructors default_graph(), txn_meta(), config(), iri() and from_str() are removed: use the variants (GraphSel::Default, TxnMeta, Config, Named(GraphIri::parse(..)?)) or GraphSel::parse. ledger_info::GraphSelector is a different type and is untouched.
  • DatasetSpec::from_sparql_clause(&SparqlDatasetClause) becomes from_sparql(&ResolvedDatasetClause) / from_sparql_ast(&SparqlAst). New: DatasetSpec::sources(), ledgers().
  • HistoryTimeRange { identifier: String, … } becomes { ledger: LedgerId, … }, and so does HistoryTimeRange::new.
  • New in fluree-db-api: module target_dataset, re-exported at the root, the one reader of a JSON-LD dataset in the ledger a surface targets: resolve_jsonld_dataset_in_target (rewrites the body so each source names what the target reads for it, and reports the lane), resolve_in_target, jsonld_lane, jsonld_view_ledger, jsonld_dataset_ledger, jsonld_names_dataset, InTarget, JsonLdLane, JsonLdInTarget, SingleFrom, GraphLookup; LedgerView::graph_id_for_iri (a borrowed lookup into the cached head), LedgerHandle::graph_names and GraphNames (that lookup alone), Fluree::ledger_handle (a cached handle by a parsed id); sparql_dataset_ledgers (the typed ids the connection path loads), sparql_has_dataset_clause, QueryAdvisory, QueryResult::advisories (additive), execute_formatted_with_advisories, ApiError::GraphNotFound (ApiError is not #[non_exhaustive], so an exhaustive match needs the arm), DataSetDb::named_aliases (a pub field, so a struct literal of DataSetDb needs it) and with_named_alias. Re-exported: resolve_dataset_clause, ResolvedDatasetClause.
  • fluree-db-api::query::multi:
    • Removed: snapshot::apply_snapshot_to_jsonld and snapshot::apply_snapshot_to_sparql, which are pub on main. The envelope no longer rewrites sub-queries; nothing in db or solo calls them.
    • New: MultiQueryValidationError::JsonLdDatasetUnreadable and MultiQueryValidationError::DatasetConflict (the enum is not #[non_exhaustive], so an exhaustive match needs the arms); alias_opts and effective_jsonld_body, the merge the dispatcher runs, for a host that merges the layers itself before dispatch.
    • Relative to fix(server): query routes read a request's dataset the way the engine does #2019, if it merges first: EnvelopeLedgers::sparql becomes members, every alias's members (JSON-LD aliases included), and SubqueryLedger describes a member of either language; DatasetSpec::default_graph_sources is removed (the ledger route reads a from object through dataset::source_object_id, the parser's own accessor).
    • QueryExecutionOptions gains a crate-internal field; it already had private fields, so no struct literal changes.
  • Removed: Fluree::is_single_ledger_fast_path (test-only callers).
  • fluree-db-query: R2rmlProvider::has_r2rml_mapping returns Result<bool>, so implementors must change (the three in-tree ones and the test doubles did). New variant QueryError::Nameservice(String): QueryError is not #[non_exhaustive], so an exhaustive match needs the arm. New MemberKind on GraphRef::kind (a pub field) and ContextConfig::primary_kind / ExecutionContext::primary_kind, plus ExecutionContext::graph_is_native, DataSet::service_member and DataSet::with_name_resolver (GraphNameResolver).
  • fluree-db-transact: WriteGraph, GraphTable and FlakeGenerator::set_graph_table. fix: unresolvable graph references fail closed, and TriG directives apply in document order #1997's Txn::template_default_graph, TripleTemplate::graph_from_template_default and TripleTemplate::in_template_default_graph are removed: that case is a row of the table. v4.2.4 and v5.0.0-alpha.1 carry them, so a struct literal of Txn or TripleTemplate, or a caller of in_template_default_graph, needs the change (in_graph replaces it). fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009's GraphScope::as_template_default goes with them; no release carried it.
  • fluree-vocab: errors::GRAPH_NOT_FOUND.

Kept source-compatible, and pinned by a compile test (the_embedder_surface_on_the_hard_keep_list_still_compiles): MultiQueryRequest { context, as_of, opts, queries } and MultiQuerySubquery { language, query, opts } as struct literals; the AgentJsonContext fields; fluree_db_api::dataset::GovernanceOptions; fluree_db_core::validate_branch_name; ledger_info::GraphSelector::ByIri; build_stream_dataset, build_stream_dataset_for_sparql, plan_stream_query_dataset, run_stream_query_dataset, OwnedStreamQuery, run_stream_query; fluree_db_sparql::resolve_dataset_clause and ResolvedDatasetClause { default_graphs, named_graphs, to_graph }; fluree_db_core::split_time_travel_suffix; TimeSpec::from(LedgerIdTimeSpec); DatasetSpec::from_query_json, GraphSource::identifier / policy_override, and sparql_dataset_ledger_ids.

Commits

42 commits on #2019's head, b061c5fcd; then the merge of main c5874d586 (85183e83f), 079ccf338 (the test above), the merges of main ba694ee79 (a0050eb49), 58b53238a (1fbb44a4b), ba4a982ec (6ad964919), f3c3b00ec (03e4b43ed) and 04e1a6d37 (86cd7e2c2), this round's six (43–48), the merge of main 1d06ae2ef (893521fb1), 49 and 50, the merge of main d9a1d2004 (06190d23c), 51 and 52, and the merge of main 4a0d14a1a (d68a3e871):

The commit list
  1. d53cad067 bench: dataset_http and dataset_build
  2. d589d8cd0 core: typed dataset and graph references
  3. 883df44a6 api: typed dataset members, one resolver for a target ledger
  4. d766b7e3b query/api: graph-source probes fail closed; ledger graphs are never probed
  5. 7427ebc18 api: graph() and db() take any ledger address; a view refuses another ledger's from
  6. 33e115175 query: a SERVICE endpoint names a dataset member or the query's own ledger
  7. cbb87f92a transact: an update's WHERE dataset resolves in the transaction's ledger
  8. fe94a9a50 server: the ledger routes resolve dataset references in the path's ledger
  9. 276ddf1aa cli: route a query after resolving its dataset in the target ledger
  10. 62086ae3e api: keep the dataset parsers' public shape for callers that authorize
  11. e6a844148 api/cli: typed query advisories on the result
  12. 975c26648 cli: --remote --at pins the ledger path
  13. e5a29b7d7 core: one home for the unknown-@-tag rule (an unknown @ tag in a dataset position)
  14. b2c46ecf6 test: the filed reproductions, solo's dataset shapes, and the embedder surface
  15. 73d2f4f3f docs: dataset references, SERVICE membership, update datasets, CLI --at
  16. e9130e24a api: resolve a JSON-LD dataset in the ledger a surface targets
  17. 703517ff0 api: a view answers a JSON-LD query only for its own ledger, whole
  18. b2dda77bb query/api/server: a nameservice lookup that fails inside a query is a 500
  19. f1ae4a0da api: report every dataset address as name[:branch], whatever its spelling
  20. b6f6b1a1f core/query: a malformed URN address is its own error; SERVICE reads one time
  21. 98be3ab30 core/query/transact: every graph position reads the ledger's address one way
  22. cc5743ffd docs: the ledger's own address in a graph position
  23. 2ed4afdce core/transact: the address with a reserved keyword names that reserved graph
  24. 2a521d507 transact: graph management reads L#<g> as the graph <g>
  25. 574271e90 server/api: resolve a ledger route's dataset with its path id as parsed
  26. 5ea64f7f0 api/server/cli: resolve dataset references against the head's graph names
  27. 5c43aa3b6 api: keep a dataset member's text once
  28. b2d0323cf core/query/transact: read graph positions and resolve members without copying IRIs
  29. 41528efe1 core/query/transact: read urn:default through the keyword table
  30. ab12941aa api: the union default graph reads the graphs GRAPH ?g lists, as ledger graphs
  31. 055f2c15d test: retire the exact-match alias spelling test
  32. 64f969fe6 docs: urn:default in the graph-position table, and the union's graphs
  33. b55d4ed5e server: test the ledger route's JSON-LD dataset shapes on both paths
  34. 3bb24d276 api: read a source object's id as the dataset parser does
  35. 931873eb5 transact: a top-level values cell the WHERE cannot decode carries its IRI
  36. a209d96aa test/docs: urn:default in a query dataset, on both surfaces
  37. 80df644dc server: ledger routes check read access before resolving the dataset
  38. bb4d81ab9 api/server: a multi-query envelope runs each sub-query as written, at its snapshot
  39. e58ac72bf api/server: an envelope validates a JSON-LD sub-query as the body it runs
  40. 6da68a115 api: an envelope's ledger times come from its snapshot or fail the envelope
  41. 01b105f46 multi-query: test a recovered parse error, and fromNamed in every layer
  42. 32d0c9ef9 docs/test: a ledger route reads a from string as it reads an object
  43. ba06dd75c core: one graph-name table and one address lexer
  44. d6bbda4b5 transact: a USING IRI the ledger has no graph for contributes nothing
  45. a82e3953b sparql: BASE leaves a ledger address with a branch or time as written
  46. 42c41706f api/cli: with no registry, an ambiguous reference names another ledger
  47. 7adc15fd8 server: a ledger route waits for its ledger's min-t, then reads its registry
  48. 7db0c3aab api/cli: a local query reads the head its route was chosen on
  49. aa60ba924 api/cli/transact: graph keywords and addresses through the one table
  50. ce0a70771 transact: a JSON-LD graph named by this ledger's address is that address
  51. 1040a04cb test: another ledger's address in a JSON-LD graph is the parser's undefined-prefix error
  52. 82e2b054c test: every JSON-LD graph name the address reading admits or refuses

Commits 1–28 are the posted ones, rebased onto 2941d470c and then onto #2019.

Tests

New integration tests cover each surface — the API's dataset and graph-handle suites, SERVICE, the update-dataset matrix, graph positions, graph management and bulk import, the address with a reserved keyword (L#config, L#txn-meta), the graph-source probes against real SQL sources, the server's ledger routes, multi-query envelopes, and the CLI's routing (including #1972 and #1512 reproduced from the issues verbatim) — each with its SPARQL and JSON-LD twin where the surface has both, plus unit tests for the grammar, the classifier and both resolution tables. Existing tests whose expectation changed on purpose (two of #1997's and the server's policy regression test among them) are listed in the fold, each with why.

Each new regression test was also run against its fix reverted, and every revert turned its test red, on an assertion (tests that pin behavior main already has are marked; they have nothing to revert). The full mutation log, and every new test by name, are in the comments below: they'd push this description past GitHub's size limit.

The existing tests whose expectation changed on purpose, and this round's revert runs

This round's new tests, each red with its fix reverted except address_text_splits_where_the_parser_does (it pins a refactor), are listed by name in the comment below, with every earlier round's.

Existing tests whose expectation changed on purpose this round:

  • This round: update_where_dataset_references_resolve_in_the_transactions_ledger refused USING <w-other-ledger:main>; that text is also a graph IRI the ledger lacks, so it now matches nothing, and the refusal rows name <w-other-ledger>, which can only be a ledger. remote_routing_sends_only_another_ledger_to_the_connection kept FROM NAMED <urn:x> on the remote ledger route; with no registry it now goes to /query, as on main, and the test keeps <mydb:main#urn:x> on the route.
  • With the merge of fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009: test_writes_through_the_ledger_address_name_the_default_graph matched staging's wording for another ledger's address as a JSON-LD graph ("does not define"); that name is now refused at parse with the parser's undefined-prefix error, as on main.

Earlier rounds' (#1997's two among them, the server's policy regression test, the retired alias-spelling test and the multi-query unit tests) are in the comment below, each with why.

This round's revert runs each reverted one fix, restored the file and checked it byte-for-byte: nine at 7db0c3aab (the review's items), and eight at the head on the merges' own code (the address reading of a JSON-LD graph name in four ways, the reifier anchor in two, the top-level urn:default, and the written-name keyword table). Every one turned its tests red, on an assertion; both logs are in the comment below.

The refactors (one parse per source, the shared lookup, the lexer) change no behavior, so there is no fix to revert; the existing suites cover them.

Gates

At the head, d68a3e871 (main 4a0d14a1a merged in), run locally with --all-features. fmt is clean. cargo check --workspace --all-targets is clean after each merge. Clippy -D warnings (--all-targets --no-deps) is clean over 19 crates: core, binary-index, query, sparql, transact, api, server, cli, reasoner, consensus, indexer, novelty, iceberg, r2rml, doc, graph-json-ld, graphql, vocab and shacl.

Tests pass: fluree-db-core 1,071; binary-index's lib 428; sparql 696; query's lib 1,736; transact 452; server 781; cli 485; api 5,244 of 5,245, every target, #2109's eight multi-op matrix tests included; and the W3C SPARQL suite, 36 of 36 groups. The one api failure is a span-capture lane stamp (jsonld_join_takes_batched_subject_probe_like_sparql) that fails under parallel load on main too and passes alone. With the bare-name BASE rule applied instead, the W3C suite's 12 dawg-dataset tests fail.

Not run: fluree-db-query's integration tests and binary-index's beyond its lib; the wasm32 lints and runtime smoke; the no-optional-features server check; and the benchmarks. Per commit, 44, 45, 47, 48 and 51 were not checked on their own.

Performance

The connection path gets faster, and no case regresses. On a shared dev box (cargo bench --profile dev-fast, dataset_http and dataset_build, before and after in two passes), dataset_build's query/* cases are 3.4–9.3× faster, growing with the member count (query/cross/16 1.315 → 0.157 ms), which matches what commit 4 (d766b7e3b) removed: the executor no longer asks the graph-source registry about native members. Over HTTP the connection-route cases are 18–50% faster, and the ledger-route and single-ledger stream cases sit within that box's noise.

Quiet box. On EC2 (c7i.4xlarge, fat LTO, base and head in interleaved rounds; a change counts only when the ranges don't overlap and the median moves past the bench's 5% budget): seven wins, no loss. dataset_build's 16-member query and query_r2rml cases are 91–96% faster (2.2–5.3 ms → about 190 µs), the connection-route a_conn / b_conn 45% and 80%, and the 16-member stream s5 43%. The 10,000-graph ledger route (w1) read +11–20% there, which that box's timing can't resolve; by instruction count it's flat, with nothing that grows with the registry.

Per request. Commits 25–28 resolve a route's dataset with the path's id as parsed and borrow IRIs: per w1 request, 652 allocations (base 657) and −0.6% instructions; w2 432 (472) and −31%. With the borrowed lookup, /query/big:main (20,000 graphs) with FROM + FROM NAMED is 3.56 ms CPU against base's 3.62, and the stream route 3.58 against 3.66.

This round, the CLI's route. A local fluree query that names a dataset loaded the ledger to choose its route and again to run (the CLI builds Fluree with no ledger cache); it now runs on the head it routed on. dev-fast binaries at 7adc15fd8 and 7db0c3aab, interleaved, on a 302-commit unindexed ledger (a shared box at load 13–17, medians of 15 rounds): FROM <bench:main> 31.5 → 21.1 ms, FROM NAMED <g> 34.4 → 22.1 ms, JSON-LD "from": "bench:main" 32.7 → 21.4 ms, against a no-dataset control at 20.8 → 21.6 ms; with --at, 28.8 → 19.1 ms at the head and 39.2 → 29.5 ms at t:150. Answers are byte-identical. The ledger routes' new min-t wait is an empty map without a min-t, and the refresh fast path when the head is already there; a JSON-LD source is parsed once instead of three times.

Solo

Solo itself was not built against this branch. What reaches solo's call sites:

  • Identifier form. Solo reads which ledgers a query names before running it, through DatasetSpec::from_query_json (each member's identifier, and policy_override) and sparql_dataset_ledger_ids; both keep their signatures and fields. An identifier is reported as name[:branch] whatever its spelling: an address's urn:fluree: wrapper and @ pin are removed and its #graph kept, a bare name stays bare, and anything that is not an address is reported as written. A urn:fluree: spelling used to keep its wrapper, so solo's extractor tests that pin a raw URN string need that update. sparql_dataset_ledger_ids reports every member's identifier (without #graph) and the history range's ledger, after expanding a dataset IRI against the prologue.
  • Multi-query envelopes. validate_envelope_ledgers returns each sub-query's ledgers as the envelope reads them: a SPARQL sub-query's from its text with the envelope @context applied, a JSON-LD sub-query's from its body with the envelope's and the sub-query's opts merged (effective_jsonld_body), as distinct and as members per sub-query. Solo's own envelopes name their dataset in each body's from, with no opts, and are unaffected by the new refusal.
  • Client-visible text (statuses unchanged): an asOf collision now reads "a source names its own time for ''"; a JSON-LD from object that names no source is refused with the parser's message (JsonLdDatasetUnreadable) rather than MissingFrom; {"from": ""} is a parse error, so solo's extractor answers "Could not read the query's dataset" for it before its own "requires a FROM clause" check. Solo builds no such body itself.
  • QueryError::Nameservice: a new variant, so an exhaustive match on QueryError downstream needs an arm. A nameservice failure inside a query is now a 500 where some were a 400. (Solo's ApiError matches have wildcard arms, and solo implements no R2rmlProvider.)
  • Solo's shapes, pinned by tests: config by the main URN from a branch, and user graphs named urn:fluree:…#…, on a real branch, on the view and through query_from() (a_branch_reads_config_by_the_main_urn_and_urn_named_graphs_stay_graphs); FROM NAMED <L@t:N> + GRAPH <L> through the compatible alias (pinned_from_named_members_are_named_as_written); "not found" from ledger_cached, ledger_info and refresh (a_missing_ledger_reads_as_not_found_at_every_entry_point); a non-member SERVICE endpoint refused and never loaded (a_service_endpoint_is_never_loaded); and solo's JSON-LD dataset shapes through query_from() (solo_jsonld_dataset_shapes_still_answer: {"@id": L, "t": 1, "graph": "txn-meta"}, the same with "at", a user graph, "L", "L:main", a from/to range). Solo's own extractor, run on its test inputs and a 93-case corpus, passes its own tests; against main, 16 of the 93 answers differ, each one of the changes above.
  • Three of solo's checks depend on lane consolidation and wait for the follow-up PR (part 2): a policy-scoped SPARQL FROM <L> query answering the same rows with fast paths on and off, the injected FROM <L> / FROM <L@t:N> / FROM <L:main@iso:…> spellings answering under the whole-ledger FROM convention, and the embedder stream path answering the same rows as buffered.
  • This round (against solo main 74d5404b6, and again at 1f196da7e6, whose two newer commits touch only lockfiles): solo calls none of the changed signatures and runs neither the server's ledger routes nor the CLI. What reaches it is the BASE rule, which makes an address with a branch or a time in FROM that address in sparql_dataset_ledger_ids (its cross-ledger extractor) and in resolve_dataset_clause, as the engine reads it, and the urn:default order. Solo writes config only on :main and issues no USING. The merge with fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009 doesn't reach solo either: solo uses no fluree-db-transact type, and ledger_info::GraphSelector::ByIri, which its profile op uses, is unchanged. Nothing for solo to change.
  • solo#1302 compiles against resolve_dataset_clause, ResolvedDatasetClause, split_time_travel_suffix and TimeSpec::from(LedgerIdTimeSpec); all four are unchanged (pinned by the compile test).

Overlap with #2009

#2009 fixes the class 931873eb5 belongs to at the write boundary: two of its commits, "flake generation stores every IRI under its canonical namespace code" and "an update's where reads top-level values in the ledger's encoding". #2009 landed first, so the merge (893521fb1) drops 931873eb5's code and keeps its two tests, an_update_reads_a_graph_variable_bound_to_the_ledger_address and a_top_level_values_iri_in_a_new_namespace_writes_and_reads_as_itself, which pass on #2009's mechanism. The rest of the overlap, the two graph-name modules, is under "Merged with #2009".

Persisted data

Nothing persisted changes format: no commit, index, nameservice-record, graph-registry or content-hash format changes, and stored ledger ids are read by LedgerId::parse_persisted, unchanged. What changes is where new writes land and how names resolve (a write through the ledger's own address names the default graph instead of registering a graph under the address). The code reads data written by earlier versions without a migration, except for one shape: a branch whose name begins with / (creatable from v4.0.0 through v4.2.1) is not addressable; its data is intact. Export it with v4.2.3 before upgrading (fluree export L:/branch; v4.2.3's branch drop does not remove such a branch). A graph an earlier version registered under the ledger's address is listed as L#<address> and reached by that name, and a graph named through L#config likewise. A graph registered literally as urn:default before #2005 is not listed, as on main.

Deviations from the design

  • The HTTP x-fdb-warning header is still computed by the two route-level walkers; QueryResult::advisories is not yet what renders it, and the MCP envelope does not render advisories.
  • /explain/{L} accepts within-ledger graph IRIs through the typed ids and plans on the ledger view; a dataset's explain still plans the single view.
  • ledger_info() and ledger_cached() still parse their argument with LedgerId::parse, so a urn:fluree: id is refused there ("branch cannot contain ':'"). The design moves them onto LedgerRef::parse; that waits for a follow-up PR (part 2). Their "not found" text is unchanged.
  • The CLI's fallback for older servers: the design expected an old server to refuse a pinned path with a 400 naming the @. Run against the v4.1.6 and v4.2.1 binaries, both answer a 500, "Invalid ledger ID format '@t:N': expected 'name' or 'name:branch'". The CLI falls back on an "invalid ledger id" reply that names the pinned path, at any of 400/404/500, and on nothing else.
  • NDJSON and TSV/CSV with --remote --at keep the old rewrite; they move to pinned paths in the follow-up PR (part 2).
  • A /query request still parses its dataset more than once (auth, refresh and min-t collection each read it); the design's one parse per request waits for the walkers below.
  • The multi-query server route validates the envelope as submitted, before it merges each sub-query's opts for authorization, not after: the conflict refusal needs the layers apart. Validation reads each body with its outer opts merged (effective_jsonld_body), so the route's min-t wait and refresh, which run on validation's ledgers, cover a ledger the outer opts add, and a body whose dataset they would change is refused before either. The merge the route then stores in each body is the same function's output, the body the dispatcher runs.
  • A multi-query JSON-LD body must still name its own from. A dataset named only in the envelope's or the sub-query's opts stays refused (MissingFrom), as on main.
  • Under a declared BASE, a bare ledger name in a SPARQL dataset clause (FROM <mydb>) is BASE-resolved, as SPARQL specifies and the W3C dataset tests require; main read it as written. An address with a branch or a time is still read as written.
  • The graph-source crawl's dataset parse reads no envelope times: a crawl runs only on a graph source, and an envelope resolves every member as a ledger before it dispatches.

Pre-existing, not changed here

  • A pinned FROM NAMED member sometimes fails with a 400 FormatError: every time with Accept: application/json, and about one run in three in other formats, solo's pinned FROM NAMED shapes included. It reproduces on main and on this branch alike, and is to be filed separately.

Not in this PR: lane consolidation, in a follow-up PR (part 2)

  • The whole-ledger FROM convention (docs: the "Ledger-Bound Mode" example (FROM <mydb:main> + GRAPH <g>) returns no rows #1975): a clause that is exactly one FROM naming a whole ledger selects the ledger with its named graphs.
  • Streaming onto the view lane (Streaming queries can't read named graphs under policy or at a time pin: no streaming entry point takes a prepared GraphDb #1996), with /stream/query/{L}@pin, the CLI's NDJSON --at (local and remote) and TSV/CSV --remote --at on pinned paths.
  • JSON-LD from/fromNamed on the view path resolved as within-ledger datasets (this PR refuses them there).
  • The HTTP advisory header and the MCP envelope rendering QueryResult::advisories.
  • The remaining string classifiers the design lists, each still a reader of dataset text of its own. The known divergences from the parser, read from the code:
    • The single-query routes' refresh and min-t collection (refreshable_ledger_id, refreshable_ledger_id_and_t, collect_refreshable_jsonld_ledgers, collect_jsonld_min_t_requirements, and collect_sparql_min_t_requirements with iri_to_string): they skip any text that starts with urn: or contains ://, read JSON-LD from / fromNamed at the top level only (not opts, not ledger), and do not expand a SPARQL prefixed name. A ledger named in any of those ways is not refreshed before the query, and its @t: pin sets no min-t requirement. (The multi-query route reads its sub-queries' members from validation instead.)
    • The route-level walkers: needs_default_graph_injection reads only the top-level from / fromNamed / from-named, jsonld_dataset_semantics_warning_headers likewise, and the SPARQL twin of the warning does not look inside EXISTS. So the x-fdb-warning header can differ from QueryResult::advisories, which reads the lowered query.
    • pin_jsonld_dataset (a pinned ledger path) walks every dataset key, top level and opts alike, where the parser reads one of each pair.
    • MCP's load_address renders a parsed address back to text for the loader to parse again. It round-trips; no divergence is known.

@aaj3f aaj3f added bug Something isn't working as expected area:sparql SPARQL/Turtle/TriG/JSON-LD parsing, lowering, UPDATE semantics, W3C conformance area:query Query execution, planning, fast paths, overlay, result formatting labels Oct 1, 2026
@aaj3f

aaj3f commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Full mutation log for this PR's non-vacuity runs, moved out of the description to keep it under GitHub's size limit. Each new regression test was run against its fix reverted (the file text saved, mutated, the named test run, the text restored, and the tree checked clean after each). Every mutation below turned its test red.

Earlier rounds ran on the commits as they were then, before the rebase onto 61b836e9a; the tests they name still exist, except where noted.

api: typed dataset members (ac7394c)

  • names (member name = time-stripped id) -> it_query_dataset::pinned_from_named_members_are_named_as_written FAILED; restored.
  • graph-iri (connection GraphIri -> 404 NotFound) -> it_query_dataset::a_connection_query_refuses_a_bare_graph_iri FAILED; restored.
  • expand (prefixed dataset IRI not expanded) -> it_query_dataset::connection_dataset_iris_expand_against_the_prologue FAILED; restored.
  • alias-text-compare (own address compared as text, both sites) -> sparql_within_ledger_from_accepts_every_spelling_of_the_ledger + ..._names_a_graph_through_the_address FAILED; restored.
    (a first attempt at step 0 alone stayed green: step 2 also compares typed ids)
  • drop-step-0 (resolution step 0 removed) -> core dataset_ref::tests::the_targets_own_address_is_its_default_graph FAILED; restored.
  • graph-not-found-400 (unknown graph mapped to 400) -> it_query_dataset::sparql_within_ledger_from_rejections_are_typed FAILED; restored.

query/api: graph-source probes fail closed (3591cb4)

Test: it_sql_pushdown_lane::graph_source_probes_fail_closed_and_skip_ledger_graphs.

  • fail-open (provider maps lookup error to "no mapping") -> RED: lane off GRAPH gave Ok(0 rows), SPARQL and JSON-LD.
  • kinds-unclassified (views never classify) -> RED: every native shape errors with the injected lookup failure, both lanes.
  • runner-probes-members (executor probes native dataset members) -> RED: FROM , FROM NAMED + GRAPH, COUNT over member.
  • runner-probes-primary (executor probes a native primary) -> RED: own view, COUNT over own id.
  • graph-op-probes-natives (GRAPH operator probes native members) -> RED: FROM NAMED + GRAPH, COUNT (both lanes).
  • fused-probes-natives (fused aggregate probes native graphs) -> RED: lane on COUNT over member and own id.
  • lane-probes-natives (SQL lane asks about native members) -> RED: lane on FROM NAMED + GRAPH and COUNT.

api: graph() and db() take any ledger address; view refuses another ledger's from (9dde79a)

  • graph-selector-dropped (handle loads the ledger, drops its #graph) -> RED: graph(L#audit) descs [] vs ["login"].
  • graph-qualified-writes (graph-qualified handle transacts) -> RED: "transact through L#audit must be refused".
  • address-pin-ignored (L@t:1 read at head) -> RED: [Alice, Bob] vs [Alice].
  • view-check-off (view ignores a cross-ledger from) -> RED: all four entry points answered (query, graph().query(), view tracked, graph() tracked). (That test is now a_view_refuses_a_jsonld_dataset_beyond_its_own_ledger; its per-site mutations are in this round's section.)

query: SERVICE endpoint names a dataset member or the query's own ledger (6597d79)

  • self-fallback (non-member runs against the current dataset) -> RED: "a non-member endpoint is not the current dataset" (answered).
  • silent-errors (SILENT no longer swallows a non-member) -> RED: SILENT query failed.
  • endpoint-not-bare (pins/graphs accepted in an endpoint) -> RED: "an endpoint with a pin or a graph is malformed" (answered).

transact: an update's WHERE dataset resolves in the transaction's ledger (1e6c466)

  • unknown-reads-default (an unknown graph reads the default graph: GraphNotFound -> g_id 0) -> RED: the unregistered-graph cases (one USING, two, and a JSON-LD from) delete the default graph; the WITH <new> twins copy into newg.
  • union-drops-own-address (the own address dropped from the union) -> RED: the own-address cases (USING <L:main>, <L>, <urn:fluree:L:main>, and <L:main> beside <g1>) and their JSON-LD twins read nothing.
  • from-strict (JSON-LD from expands strictly) -> RED: "Unresolved compact IRI" for from L:main, L#config, pinned, other ledger.
  • cross-ledger-empty (another ledger reads as an unknown graph) -> RED: SPARQL/JSON-LD "another ledger" and USING NAMED another ledger answer Ok.

server: the ledger routes resolve dataset references in the path's ledger (9e486b6)

  • path-spelling (/query/{ledger} parses the path ledger once but authorizes, loads and compares its raw spelling #1982: the path's spelling drives loading) -> RED: /query/urn:fluree:… is a 400 invalid ledger id.
  • from-named-unresolved (fromNamed not resolved) -> RED: a graph IRI in fromNamed is a 400 "graph IRI, not a ledger".
  • registry-ignored (Ambiguous other-ledger read as a graph) -> RED: FROM other-ledger:main is a 404 instead of the 400 mismatch.
  • graph-not-found-500 (server mapping reverted) -> RED: unknown graph is a 500.

cli: route a query after resolving its dataset in the target ledger (6c72522)

  • local-ambiguous-stays (a reference that also reads as another branch stays on the view) -> RED: SPARQL FROM routedb:feature-x fails on the view.
  • jsonld-graph-stays (a JSON-LD graph of the ledger stays on the view) -> RED: from routedb:main#g1 answers "in-default".

api: keep the dataset parsers' public shape (6b1a876)

  • ids-skip-named (sparql_dataset_ledger_ids leaves out named graphs) -> RED: completeness check, SPARQL FROM NAMED rep-h:main read but unreported.
  • identifier-blank (identifier loses the ledger) -> RED: completeness check, every JSON-LD shape reads a ledger reported as "".

api/cli: typed query advisories (cb9cd66)

Test: it_query_dataset::a_named_only_dataset_advises_when_the_query_reads_its_empty_default_graph.

  • walker-skips-exists (the walker does not look into FILTER / BIND expressions) -> RED: FILTER(EXISTS {…} || false) gave [] vs [EmptyDefaultGraph].
  • walker-skips-exists-pattern (the walker skips Pattern::Exists) -> RED: FILTER EXISTS {…} gave [] vs [EmptyDefaultGraph].
  • never-advise (no advisory is ever raised) -> RED: [] vs [EmptyDefaultGraph].
    (a first single mutation stayed green: FILTER EXISTS lowers to Pattern::Exists; both are covered now)

cli: --remote --at pins the ledger path (0f512cd)

  • pins-off (never pin the path; always the older rewrite) -> RED: server_memory remote_at_pins_the_path_and_keeps_the_querys_dataset, GRAPH with no dataset clause at t=1 answered no rows.
  • fallback-never (an old server's refusal is final) -> RED: server_memory remote_at_falls_back_on_a_server_without_path_pins, the CLI surfaced the stand-in's 500 "Invalid ledger ID format 'pin:main@t:1'".
  • fallback-ignores-500 (fallback reads only 400/404, as first designed) -> RED: same test, same 500 surfaced.
  • fallback-on-any-error (every refusal falls back) -> RED: unit only_a_server_without_path_pins_falls_back, "Invalid ledger id 'other:main@t:5'" fell back.

test: the filed reproductions (92b8d2f)

  • jsonld-graph-stays (router keeps a JSON-LD graph of the ledger on the view) -> RED: integration issue_1972_reproduction_reads_the_graph_each_from_names, stdout lacked "in-g".
  • within-ledger-reads-default (the view's within-ledger FROM reads the default graph whatever it names) -> RED: integration issue_1512_sparql_from_reads_the_config_graph, stdout lacked "cfg-value".

core: typed dataset and graph references (d07f13c): no branch begins with /

  • slash-rule-off (a branch may begin with '/') -> RED: it_sql_pushdown_lane graph_source_probes_fail_closed_and_skip_ledger_graphs, a GRAPH IRI that is no graph-source id was looked up (lane on and off) and failed with the injected lookup error.

This round, on the current head

Each file restored from its saved text, and the tree checked clean after the run. Where one mutation names tests in several binaries, all of them ran (--no-fail-fast) and each went red. (Four were re-run with it after a first pass stopped at the first red binary.)

api: resolve a JSON-LD dataset in the ledger a surface targets (acfbaeb)

  • key-precedence-top-first (the dataset keys are read at the top level before opts) -> RED: target_dataset the_lane_follows_the_parsers_key_precedence ({"from": "books:main", "opts": {"from": "books:main@t:1"}} on the view lane), server the_dataset_is_read_where_the_parser_reads_it (an opts.from naming another ledger accepted), CLI local_routing_hands_the_connection_the_resolved_body (a pinned opts.from kept on the view).
  • graph-not-rewritten (a graph of the target stays as written) -> RED: sources_resolve_in_the_target and the CLI routing test ("config" reached the connection path as written).
  • cli-original-body (the local router sends the body as written, not as its ledger resolved it) -> RED: the CLI routing test.

api: a view answers a JSON-LD query only for its own ledger, whole (b318ab3)
Test: it_query_dataset a_view_refuses_a_jsonld_dataset_beyond_its_own_ledger; each entry point's check was switched off on its own.

  • view-site-0-off (buffered, no graph-source providers) -> RED: fluree.query(&view, …) answered from: "o4-orgs:main".
  • view-site-1-off (buffered, with the providers) -> RED: graph().query().execute() answered it.
  • view-site-2-off (tracked, no providers) -> RED: view.query(&fluree).execute_tracked() answered it.
  • view-site-3-off (tracked, with the providers) -> RED: graph().query().execute_tracked() answered it.
  • view-stream-off (the streaming planner) -> RED: plan_stream_query planned it.
  • view-accepts-pinned-own (the view's own ledger with a pin counts as the whole ledger) -> RED: from: "o4-people:main@t:1" answered at every entry point.
  • flag-never-set (the connection path's one-ledger view is never marked as holding the query's dataset) -> RED: solo_jsonld_dataset_shapes_still_answer, {"@id": "so7:main", "t": 1, "graph": "txn-meta"} through query_from() refused by the view's check.

query/api/server: a nameservice lookup that fails inside a query is a 500 (eb1d928)

  • ns-400-api (the API maps QueryError::Nameservice to 400) -> RED: api a_failed_nameservice_lookup_in_a_query_is_500, and it_sql_pushdown_lane graph_source_probes_fail_closed_and_skip_ledger_graphs and a_failed_source_lookup_still_fails_the_query (400 vs 500).
  • probe-internal (the R2RML provider's probe reports a failed lookup as QueryError::Internal again) -> RED: both it_sql_pushdown_lane tests (lane off: the injected failure answered as a 400).
  • ns-server-type-arm-off (the server's @type arm for it removed) -> RED: server a_failed_nameservice_lookup_in_a_query_is_a_500, err:db/InvalidQuery vs err:system/NameServiceError.
  • ns-server-status-arm-off (its status arm removed) -> RED: the same test, 400 vs 500.

api: report every dataset address as name[:branch] (a17fbfd)

  • urn-kept (an address is reported with its urn:fluree: wrapper) -> RED: dataset from_query_json_reports_every_named_ledger ({"from": "urn:fluree:g:main"} reported as written) and sparql_dataset_ledger_ids_reports_every_named_ledger, and it_query_dataset reported_dataset_ledgers_cover_every_ledger_the_engine_reads (the report, read as a consumer reads it, no longer covers the ledgers read; last round's version of that test stayed green under this mutation).

core/query: a malformed URN address is its own error; SERVICE reads one time (8b4dd84)

  • urn-pin-arm-off (the urn:fluree: branch reads a bad pin or a missing graph as an IRI) -> RED: dataset_ref a_known_tag_with_a_bad_value_is_an_error (urn:fluree:mydb:main@t:abc parsed as a graph IRI) and an_address_missing_its_graph_is_an_error (urn:fluree:dsx:main# likewise).
  • lacks-graph-off (an address with nothing after # is an IRI) -> RED: an_address_missing_its_graph_is_an_error (dsx:main# parsed as a graph IRI).
  • service-no-ambiguity (a ledger held at two times is not refused) -> RED: it_service_cross_ledger_iri a_service_to_a_ledger_held_at_two_times_is_refused, the query answered instead of the 400.
  • service-order-max (the named member is picked last by name instead of first) -> RED: the same test, run 0 read the #txn-meta member, [] vs [b1, b2].

core/query/transact: every graph position reads the ledger's address one way (23450ec)
Tests: it_named_graphs test_writes_through_the_ledger_address_name_the_default_graph (writes), test_updates_on_a_graph_registered_under_the_ledger_address (legacy graph), test_query_and_update_list_the_address_graph_under_one_name (list); it_import import_trig_blocks_named_by_the_ledger_address.

  • wg-address-is-a-graph (a write to the ledger's address goes to a graph named by it) -> RED: writes (the address quads left the default graph: [] vs [default, urn default]) and legacy graph (every GRAPH <ADDR>, WITH <ADDR> and JSON-LD address case deleted "same" from the legacy graph and left the default graph).
  • wg-hash-graph-whole (core: L#<g> in a graph position is a graph named by the whole text) -> RED: writes, FROM <gp:main#http://example.org/g2> found no graph g2.
  • var-graph-raw (a GRAPH ?g binding writes the graph its text names, bypassing the table) -> RED: all three. The writes test's USING NAMED <gp:main> copy left the default graph ([] vs [in default]); the legacy-graph test deleted nothing from the legacy graph through GRAPH ?g and registered L#L as a new graph, and its USING NAMED <ADDR> case deleted "same" from the legacy graph (the DELETE reproduction from Claude's review); the list test's markers missed the graph the WHERE read.
  • enum-raw-update (an update's GRAPH ?g lists a graph by its registered IRI) -> RED: legacy graph (GRAPH ?g read the legacy graph and deleted "same" from the default graph) and list (the "listed" marker went to the default graph).
  • enum-raw-query (a query's GRAPH ?g lists it by its registered IRI) -> RED: list, GRAPH ?g bound legacy-list:dev vs legacy-list:dev#legacy-list:dev.
  • query-graph-position-off (a single-ledger query's GRAPH <iri> bypasses the table) -> RED: list, GRAPH <L#L> read [] vs [legacy only, same].
  • ambient-resolver-off (an update's WHERE with no USING reads GRAPH <iri> by dataset key only) -> RED: legacy graph, GRAPH <urn:fluree:…> in SPARQL and JSON-LD read nothing. (The canonical spelling still matched the default graph's key, so only the urn:fluree: cases failed.)
  • mgmt-guard-off (graph management may create a graph at the address) -> RED: writes, COPY DEFAULT TO <gp:main> committed.
  • strict-check-off (a graph name kept as written is not checked against the ledger) -> RED: writes, a node @graph: "exx:g" committed. (A first pass went red only through another check, on the top-level graph; the node case, which only this check refuses, was added and runs first.)
  • import-block-raw (a bulk-import TriG block goes to the graph its text names) -> RED: import_trig_blocks_named_by_the_ledger_address, the address blocks missing from the default graph.

core/transact: the address with a reserved keyword names that reserved graph (c2adf42)

  • position-reads-keyword-as-iri (a graph position reads L#config as a plain IRI again) -> RED: the core, writes (config graph empty after six writes), server and CLI tests.
  • resolve-step0-default-only (a dataset position checks the registry before the keyword reading) -> RED: the core test, and FROM <rkl:dev#config> read the graph registered under the literal text.
  • graph-mgmt-keeps-literal (graph management keeps the literal text) -> RED: the writes test, ADD DEFAULT TO <rk:main#config> refused as an address, not as a reserved graph.

transact: graph management reads L#<g> as the graph <g> (206071c)

  • graph-mgmt-hash-as-written (the verbs keep L#<g> as written) -> RED: the core assertions, and test_graph_management_reads_a_graph_named_through_the_address, ADD GRAPH <rkm:dev#rkm:dev#config> TO DEFAULT: source graph does not exist.
  • graph-mgmt-dest-as-written, graph-mgmt-clear-as-written (one arm each) -> RED: the same test, a COPY to an L#<g> destination refused as an address; DROP GRAPH <rkm:dev#rkm:dev#config> left its data.

The four allocation fixes (aa75eb9..ed58916)

  • own-id-fast-path-not-own, own-id-guard-off (the shortcut misreads the target's id, or takes a stored id with @) -> RED: the_targets_own_id_reads_as_its_other_spellings.
  • member-text-twice (every member keeps its text apart) -> RED: a_member_keeps_its_text_once_unless_it_differs_from_its_identifier.
  • position-copies-iri, resolve-copies-member-iri, graph-copies-iri (each copy restored) -> RED: graph_positions_and_resolved_graphs_copy_no_iri.

aaj3f added 10 commits October 12, 2026 10:51
Two benches for the request shapes whose dataset references are parsed,
classified and resolved per request, so the typed-reference work that
follows has before numbers to compare against.

fluree-db-server dataset_http: warm in-process HTTP requests with SPARQL
FROM / FROM NAMED, JSON-LD from, and GRAPH scopes on /query and
/query/{ledger}, a bearer-token request, a query with a 2 KB VALUES block,
and three streaming requests on /stream/query/{ledger} (10k default-graph
rows with and without a policy input, and 16 FROM NAMED members under a
policy input). Each case checks its row count once before timing.

fluree-db-api dataset_build: build_dataset_view and FROM NAMED x 1/4/16
through query_from() on a file-backed connection, for members that are
graphs of one ledger and for members that are separate ledgers, plus the
same query with the graph-source providers attached (iceberg feature).
A ledger, a time, a graph of a ledger and a bare graph IRI are all written
as text, and each surface split that text itself: at HEAD there are seven
parsers of the address grammar, and they disagree about '#', '@' and
'urn:fluree:'. This adds the one typed form they can all share, in a new
fluree-db-core module, dataset_ref:

- GraphIri: an absolute IRI (validate_absolute_graph_iri), the only way to
  name a graph by IRI.
- GraphSel { Default, TxnMeta, Config, Named(GraphIri) }: which graph of one
  ledger. The one keyword table for 'default' / 'txn-meta' / 'config'. A
  relative name is refused instead of being looked up literally.
- LedgerRef { id, at: Option<TimeSpec>, graph: GraphSel }, private fields:
  the parsed address for ledger positions. Replaces the raw-string struct
  of the same name (its pin was a String and its fragment unvalidated).
- DatasetRef { Address | GraphIri | Ambiguous }: what a dataset-position
  string (FROM, FROM NAMED, a JSON-LD from string) names before resolution.
  Ambiguous carries both readings of text that is lexically both, such as
  'mydb:main', for a resolver that holds a graph registry to choose.
- TimeSpec moves here from fluree-db-api (re-exported at both of its old
  paths, with From<LedgerIdTimeSpec>), together with its grammar tests.

Two grammar rules keep the address grammar from swallowing graph IRIs:

- A branch may not begin with '/': LedgerId::parse refuses one, so
  'http://ex.org/g' is no longer read as ledger 'http', branch
  '//ex.org/g'. Legacy branches that merely contain '/' still parse, and
  stored records keep parse_persisted.
- '@' starts a pin only before a known tag. In a ledger position any
  other '@' is a bad pin; in a dataset position it means the text is not an
  address ('http://ex.org/@alice/g', 'mailto:a@b').

With the first rule a hierarchical graph IRI no longer parses as an id, so the SQL and
Delta dispatch probes, which receive the GRAPH IRIs a query writes, now
classify the IRI first: one that does not parse as a graph-source id names
no source and is declined without a lookup, while a failed lookup of a
well-formed id still fails the query: the same guard #1997 added
(dispatch_record).

The existing LedgerRef callers (server path parsing, scope_id, the MCP
ledger argument, the graph-source fallback, same_ledger) move to the typed
accessors.
A dataset member was a GraphSource with an `identifier: String` that every
consumer re-read: a SPARQL FROM IRI went through its own stringifier
(prefixed names unexpanded), then a third address parser that split '@' and
'#' textually, and a graph IRI on a connection route was looked up in the
nameservice as a ledger. Members are now parsed once into typed values and
resolved by one table.

- GraphSource keeps the text as written, what it names (MemberRef: a graph
  keyword, or a DatasetRef), its time and its per-source options, behind
  private fields. It is built by parsing (GraphSource::parse, TryFrom,
  FromStr) or from a typed address (GraphSource::ledger); `identifier` is
  gone. dataset::GraphSelector is now an alias of core's GraphSel.
- One JSON-LD dataset parser: DatasetSpec::from_json reads the `opts` and
  `ledger` spellings that only from_query_json used to. An object's `@id`
  is a ledger address and its `graph` a graph of that ledger; naming a
  graph in both is refused.
- SPARQL dataset clauses are read from resolve_dataset_clause, so prefixed
  and BASE-relative FROM / FROM NAMED IRIs expand against the prologue on
  every route (DatasetSpec::from_sparql / from_sparql_ast). A dataset IRI
  written in full is taken as written: FROM <mydb:main> is not a misused
  prefix even when the query declares `mydb:`.
- core gains MemberRef and TargetLedger, the resolution table for a
  ledger-scoped surface: the ledger's own address in any spelling is its
  default graph; the written text as an exact registry IRI (reserved slots
  included) is that graph; a keyword or `L#graph` selects within; another
  ledger is CrossLedger; an unknown graph IRI is GraphNotFound. The view
  path's within-ledger FROM and every graph selection (`db("L#g")`, a
  member's graph) resolve through it, so the short alias `FROM <L>`,
  `FROM <L#iri>`, `FROM <L#config>`, a keyword, and the main branch's
  `urn:fluree:L:main#config` read from a branch all work there (#1512).
- On a connection surface a bare graph IRI or keyword names no ledger: a
  400 that names the fix, instead of a nameservice lookup of the IRI.
- A named member is known by its alias, else its text as written, pin
  included: `FROM NAMED <L@t:2>` answers `GRAPH <L@t:2>` and two pins of
  one ledger are two members. The time-stripped name it had before stays a
  non-enumerated alias while exactly one member claims it, so
  `GRAPH <L>` over one pinned member still matches (DataSetDb gains the
  alias map).
- Caller mistakes in this area are no longer 500s: an unknown graph is a
  404 (new ApiError::GraphNotFound, which is not is_not_found(), so it
  never falls back to a graph-source lookup); a missing dataset, a
  cross-ledger or pinned within-ledger member, and the within-ledger
  history-range refusal are 400s. An unknown pin tag in a dataset position
  reports the pin, not "not an IRI".
- sparql_dataset_ledger_ids returns the canonical ids a clause names by
  address (graph IRIs are not ledgers), and the CLI's "already has a
  dataset clause" guards use the new sparql_has_dataset_clause.
- Fluree::is_single_ledger_fast_path (test-only callers) is removed.

The ledger route keeps its own FROM classifier for now and only moves to
the typed constructors; routing it through TargetLedger follows.
…robed

`R2rmlProvider::has_r2rml_mapping` returned `bool`, and the api's provider
turned every nameservice error into "no mapping"; the GRAPH operator and the
fused R2RML aggregate also `.ok()`-ed `compiled_mapping`. During a
nameservice outage a GRAPH-addressed R2RML, Iceberg or SQL source therefore
read as an empty native graph, with a 200. The probe now returns
`QueryResult<bool>`. An IRI that is no graph-source id is still `Ok(false)`
without a lookup; a lookup that fails fails the query, and so does a failed
mapping load for a graph found to be a source.

Failing closed alone would have made every query that carries the R2RML
provider (every `query_from()` and `graph().query()` on an iceberg build)
depend on the graph-source registry, because the executor probed the primary
snapshot and each dataset member on every query. Views now say what they
read: a `MemberKind` (`Native`, `GraphSource`, or `Unclassified` for callers
that do not say) on each runtime `GraphRef`, and on `ContextConfig` for the
no-dataset primary. The executor's precomputed set, the GRAPH operator, the
fused aggregate and the SQL lane never ask about a graph loaded as a ledger
graph. Graph-source members are probed as before, and a GRAPH IRI that is
not a member is the one remaining run-time probe.

A probe failure surfaces as the provider's existing "Nameservice error"
(`QueryError::Internal`, which the api maps to 400 like the provider's other
nameservice errors).

Test: it_sql_pushdown_lane `graph_source_probes_fail_closed_and_skip_ledger_graphs`
runs against real SQL sources with every graph-source lookup failing:
`GRAPH <source>` errors on and off the lane, in SPARQL and JSON-LD; the
native twin answers exactly as with a healthy nameservice through its own
view, `FROM`, and `FROM NAMED` + `GRAPH`; a GRAPH IRI that is no id answers
without a lookup.
… ledger's from

`graph()` stored the raw string and handed it to the ledger loader, which
takes only `name[:branch]`, so `graph("L#txn-meta")`, `graph("L#<graph IRI>")`
and `graph("urn:fluree:L")` failed although `db()` accepted them (#1961).
The handle now parses a `LedgerRef` once. Queries and `load()` read the
address's graph through the loader `db()` uses. A pin in the address
(`L@t:5`) is honored, and one that disagrees with `graph_at`'s is a 400;
`db()` honors a pin the same way. A transaction applies to the whole ledger
at HEAD, so `.transact()` through a graph-qualified or pinned handle is
refused with a 400. The commit builder reads the address's ledger.

A JSON-LD query on a view reads the view's ledger, but a `from` or
`fromNamed` naming another ledger, or one that does not exist, was ignored
and the query silently answered from the view. All four view entry points
refuse it now with a 400 that points at `query_from()`. A `from` naming the
view's own ledger, in any spelling, still answers. The other within-ledger
JSON-LD `from` shapes keep their current reading; honoring them on the view
path belongs to lane consolidation (part 2).

The tracked view paths report the within-ledger FROM resolver's own status
(404 for a graph the ledger lacks), as the untracked paths already do.

Tests: it_named_graphs `graph_handles_take_the_addresses_db_takes` and
`a_missing_ledger_reads_as_not_found_at_every_entry_point`; it_query_dataset
`a_view_refuses_a_jsonld_from_naming_another_ledger`.
…edger

`SERVICE <fluree:ledger:X>` looked X up among the dataset's members and,
when X was not one, ran the block against the current dataset. An endpoint
naming another ledger, or no ledger at all, therefore answered with this
dataset's rows. A non-member endpoint is now a 400 that points at
FROM NAMED, and it contributes no rows under SILENT. It is never loaded on
the spot, because a SERVICE endpoint is not authorized the way a dataset
member is. With no dataset, the endpoint must still name the query's own
ledger, as before.

The endpoint's address is parsed with the shared ledger grammar, so the
`urn:fluree:` spelling works. A pin or a graph in it is malformed: the
member's time and graphs come from the dataset.

Tests: service unit tests for the endpoint grammar; it_service_cross_ledger_iri
`service_to_a_non_member_is_refused_not_answered_by_the_dataset` and
`a_service_endpoint_is_never_loaded` (a recording nameservice sees no lookup
of the endpoint's ledger).
A single `USING <g>` or `WITH <g>`, or a JSON-LD update `from` / `graph`,
that the graph registry did not resolve fell back to g_id 0, so the WHERE
read the ledger's real default graph. `DELETE { ?s ex:v ?o } USING <typo>
WHERE { ?s ex:v ?o }` deleted it, `WITH <new> INSERT … WHERE …` copied it,
and `USING <L#config>` read the default graph instead of the config graph.
Two or more `USING` graphs skipped an unresolved IRI, which dropped
the ledger's own address. JSON-LD refused `"from": "L:main"` as an
undefined prefix.

Every WHERE-dataset reference (`USING`, `USING NAMED`, `WITH`, and the
JSON-LD `from`, `fromNamed` and `graph` keys) now resolves once, in the
transaction's ledger, through the table a query's FROM uses:
- the ledger's own address, in any spelling, names its default graph;
- `L#config` or its URN names the config graph;
- a registered IRI names its graph.
A graph the ledger does not have contributes nothing, so a WHERE over it
binds nothing (SPARQL 1.1 Update §3.1.3, Query §13.2). Another ledger's
address, or a pinned address, is a 400, since the WHERE reads only this
ledger as it stands. The single and multi branches share the resolver. The
JSON-LD dataset keys are dataset references: a prefix the context defines
still expands, and any other text is kept as written for the resolver.

rule (own address, else registry, else empty). This is its generalization;
the rebase onto #1997 keeps this side.

Test: it_named_graphs
`update_where_dataset_references_resolve_in_the_transactions_ledger`, each
shape above in SPARQL and JSON-LD, with the cross-ledger and pinned
refusals.
…dger

The ledger routes (`/query/{L}`, `/stream/query/{L}`, `/explain/{L}`) loaded,
authorized and compared the path as spelled, so `/query/b2x` with
`FROM <b2x:main>` or `"from": "b2x:main"` was a ledger mismatch, and
`/query/urn:fluree:b2x:main` could not load at all (#1982). `PathLedger` now
carries the canonical id (plus any graph the path selects), and every
downstream use reads it.

Each SPARQL `FROM` / `FROM NAMED` IRI, and each JSON-LD `from` / `fromNamed`
source, was classified by string shape: an IRI with `#` or `@` was taken for
ledger syntax ("Ledger mismatch" for `<http://ex.org/vocab#products>`,
"Invalid time travel" for `<http://ex.org/@alice/g>`), the short
alias or the URN of the path's own ledger read as a graph name (500 Unknown
named graph), and a graph IRI in `fromNamed` was loaded as a
ledger (404). The clause is now expanded against the prologue first
(prefixed and BASE-relative IRIs), and each reference resolves once, in
the path's ledger, through the table the view path and updates use, with the
ledger's graph registry:
- the ledger's own address in any spelling names it, or the graph the
  address names;
- a keyword or a registered IRI names that graph;
- an IRI the registry does not hold is left to loading, which answers 404
  `err:db/GraphNotFound`;
- another ledger is a 400.
A single JSON-LD `from` must name the path's ledger. A `from` array and
`fromNamed` may also name other ledgers, as before. The dataset lane and its
per-member loading are unchanged.

`ApiError::GraphNotFound` now maps to 404 with the new `@type`
`err:db/GraphNotFound` on the server (it fell through to a 500).

Tests: sparql_dataset_semantics
`ledger_route_dataset_references_resolve_in_the_paths_ledger` (graph IRIs
with `#` and `@`, the config graph by its URN, each spelling of the path and
of the ledger in `FROM` and `from`, a prefixed `FROM NAMED`, a graph IRI in
`fromNamed`, an unknown graph, another ledger in each language); unit tests for the path id and the JSON-LD
normalization.
`fluree query` chose between the target's own view and the connection path
by comparing base names (`mydb:feature-x` and `mydb` share `mydb`) and by
reading only a string or string-array JSON-LD `from` (#1972). A branch other
than the target's ran against the target's branch; a JSON-LD `from` naming
one of the ledger's graphs, in string or object form, or naming a ledger
that does not exist, ran on the view path, which ignored it and answered
from the default graph; SPARQL `FROM` of another branch failed there.

The router now resolves each reference in the target ledger through the
table every surface shares, using the ledger's graph registry when it is
local. Locally:
- the view path keeps what it reads: its own ledger in any spelling, and
  SPARQL graphs of that ledger;
- another ledger or branch, a time pin, and every JSON-LD source other than
  the whole ledger (a graph, `fromNamed`, a history `to`) take the connection
  path, which reads them.
For a remote target, the ledger route resolves references against its own
registry, so only a reference that names another ledger leaves it. The base
name comparison and the `from` scraper are gone.

Tests: unit routing decisions for the local and remote rules; CLI
integration `local_query_reads_the_graph_or_branch_its_dataset_names`
(graph by address and object form, config graph, another branch in JSON-LD
and SPARQL, a missing ledger).
Callers outside db read which ledgers a query names before running it,
through `DatasetSpec::from_query_json` (each member's `identifier` and
`policy_override`) and `sparql_dataset_ledger_ids`, so these two must report
every ledger the query can read. The typed members had made `identifier` and
`policy_override` private and changed what `sparql_dataset_ledger_ids`
reported.

Both fields are public again. `identifier` is the reference as the query
named it, with an address's `@` pin removed and a `#graph` kept, as before.
Both are derived from the typed parse, and resolution reads the typed
reference, never them. `sparql_dataset_ledger_ids` reports every member's
identifier (minus `#graph`) and the history range's ledger, as before. A
reference whose reading depends on a ledger's graph registry is reported
too.
The typed ids the connection path loads are the new `sparql_dataset_ledgers`,
which the server's own authorization, refresh and comparisons now use.

A dataset clause's prefixed name whose prefix is not declared
(`FROM ledger:main`) is again the ledger address as written; a declared
prefix still expands.

Tests: dataset unit tests `from_query_json_reports_every_named_ledger` and
`sparql_dataset_ledger_ids_reports_every_named_ledger` (string, array and
object `from`, `{"@id", "t"}`, `fromNamed` object, legacy `from-named`,
`opts.from`, `ledger`, `FROM<x>` with no space, a bare `FROM ledger:main`,
several clauses, a commented-out clause, a history range, a per-source
policy); it_query_dataset
`reported_dataset_ledgers_cover_every_ledger_the_engine_reads`, which runs a
corpus through a recording nameservice and checks that every ledger whose
record the engine reads was reported. The recording nameservice moves to
the shared test support.
aaj3f added 4 commits October 13, 2026 13:56
…ferences

Conflict in fluree-db-api/src/view/fluree_ext.rs: main's
`graph_db_from_cached_head` and `ContentId` (opening the model ledger at
its head commit) kept; this branch's typed-reference imports kept, and
the `GraphRef` enum it replaced stays removed.
…ferences

Conflicts in fluree-db-api/src/error.rs and fluree-db-server/src/error.rs:
main's single status table (`ApiError::status_code`, `ApiError::error_type`)
kept, and the server's own table dropped as main drops it.
`QueryError::Nameservice` is classified in `query_error_status` (500) and
in the `@type` table (`err:system/NameServiceError`), with a row in the
every-variant test. This branch's `From<TargetError>`, `scope_id` and
nameservice tests are kept.

Conflicts in fluree-db-api/src/query/connection.rs and view/query.rs: this
branch's dataset readers (`connection_dataset_spec`,
`connection_sparql_dataset_spec`, `refuse_cross_ledger_from`) kept, each
error wrapped with main's `TrackedErrorResponse::from_api`, so a tracked
query answers the status the one table gives.

@bplatz bplatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: one grammar and one resolver is the right shape, and the docs and tests are thorough. There are items inline to look at and address:

Regressions against main, worth fixing before merge

  • CLI --remote with FROM <other:main> / {"from":"other:main"} stays on the ledger route and gets a 400.
  • An update's USING <urn:g1> (an ambiguous IRI with no graph yet) is now a 400, not an empty match.
  • With a BASE declared, bare and pinned ledger names in FROM are BASE-resolved on the connection route.

Fix or file as follow-ups

  • The JSON-LD ledger route resolves its dataset before the min-t wait.
  • The CLI loads the ledger twice to choose a route.
  • L:feature#config writes on a branch that inherited its source's labels.
  • A legacy urn:default graph shadows the default graph.
  • scope_registry swallows registry errors.

Nits

  • Repeated parsing in target_dataset.
  • Duplicated graph-id lookups.
  • Written text re-split after parsing.

main has moved 67 commits since the last merge. It merges cleanly except for one BENCHMARKING.md table conflict (keep both rows), and the merged tree passes cargo check --workspace --all-targets, clippy and fmt.

Comment thread fluree-db-cli/src/commands/query.rs Outdated
match resolver.resolve(written, &member, pinned) {
Ok(_) => local && pinned,
Err(TargetError::GraphNotFound(_)) => false,
Err(TargetError::CrossLedger { also_iri, .. }) => local || !also_iri,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression for --remote. A remote target has no registry, so FROM <other:main> reads as ambiguous and local || !also_iri keeps it on /query/mydb, where the server answers 400 "Ledger mismatch". JSON-LD {"from":"other:main"} has the same gap through names_another_ledger (it only counts DatasetRef::Address). On main, the base-name comparison sent both to /query. Suggest: when the registry is unknown, an ambiguous reference to another ledger goes to the connection path. The tests cover only the bare and pinned forms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and the mechanism is exactly that: the CLI holds no registry for a remote ledger, so other:main read as possibly a graph and stayed on /query/mydb. In 42c41706f, with no registry to consult, text that reads both as a graph IRI and as another ledger's address is read as that address, as on any surface with no target, so it goes to /query the way it did on main. On the JSON-LD side that's names_another_ledger, which now counts the ambiguous reading when the registry is unknown; on the SPARQL side it's the router's CrossLedger arm. remote_routing_sends_only_another_ledger_to_the_connection now covers the bare, pinned, @t:, urn:fluree:, #config and #<iri> forms, as FROM, FROM NAMED, and from (string, object, array) / fromNamed, and it fails with the change reverted. One side effect worth naming: FROM NAMED <urn:x> leaves the route too now, again as on main. A graph spelled that way is reached through the ledger (mydb:main#urn:x), which docs/cli/query.md now says.

match TargetLedger::new(target_ledger, &resolve_graph_id).resolve(iri, &member, false) {
Ok(graph) => Ok(Some(graph.g_id)),
Err(TargetError::GraphNotFound(_)) => Ok(None),
Err(TargetError::CrossLedger { named, .. }) => Err(TransactError::Parse(format!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ambiguous IRI the registry doesn't hold (USING <urn:g1>, USING NAMED <ex:g>, JSON-LD "fromNamed": ["urn:g1"]) now fails the whole update with "names ledger 'urn:g1'". The comment above says a graph the ledger doesn't have contributes nothing. Suggest mapping CrossLedger { also_iri: true, .. } to Ok(None) here, and keeping the 400 for a definite other-ledger address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the comment was right and the match arm wasn't. In d6bbda4b5, CrossLedger { also_iri: true, .. } maps to Ok(None) alongside GraphNotFound. So USING <urn:g1>, USING NAMED <ex:g> and "fromNamed": ["urn:g1"] contribute nothing again, and only an address that can't be anything else (USING <other>) is still the 400. The update matrix in it_named_graphs has those rows now (and w-other-ledger:main moved from refused to empty), and it fails with the arm reverted.

Comment thread fluree-db-sparql/src/lower/mod.rs Outdated
// query also declares a `mydb:` prefix, so the misused-prefix check
// that pattern IRIs get does not apply to a dataset clause.
crate::ast::term::IriValue::Full(s) => Ok(match base.as_deref() {
Some(base) if !fluree_vocab::iri::is_absolute_iri(s) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_absolute_iri is false for several ledger spellings (mydb, mydb@t:3, my_db:main). With a BASE declared they become http://ex.org/mydb@t:3 and so on, and the connection route answers "names no ledger". On main the connection path read them as written. Suggest trying the text as an address before BASE-resolving it, or documenting the change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one needed a narrower version of the suggestion, fwiw. Trying every relative IRI as an address first would also keep FROM <data-g1.ttl> as written, and the W3C dataset tests depend on BASE resolving exactly that (the harness prepends BASE <query-url>). data-g1.ttl and mydb are lexically the same kind of text, so nothing can tell them apart. I tried it to be sure: with every address-shaped relative IRI kept as written, the 12 dawg-dataset tests fail. So in a82e3953b, an address that names its branch or a time (my_db:main, mydb@t:3, tenant/db@t:3) stays as written under a BASE, since no relative reference is spelled that way (RFC 3986 keeps a : out of the first segment), and a bare name follows BASE as SPARQL says. That leaves FROM <mydb> under a declared BASE as the one difference from main, documented in datasets-and-named-graphs.md. The tests are base_leaves_an_address_with_a_branch_or_time_as_written, in the sparql crate and in grp_query, and both go red with the check taken out. If you'd rather keep main's reading for bare names too, I think it would have to be a dataset-position rule that the W3C harness opts out of, which seems worse.

Comment thread fluree-db-server/src/routes/query.rs Outdated
// Ledger-scoped endpoint: resolve `from` / `fromNamed` in the path's ledger,
// rejecting attempts to target a different ledger than the URL.
let registry = if fluree_db_api::jsonld_names_dataset(&query_json) {
scope_registry(&state, &path.id).await

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the cached head's registry before the Fluree-Min-T wait below; the SPARQL ledger route refreshes first. On a peer, a graph registered by the commit being waited for is misread: in from it is a 400 mismatch, and in fromNamed it is loaded as a ledger and gets a 404. Could the path ledger's header min-t be awaited before scope_registry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In 7adc15fd8 the ledger routes await the path ledger's min-t before scope_registry, on /query, /stream/query and /explain. That covers the header, opts.min-t, a pinned path, and a numeric pin on the ledger's own address. Writing the test turned up a SPARQL twin of the same problem. The SPARQL route did wait first, but it keyed the header's min-t to whatever sparql_dataset_ledgers reported, so FROM <urn:g1> waited on a ledger called urn:g1, which doesn't exist. Both languages now go through one path_ledger_min_t. ledger_routes_wait_for_the_path_ledgers_min_t_before_resolving_the_dataset puts the route's head one commit behind (a second instance on the same storage commits the graph) and runs six shapes across the three routes. It fails with the JSON-LD pre-wait reverted, and separately with the SPARQL keying reverted.

_ => Vec::new(),
impl EndpointGraphs {
async fn of_local(fluree: &fluree_db_api::Fluree, alias: &str) -> Self {
match fluree.ledger_cached(alias).await {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI builds Fluree with without_ledger_caching(), so ledger_cached here is a full ledger load, and the query then loads the ledger again. Every local query that names a dataset now pays two loads just to choose a route. Suggest reusing this handle for the query, or reading the graph names some cheaper way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reused the handle. In 7db0c3aab the router keeps the LedgerHandle it loaded, and the local path builds its view from it (Fluree::db_with_default_context_from_handle, plus an --at twin that resolves the time against that head). So a local query that names a dataset loads the ledger once again, and the plain NDJSON path reuses it too. Measured with dev-fast binaries at 7adc15fd8 and 7db0c3aab, interleaved, on a 302-commit unindexed ledger: FROM <bench:main> went from 31.5 to 21.1 ms median, FROM NAMED <g> from 34.4 to 22.1 ms, and JSON-LD "from": "bench:main" from 32.7 to 21.4 ms, which is where the no-dataset control sits (20.8 → 21.6 ms). --at drops the same ~10 ms (28.8 → 19.1 ms at the head). The box was shared, so take the medians as rough, but the minimums line up the same way.

}
}
}
if let Some(found) = self.registered(written, || {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the exact-registry lookup runs before the keyword reading. So a graph registered literally as urn:default before #2005 shadows the default graph in FROM/USING/WITH, while graph_position and the WITH template still write the real default graph. Then WITH <urn:default> DELETE {…} WHERE {…} reads one graph and retracts from another. main checked DEFAULT_GRAPH_IRI first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ba06dd75c: a keyword member now resolves before the exact-registry lookup, as main checked DEFAULT_GRAPH_IRI first. No write can create such a graph anymore, so the test renames one to urn:default in the loaded registry. It then runs WITH <urn:default> DELETE … WHERE …, USING <urn:default>, and the JSON-LD graph / from twins, and each one reads and retracts the default graph. With the registry-first order put back, the test fails at its first case, WITH <urn:default>, which leaves the default graph's fact in place.

Comment thread fluree-db-server/src/routes/query.rs Outdated
match state.fluree.ledger_handle(target).await {
Ok(handle) => Some(ScopeRegistry::Ledger(handle.graph_names().await)),
Err(e) if e.is_not_found() => Some(ScopeRegistry::Empty),
Err(_) => None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: proxy mode, and any load error other than not-found, both give None. With no registry, resolve_in_target reads an ambiguous other-ledger reference as a graph of the path's ledger. So {"from":"other:main"} becomes a 404 GraphNotFound instead of the 400 mismatch, and the storage error is dropped. Suggest propagating the error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propagated in 7adc15fd8. On proxy mode, I think we can do better than no registry: a proxy peer's queries load through the same cached handle (execute_query_proxy → db() → ledger_cached), so it can read the registry the way a shared-storage peer does, and now it does. So {"from": "other:main"} on a proxy peer is the 400 mismatch, and {"from": "urn:g1"} reads the graph. test_proxy_peer_ledger_route_resolves_the_dataset_in_its_registry drives that through a real proxy peer, and with an empty registry put back for proxy mode it fails at the urn:g1 read. A load error other than not-found now fails the request instead of quietly dropping the registry. With no registry at all, which is now only the CLI against a remote server, an ambiguous other-ledger reference reads as that ledger, per the --remote fix above.

Comment thread fluree-db-api/src/target_dataset.rs Outdated
fn source(&mut self, written: &str) -> Result<Option<InTarget>> {
if self.scope == Scope::AnyLedger {
let registered = self.graphs.is_some_and(|graphs| graphs(written).is_some());
let other_ledger = MemberRef::parse(written)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: each source is parsed with MemberRef::parse here, again in names_another_ledger, and again in resolve_in_target. That runs on every ledger-route request that names a dataset. Parsing once and passing the MemberRef down would match the parse-once design.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 42c41706f: Sources::source parses once and hands the MemberRef to resolve_member_in_target and names_another_ledger. The target's own id, written exactly as it stands, still takes no parse at all.

Comment thread fluree-db-api/src/view/fluree_ext.rs Outdated
let store = view.binary_store.as_ref();
// Fallback for safety: if registry is missing an entry but a binary
// store has it (should not happen in a consistent ledger), use the store.
let lookup = |iri: &str| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the "registry, then binary store" lookup is here, in view/query.rs's SPARQL FROM resolution, and in transact as ledger_graph_lookup, as well as ledger_view::graph_id_in. One shared helper would stop the fallback drifting between copies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ba06dd75c: fluree_db_binary_index::HeadGraphNames is the one registry-then-store table. fluree_ext, the SPARQL FROM resolution in view/query.rs, transact (its ledger_graph_lookup is gone) and LedgerView/GraphNames all read through it. It implements the new core GraphNameTable, which is also what the L:feature#config fix needed. After main brought in #2009, aa60ba924 moved the last readers that still spelled the reserved keywords themselves onto the same tables. ledger_info's graph selector takes a keyword's slot from GraphSel::keyword; its IRI lookups still read the binary store alone, since ledger-info's stats come from the index. config_guard's cross-branch check reads the IRI through AddressText and LedgerRef::parse. An update's from keywords and the CLI's target alias go through GraphSel and AddressText too.

/// reported as `name[:branch][#graph]`, whatever its spelling (the
/// `urn:fluree:` wrapper and the `@` pin removed, a bare name kept bare), and
/// anything else is kept as written.
fn identifier_of(written: &str, reference: &MemberRef) -> String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this function and unpinned_name re-split the written text at # and @ after MemberRef::parse has already split it. Building both from the typed parts, or from a pin span recorded at parse time, would keep the grammar in one place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ba06dd75c, through the parser's own lexer rather than the typed parts. The typed LedgerRef doesn't keep the spelling these need: the identifier keeps a bare name bare, and the pin alias keeps a URN's wrapper. So core has one lexer, AddressText, that LedgerRef::parse and DatasetRef::parse split through, and identifier_of / unpinned_name read the text's parts through it instead of splitting at # and @ themselves. It's one more lex of a short string per member, fwiw, not a second grammar.

aaj3f added 14 commits October 19, 2026 08:29
A reserved keyword in a graph position was looked up by this ledger's own
`urn:fluree:` IRI. A branch made from an indexed ledger holds its source's
IRI at the reserved slots, so `GRAPH <L:feature#config>` missed the config
graph, and a write registered a new graph that `FROM <L:feature#config>`
never read. `TargetLedger` now reads names through `GraphNameTable`, which
also says which IRI a reserved slot is registered under, and a reserved
keyword names the graph at its slot in every position.

`fluree_db_binary_index::HeadGraphNames` is the one registry-then-binary-store
table. The view's graph selection, its SPARQL `FROM`, transact's lookups and
`LedgerView` / `GraphNames` read through it instead of four copies.

A keyword now resolves before the exact registry lookup, as main checked
`DEFAULT_GRAPH_IRI` first. A graph an earlier version registered as
`urn:default` no longer shadows the default graph in `FROM` / `USING` /
`WITH`, where a graph position and the `WITH` template read the real one.

`AddressText` splits an address's text at `#` and `@` in one place.
`LedgerRef::parse` and `DatasetRef::parse` split through it, and a member's
reported identifier and a pinned member's alias read its spans instead of
splitting the written text again.

Tests: core unit tests for the slot, the keyword order and the lexer;
`a_branch_of_an_indexed_ledger_writes_its_config_address_to_the_config_slot`
(it_named_graphs) and
`a_legacy_urn_default_graph_does_not_shadow_the_default_graph`
(it_default_graph_name).
`USING <urn:g1>`, `USING NAMED <ex:g>` and JSON-LD `"fromNamed": ["urn:g1"]`
read both as a graph IRI and as another ledger's address. When the ledger
had no graph by that IRI, the update failed with "names ledger 'urn:g1'";
on main it matched nothing. It contributes nothing again, and only an
address that can name nothing but another ledger (`USING <other>`) is
refused. The update matrix in it_named_graphs covers each form.
With a `BASE` declared, `FROM <mydb@t:3>` and `FROM <my_db:main>` were
resolved against it and named no ledger. A ledger address that names its
branch or a time is no relative IRI reference (RFC 3986 keeps a `:` out of
a relative reference's first segment), so `resolve_dataset_clause` takes it
as written. A bare name (`mydb`) is also a relative reference, the same kind
of text as the W3C dataset tests' `FROM <data-g1.ttl>`, so `BASE` still
resolves it, as SPARQL specifies.

Tests: `base_leaves_an_address_with_a_branch_or_time_as_written`, in the
sparql crate and in grp_query.
`fluree query --remote` holds no graph registry for the remote ledger.
`FROM <other:main>` and `{"from": "other:main"}` read both as a graph IRI
and as another ledger, so the router kept them on the ledger route, which
answered 400 "Ledger mismatch". With no registry to consult, such text is
now the address, as on a surface with no target, so it goes to `/query`, as
on main; `resolve_in_target` reads it the same way, where it read it as a
graph of the target. A graph spelled that way is reached through the ledger
(`mydb:main#urn:x`).

`Sources::source` parses each JSON-LD source once and passes the parsed
member to the resolver and to the other-ledger check.
…egistry

The JSON-LD ledger routes (query, stream, explain) read the cached head's
graph registry before the `Fluree-Min-T` wait, so on a peer a graph the
awaited commit registers was misread: a 400 mismatch in `from`, and in
`fromNamed` a ledger to load and a 404. They now await the path ledger's
min-t first. The SPARQL ledger routes waited first, but keyed the header's
min-t to the ledgers the dataset parser reports, so `FROM <urn:g1>` waited
on a ledger named `urn:g1` (a 404). Both now wait on the path's ledger
through `path_ledger_min_t`: every reference on a ledger route resolves in
it.

`scope_registry` returns a load error other than not-found instead of
dropping the registry. A proxy-storage peer reads the registry too: its
queries load through the same cached handle, so it resolves a dataset as a
shared-storage peer does (`{"from": "other:main"}` was a 404
GraphNotFound there).

Tests: `ledger_routes_wait_for_the_path_ledgers_min_t_before_resolving_the_dataset`
(a second instance on the route's storage registers the graph) and
`test_proxy_peer_ledger_route_resolves_the_dataset_in_its_registry`.
The CLI builds its `Fluree` without a ledger cache, so the router's
`ledger_cached` was a full load, and the query then loaded the ledger
again. The router keeps the handle it loaded, and the local path builds its
view from it (`Fluree::db_with_default_context_from_handle`, and
`db_at_with_default_context_from_handle`, which resolves an `--at` time
against that head). Plain NDJSON reads the same head.
…ferences

Brings in #2009 and #2119. The two PRs each grew a typed graph-name module
and an answer for the ledger's own address in a graph position; the merge
keeps one of each:

- fluree-db-core dataset_ref: #2007's module, a superset of #2009's
  GraphIri/GraphSel, with #2009's tests. GraphSel::bare_keyword is the
  keyword table as a JSON-LD graph name is written (`urn:default` is an IRI
  there); GraphSel::keyword adds `urn:default`.
- transact: #2009's lexical GraphScope/WriteGraphs and its JSON-LD parser,
  without #1997's template-default flag (staging reads every scope through
  the graph-position table); the parser keeps a ledger address under strict
  compact-IRI checking and notes it, and reads `from`/`fromNamed` as dataset
  references. The reifier anchor follows its edge to the graph the table
  reads the scope as.
- A top-level `values` cell reads through #2009's ledger encoding; this
  branch's IriMatch carrier is dropped, as planned for whichever landed
  second.
Four readers still spelled the reserved graph keywords, or split an address
at `#`, themselves:

- `config_guard::other_branch_system_graph` parsed `urn:fluree:<name>:<branch>#<role>`
  by hand; it now reads the IRI through `AddressText` and `LedgerRef::parse`,
  and the role through `GraphSel::bare_keyword`, with the same answers
  (the `urn:fluree:` form, an explicit branch, no pin, another branch).
- `ledger_info::resolve_graph_selector` matched `default` / `urn:default`,
  `txn-meta` and `config` itself; it takes the slot from `GraphSel::keyword`.
- An update's `from` matched `default` and `txn-meta` itself; it reads
  `GraphSel::bare_keyword`.
- The CLI split a target's alias at `#`; it reads `AddressText::before_graph`.

The merge-check role label comes from `GraphSel` too. `parse_graph_ref`,
the view API's own keyword reader, was already gone on this branch: `db()`
and `graph()` parse a typed `LedgerRef` and select its graph through
`GraphSel`. Two comments that still named it are updated.
The merge with #2009 read every written graph name as an absolute IRI, so
`"@graph": "mydb#config"` (no scheme) was refused, and so was
`"graph": "mydb:main"` under strict compact-IRI checking when the context
defines no `mydb` prefix. Before the merge they named the config graph and
the default graph.

A name that expands to no absolute IRI but is an address of the ledger being
written is now `GraphName::Address`. It is built only by `AddressName::parse`,
which checks the address against the ledger the parser writes, and staging
reads it through the graph-position table like any graph IRI. Another ledger's
address is refused at parse with the error the name had before. So staging no
longer checks it, `Txn::address_graph_names` and `WriteGraphs::into_parts` go,
and #2009's `into_iris` is back.

`annotation_under_a_graph_named_through_the_address_anchors_to_that_graph`
pins the reifier anchor following its edge to `<g>` when the scope is
written `L#<g>`.
…ferences

Brings in #2122, #2126, #2127, #2131 and #2133. The one conflict is in
fluree-db-api's re-exports, where #2131's `SharedFluree` / `SharedOptions`
and this branch's `target_dataset` items both land.
…efined-prefix error

Since `ce0a70771`, a graph name that expands to no absolute IRI and is not
an address of the ledger being written keeps the error it had before: under
strict compact-IRI checking, the parser's "prefix 'exx' is not defined in
@context", which is what `main` answers for `"@graph": "exx:g"`. Staging's
own wording for it went with its check.
`ce0a70771` moved one refusal from staging to the parser: a graph name
that expands to no absolute IRI is kept as an address only of the ledger
being written. This pins the whole set at parse, in each graph position
(the update `graph` key, a node `@graph`, a `["graph", …]` item):

- this ledger's address (bare, with its branch, `#config`, `#<g>`, a time,
  `#txn-meta`) is kept for staging's graph-position table;
- another ledger's address (with a keyword, a graph IRI or a time, a name
  without a scheme, a name sharing this ledger's as a prefix) and an
  unknown keyword on this ledger's address are refused with the error the
  name has without the address reading.

The api test gains the JSON-LD twins of its SPARQL staging refusals: the
address at a time, and `L#<L>` with no such graph.
…ferences

Brings in #2137, #2118 and #2109. The one conflict is stage.rs's
fluree_db_core import: #2109 dropped `FlakeMeta` from it, and this branch
added the dataset-reference types. #2109's FactIdentity DELETE naming and
fold, and this branch's typed graph resolution for USING / WITH and the
write table, sit in separate hunks and merge as both wrote them.
@aaj3f

aaj3f commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Every new test in this PR, by name. These moved here from the description, which is at GitHub's size limit.

New integration tests, each with its SPARQL and JSON-LD twin where the surface has both:

  • fluree-db-api (grp_query): sparql_within_ledger_from_accepts_every_spelling_of_the_ledger, sparql_within_ledger_from_names_a_graph_through_the_address, sparql_within_ledger_from_rejections_are_typed, pinned_from_named_members_are_named_as_written (and the compatible alias), a_connection_query_refuses_a_bare_graph_iri, connection_dataset_iris_expand_against_the_prologue, a_view_refuses_a_jsonld_dataset_beyond_its_own_ledger (a from naming a ledger that does not exist, and every other shape a view does not read: all five entry points, opts included, and the own-ledger spellings that still answer), reported_dataset_ledgers_cover_every_ledger_the_engine_reads (a recording nameservice; see Solo), a_named_only_dataset_advises_when_the_query_reads_its_empty_default_graph, a_branch_reads_config_by_the_main_urn_and_urn_named_graphs_stay_graphs, solo_jsonld_dataset_shapes_still_answer, the_embedder_surface_on_the_hard_keep_list_still_compiles.
  • fluree-db-api (grp_query, it_service_cross_ledger_iri): service_to_a_non_member_is_refused_not_answered_by_the_dataset, a_service_endpoint_is_never_loaded, a_service_to_a_ledger_held_at_two_times_is_refused (and, with one time, the same member on each of eight freshly built datasets).
  • fluree-db-api (grp_graphsource, it_named_graphs): graph_handles_take_the_addresses_db_takes (graph() does not accept #graph fragments or urn:fluree: ids that db() accepts #1961), a_missing_ledger_reads_as_not_found_at_every_entry_point, update_where_dataset_references_resolve_in_the_transactions_ledger (each update dataset shape, cross-ledger and pinned refusals, both languages); for graph positions, test_writes_through_the_ledger_address_name_the_default_graph (the address and L#<g> in quads, a GRAPH ?g template bound through USING NAMED (the INSERT reproduction from Claude's review), TriG, a JSON-LD node @graph and top-level graph; the refusals; no graph registered under the address), test_updates_on_a_graph_registered_under_the_ledger_address (the DELETE reproduction from Claude's review, and every read/write position over a graph registered under the address, both spellings), test_query_and_update_list_the_address_graph_under_one_name (the query and the update list it as L#L, that name reads it back, and a ?g template writes it), test_a_graph_registered_under_the_address_migrates_to_the_default_graph (the documented recipe), test_the_union_default_graph_reads_the_address_graph, an_update_reads_a_graph_variable_bound_to_the_ledger_address (a top-level values, a where values and the SPARQL VALUES twin, both spellings of the address), and a_top_level_values_iri_in_a_new_namespace_writes_and_reads_as_itself (a guard: a template still writes such an IRI as itself; it passes with or without the change).
  • fluree-db-api (grp_transact, it_default_graph_name), pinning current behavior: urn_default_under_a_query_dataset_follows_the_dataset_clause, a_named_member_for_the_default_graph_reads_it, a_graph_variable_bound_in_the_default_graph_by_name_reads_its_graph.
  • fluree-db-api (grp_misc, it_multi_query): multi_query_every_member_is_read_at_the_snapshot (SPARQL urn:fluree:, a \u escape, a declared prefix and BASE; JSON-LD fromNamed, from-named and opts.from, under asOf: 1), multi_query_a_urn_member_resolves_its_ledgers_snapshot, multi_query_named_graph_ledgers_are_resolved_at_entry (listed, and a missing one is the envelope's not-found), multi_query_a_named_member_keeps_its_name_at_the_snapshot (both surfaces, with and without asOf), multi_query_a_member_naming_its_own_time_keeps_it (a guard: an own pin won before too), multi_query_a_from_named_ledger_is_counted_and_pinned_in_every_layer (fromNamed in the body and in the envelope's and the sub-query's opts: validation's set, the bound, the integer-asOf rule, the snapshot and the read), multi_query_sub_queries_that_do_not_parse_are_reported_per_alias_via_in_process_api (both languages, and a recovered parse error reported for the text as written), multi_query_outer_opts_may_not_change_the_dataset_the_body_names (each refusal, each composition, and a body with no from still refused).
  • fluree-db-api (grp_import): import_trig_blocks_named_by_the_ledger_address.
  • The address with a reserved keyword: a core, two it_named_graphs, a server and a CLI test (SPARQL and JSON-LD, reads and writes), and test_graph_management_reads_a_graph_named_through_the_address.
  • fluree-db-api (it_sql_pushdown_lane, features sql,native): graph_source_probes_fail_closed_and_skip_ledger_graphs (against real SQL sources with every graph-source lookup failing; the failure is a 500) and a_union_default_graph_never_probes_its_members.
  • fluree-db-server: ledger_route_dataset_references_resolve_in_the_paths_ledger (graph IRIs with # and @, the config graph by its URN, each spelling of the path and of the ledger, a prefixed FROM NAMED, a graph IRI in fromNamed, an unknown graph, another ledger in each language); ledger_route_jsonld_dataset_shapes_read_in_the_paths_ledger (the route's view and its connection path; it fails on main and on fix(server): query routes read a request's dataset the way the engine does #2019 in every case); ledger_routes_check_read_access_before_resolving_the_dataset (the JSON-LD query, stream and explain routes); ledger_route_from_object_is_read_as_the_parser_reads_it (every spelling of the path's ledger and of another, as a string and as an object, in both lanes); multi_query_jsonld_min_t_covers_every_ledger_the_body_reads and multi_query_reads_a_sibling_with_its_outer_opts_merged (min-t over a ledger the body's fromNamed, the body's opts or the outer opts name; a changed default graph is a 400, also with min-t: 2 on a ledger at t=1, refused before the wait); multi_query_outer_opts_narrow_a_jsonld_sub_query_as_its_own_do (an option set in the envelope's or the sub-query's opts reaches a JSON-LD sub-query on the server as its own would).
  • fluree-db-cli: local_query_reads_the_graph_or_branch_its_dataset_names, issue_1972_reproduction_reads_the_graph_each_from_names (the issue's commands verbatim), issue_1512_sparql_from_reads_the_config_graph, a_named_only_dataset_warns_on_stderr, remote_at_pins_the_path_and_keeps_the_querys_dataset (a fluree server run --memory child), remote_at_falls_back_on_a_server_without_path_pins (a stand-in that replies as v4.2.1 does), plus unit tests for the routing decisions (local_routing_hands_the_connection_the_resolved_body among them) and the fallback predicate.
  • Unit tests for the grammar, the classifier, the resolution table and the graph-position table in fluree-db-core::dataset_ref (a malformed address in the urn:fluree: spelling and with nothing after #, a_graph_position_reads_the_address_as_the_default_graph, a_graph_is_listed_under_a_name_that_reads_it_back, urn_default_names_the_default_graph); the dataset parsers in fluree-db-api::dataset (ledger_times_read_the_unpinned_members_of_their_ledgers among them); fluree-db-api::target_dataset (key precedence, resolution in the target, a graph member that names a second graph, a_source_object_is_read_by_the_parsers_id_keys); multi-query validation (members_are_keyed_by_the_ledger_each_spelling_names, jsonld_members_are_every_ledger_the_body_reads, jsonld_pins_and_history_ends_are_found_where_the_parser_reads_them, effective_jsonld_body_merges_opts_most_specific_first, a_sparql_subquery_with_a_recovered_parse_error_has_no_members) and the snapshot's ledger times (a_snapshot_id_that_is_no_ledger_id_fails_the_envelope); the dispatcher's opts-merge unit tests now call the function the dispatcher runs; the status of a nameservice failure in the API and the server; the SERVICE endpoint grammar; the server's path id, JSON-LD normalization and key precedence.

This round's new tests:

  • fluree-db-core: a_branch_reads_and_writes_a_reserved_keyword_by_its_slot, a_legacy_urn_default_graph_does_not_shadow_the_default_graph, address_text_splits_where_the_parser_does.
  • fluree-db-sparql: base_leaves_an_address_with_a_branch_or_time_as_written.
  • fluree-db-api: a_branch_of_an_indexed_ledger_writes_its_config_address_to_the_config_slot (grp_graphsource), a_legacy_urn_default_graph_does_not_shadow_the_default_graph (grp_transact), base_leaves_a_ledger_address_with_a_branch_or_time_as_written (grp_query), and the new rows of update_where_dataset_references_resolve_in_the_transactions_ledger.
  • fluree-db-server: ledger_routes_wait_for_the_path_ledgers_min_t_before_resolving_the_dataset (grp_query), test_proxy_peer_ledger_route_resolves_the_dataset_in_its_registry (grp_proxy).
  • fluree-db-cli: remote_routing_sends_only_another_ledger_to_the_connection, extended.
  • With the merge of fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009: annotation_under_a_graph_named_through_the_address_anchors_to_that_graph (fluree-db-api, grp_graphsource), the reifier anchor of an edge written under L#<g> naming <g>.

Existing tests whose expectation changed on purpose in earlier rounds, or that are retired:

  • a_graph_named_by_the_ledger_address_gets_what_its_templates_write (from main) seeded a graph under the ledger's own address with a TriG block, which now writes the default graph. It builds that layout on a branch, as legacy_address_branch does, and writes the graph as <address>#<address>; its assertions are unchanged.
  • sparql_within_ledger_from_alias_spelling_mismatch_is_rejected locked FROM <wl> (the short alias) on a view as a rejection, a deferred limitation; the short alias now names the default graph, and the test is retired in favor of sparql_within_ledger_from_accepts_every_spelling_of_the_ledger.
  • sparql_reserved_graphs_stay_unreachable_when_not_named_in_full refused the bare keywords config / txn-meta in a view's FROM; a keyword is now an explicit naming of the ledger's reserved graph, as on the ledger route, so the test keeps refusing the relative #config / #txn-meta and another ledger's reserved IRI, and GRAPH ?g still never enumerates a reserved graph.
  • a_view_refuses_a_jsonld_from_naming_another_ledger becomes a_view_refuses_a_jsonld_dataset_beyond_its_own_ledger: the within-ledger shapes it let through (a pin, a graph, named graphs) are now refused too.
  • fix: unresolvable graph references fail closed, and TriG directives apply in document order #1997's test_updates_on_a_graph_registered_under_the_ledger_address locked GRAPH <address> in a WHERE and a template as that graph. It now reads and writes the default graph there, and the graph is reached as L#<address>. Since no write can register such a graph any more, its fixture, and that of sparql_single_db_graph_alias_wins_over_colliding_named_graph, builds one the way an earlier version could leave it: main writes a graph named by a branch's address, and the branch inherits it.
  • fix: unresolvable graph references fail closed, and TriG directives apply in document order #1997's a_failed_source_lookup_still_fails_the_query asked about GRAPH <maybe-source:main> through a one-ledger dataset. It keeps testing that a failed lookup fails the query, with a GRAPH IRI this PR still probes (on the ledger's view), and now also that the failure is a 500. The graph-source lane test no longer asserts what an undeclared graph source answers through GRAPH on a plain view; it keeps the fail-closed cases.
  • dataset_options_and_envelope_defaults_cannot_replace_authority (fluree-db-server): {"from": L, "opts": {"from": {"@id": other}}} with a token for L only is now a 400 on /query/L (a lone from naming another ledger, read where the parser reads it, refused before loading) and still a 404 on /query; neither response carries the restricted document.
  • reported_dataset_ledgers_cover_every_ledger_the_engine_reads compared both sides canonicalized, so it could not see a report in a form a consumer does not parse (a urn:fluree: wrapper stayed green). It now reads each reported string as a consumer does (dropping #graph and @pin, keeping the branch; only the id grammar's own equivalence, a bare name for its main branch, is allowed), and its corpus covers opts over the top level, named objects, a sub-query's own dataset keys, and SERVICE, nested or not.
  • Multi-query unit tests: rejects_subquery_with_object_from_missing_id expects the parser's error (JsonLdDatasetUnreadable) rather than MissingFrom; the two collision tests for an object's t / at match the new message ("a source names its own time for ''"). The unit tests of the removed snapshot rewriters go with them.

This round's mutation log, at 7db0c3aab (--all-features; each mutation reverted one fix, ran the named tests, and restored the file with git checkout, checked byte-for-byte):

item1-sparql-router: -p fluree-db-cli --all-features --lib -- remote_routing_sends_only_another_ledger_to_the_connection -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 257 filtered out; finished in 0.00s
item1-sparql-router: restored OK
item1-jsonld-names-another-ledger: -p fluree-db-cli --all-features --lib -- remote_routing_sends_only_another_ledger_to_the_connection -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 257 filtered out; finished in 0.00s
item1-jsonld-names-another-ledger: restored OK
item2-using-ambiguous: -p fluree-db-api --all-features --test grp_graphsource -- update_where_dataset_references_resolve_in_the_transactions_ledger -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 238 filtered out; finished in 0.08s
item2-using-ambiguous: restored OK
item3-base: -p fluree-db-sparql --all-features --lib -- base_leaves_an_address_with_a_branch_or_time_as_written -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 689 filtered out; finished in 0.00s
item3-base: -p fluree-db-api --all-features --test grp_query -- base_leaves_a_ledger_address_with_a_branch_or_time_as_written -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 546 filtered out; finished in 0.04s
item3-base: restored OK
item4-jsonld-prewait: -p fluree-db-server --all-features --test grp_query -- ledger_routes_wait_for_the_path_ledgers_min_t_before_resolving_the_dataset -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 185 filtered out; finished in 0.11s
item4-jsonld-prewait: restored OK
item4-sparql-keying: -p fluree-db-server --all-features --test grp_query -- ledger_routes_wait_for_the_path_ledgers_min_t_before_resolving_the_dataset -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 185 filtered out; finished in 0.14s
item4-sparql-keying: restored OK
item6-reserved-slot: -p fluree-db-core --all-features --lib -- a_branch_reads_and_writes_a_reserved_keyword_by_its_slot -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1042 filtered out; finished in 0.00s
item6-reserved-slot: -p fluree-db-api --all-features --test grp_graphsource -- a_branch_of_an_indexed_ledger_writes_its_config_address_to_the_config_slot -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 238 filtered out; finished in 0.19s
item6-reserved-slot: restored OK
item7-keyword-first: -p fluree-db-core --all-features --lib -- a_legacy_urn_default_graph_does_not_shadow_the_default_graph -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1042 filtered out; finished in 0.00s
item7-keyword-first: -p fluree-db-api --all-features --test grp_transact -- a_legacy_urn_default_graph_does_not_shadow_the_default_graph -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 309 filtered out; finished in 0.05s
item7-keyword-first: restored OK
item8-proxy-registry: -p fluree-db-server --all-features --test grp_proxy -- test_proxy_peer_ledger_route_resolves_the_dataset_in_its_registry -> RED; test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 52 filtered out; finished in 3.66s
item8-proxy-registry: restored OK

The merges' revert runs, at the head d68a3e871: the code the merges with main and their follow-up commits wrote, reverted one change at a time, each run against the transact lib tests, grp_graphsource and grp_transact, the file restored by git checkout and checked byte-for-byte after each. f1 admits no address name; f2 and f3 drop the address reading after a non-absolute expansion and after a strict refusal; f4 admits any ledger's address, not only this ledger's; m2 keeps the reifier anchor when the scope reads as the default graph and m3 leaves it naming L#<g>; m4 drops the top-level "graph": "urn:default" reading; m5 reads written graph names through the keyword table with urn:default:

f1-no-address-names: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 101; failed: 1
        test parse::jsonld::tests::only_this_ledgers_address_is_kept_as_a_graph_name ... FAILED
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 5
        test it_jsonld_graph_scope::annotation_under_a_graph_named_through_the_address_anchors_to_that_graph ... FAILED
        test it_named_graphs::test_an_address_with_a_reserved_keyword_names_the_reserved_graph ... FAILED
        test it_named_graphs::a_branch_of_an_indexed_ledger_writes_its_config_address_to_the_config_slot ... FAILED
        test it_named_graphs::test_writes_through_the_ledger_address_name_the_default_graph ... FAILED
        test it_named_graphs::test_updates_on_a_graph_registered_under_the_ledger_address ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
f2-unexpandable-name-fallback: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 101; failed: 1
        test parse::jsonld::tests::only_this_ledgers_address_is_kept_as_a_graph_name ... FAILED
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 1
        test it_named_graphs::test_an_address_with_a_reserved_keyword_names_the_reserved_graph ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
f3-strict-refusal-fallback: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 101; failed: 1
        test parse::jsonld::tests::only_this_ledgers_address_is_kept_as_a_graph_name ... FAILED
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 5
        test it_jsonld_graph_scope::annotation_under_a_graph_named_through_the_address_anchors_to_that_graph ... FAILED
        test it_named_graphs::test_an_address_with_a_reserved_keyword_names_the_reserved_graph ... FAILED
        test it_named_graphs::test_updates_on_a_graph_registered_under_the_ledger_address ... FAILED
        test it_named_graphs::test_writes_through_the_ledger_address_name_the_default_graph ... FAILED
        test it_named_graphs::a_branch_of_an_indexed_ledger_writes_its_config_address_to_the_config_slot ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
f4-only-this-ledger: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 101; failed: 3
        test parse::jsonld::tests::new_refusals_render_as_parse_or_json_ld_errors ... FAILED
        test parse::jsonld::tests::relative_graph_name_refused ... FAILED
        test parse::jsonld::tests::only_this_ledgers_address_is_kept_as_a_graph_name ... FAILED
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 1
        test it_named_graphs::test_writes_through_the_ledger_address_name_the_default_graph ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
m2-anchor-drop: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 0; failed: 0
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 1
        test it_jsonld_graph_scope::annotation_under_a_default_graph_name_lands_in_the_default_graph ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
m3-anchor-follows-L#g: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 0; failed: 0
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 1
        test it_jsonld_graph_scope::annotation_under_a_graph_named_through_the_address_anchors_to_that_graph ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 0; failed: 0
m4-top-level-urn-default: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 0; failed: 0
    -p fluree-db-api --all-features --test grp_graphsource: exit 101; failed: 1
        test it_jsonld_graph_scope::annotation_under_a_default_graph_name_lands_in_the_default_graph ... FAILED
    -p fluree-db-api --all-features --test grp_transact: exit 101; failed: 2
        test it_default_graph_name::update_positions_read_urn_default_as_the_default_graph ... FAILED
        test it_default_graph_name::a_legacy_urn_default_graph_does_not_shadow_the_default_graph ... FAILED
m5-bare-keyword: RED; restored=OK
    -p fluree-db-transact --all-features --lib: exit 0; failed: 0
    -p fluree-db-api --all-features --test grp_graphsource: exit 0; failed: 0
    -p fluree-db-api --all-features --test grp_transact: exit 101; failed: 1
        test it_default_graph_name::writes_naming_urn_default_as_a_graph_are_refused ... FAILED

@aaj3f

aaj3f commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the careful pass. All eleven are addressed in the PR rather than filed, on top of a fresh merge of main (BENCHMARKING.md keeps both rows). #2009 landed while this was in flight, so main is merged in again after them. The two PRs had each grown a typed graph-name module and their own answer for the ledger's address in a graph position, so the merge keeps one of each. The description has a section on how, and #2009's tests run unchanged. Two went a bit differently than suggested, and I'd like your eyes on them. One is BASE: the W3C dataset tests pin a relative FROM <data-g1.ttl>, so only an address with a branch or a time is exempt, and a bare name still follows BASE. The other is proxy mode, which now reads the registry rather than going without. The min-t item also had a SPARQL twin, which is fixed in the same commit. The description has the per-item detail, a table against main, and the red/green runs.

…cord kept

#2097 published and dropped such a branch. On this branch the id no
longer parses, so the test now pins that: publish, lookup and drop are
refused, nothing is written for it, and a record an older version wrote
stays where it is.
@bplatz
bplatz merged commit aa9aa7a into main Oct 20, 2026
19 checks passed
@bplatz
bplatz deleted the feat/typed-dataset-references branch October 20, 2026 22:47
bplatz added a commit that referenced this pull request Oct 21, 2026
Brings #2007 (typed dataset and graph references) onto next. Resolved:

- import: a TriG block naming the ledger's own address writes the default
  graph, as main now reads it; its reified triples take next's
  rdf:reifies link in that graph, not main's bundle.
- lower_sparql_update: next's DELETE WHERE helpers, without the
  graph_from_template_default field main removed.
- graph_source provider: next's lookup_live, which already carries main's
  nameservice error.
- nameservice: main's test that a branch beginning with '/' is refused and
  an older record for one kept, on next's create and lifecycle drop.
- BENCHMARKING: main's dataset_build row; next has no annotation benches.
- imports and re-exports from both sides.

Ported to next:

- advisory: next has no AnnotationTarget pattern; TermComponents reads no
  graph of its own, the link triple beside it does.
- Main's new tests await the async genesis_ledger, publish fenced, name
  their ledgers name:main rather than as branches of one name (the
  multi-query mq:* ledgers and their spellings), and open a second
  instance beside a live server's storage without the storage lock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:query Query execution, planning, fast paths, overlay, result formatting area:sparql SPARQL/Turtle/TriG/JSON-LD parsing, lowering, UPDATE semantics, W3C conformance bug Something isn't working as expected

Projects

None yet

2 participants