Repository navigation
Description
Verified at origin/main 0c5d32c11 (fluree 4.2.1) on 2026-09-28, and reconfirmed side by side
against 6b63e64b3 (fluree 4.2.0), 261 commits earlier, on the same machine. Behaviour is identical
at both revs. fluree/solo currently pins ffeeec554, which sits between them (231 commits past
6b63e64b3, 30 behind 0c5d32c11); parse/jsonld.rs, config_resolver.rs,
fluree-graph-turtle/src/parser.rs and docs/ledger-config/writing-config.md are byte-identical
between ffeeec554 and 0c5d32c11, so the repro below is both what a maintainer reproduces and what
the product ships.
Scope. This is the JSON-LD parse half only: triples that never receive a graph. The separate
symptom of an export dropping a graph the triples do carry is #1847 (open; see Related — its silent
form no longer reproduces at 0c5d32c11).
Summary
In JSON-LD transactions, "@graph": "<iri>" on a node object scopes that node's own triples to the
named graph but not the triples of any object nested under it. Nested nodes are parsed by a recursive
call that re-reads @graph from the nested object, which does not have one, so their triples are
emitted untagged and land in the default graph. The write is accepted with a real commit id and a
real t.
For a f:LedgerConfig the result is not a no-op but an inversion. A ledger with shapes and no
config at all validates writes against those shapes. Writing the config the docs prescribe —
f:shaclEnabled true, f:validationMode f:ValidationReject — leaves a f:shaclDefaults reference
pointing at a blank node whose properties are outside the config graph, so the reader finds the group
present and every field unset, and merge_shacl_opts defaults enabled to false. Asking for
enforcement turns enforcement off, with no error on any channel.
Steps to reproduce
Run at 0c5d32c11 (fluree 4.2.1), local CLI, no server, in an empty directory.
fluree init
fluree create govdemoShapes into the default graph:
cat > shapes.jsonld <<'EOF'
{ "@context": { "sh": "http://www.w3.org/ns/shacl#", "cm": "http://example.org/cm#" },
"@graph": [ { "@id": "cm:RequirementShape", "@type": "sh:NodeShape",
"sh:targetClass": { "@id": "cm:Requirement" },
"sh:property": [
{ "@id": "cm:propActor", "sh:path": { "@id": "cm:actor" }, "sh:minCount": 1 },
{ "@id": "cm:propControl", "sh:path": { "@id": "cm:mappedControl" }, "sh:minCount": 1 } ] } ] }
EOF
fluree insert govdemo -f shapes.jsonld # Committed t=1, 8 flakesThe config, in the shape docs/ledger-config/writing-config.md prescribes — node-level @graph,
settings nested as anonymous objects:
cat > config-nested.jsonld <<'EOF'
{ "@context": { "f": "https://ns.flur.ee/db#" },
"@graph": [
{ "@id": "urn:fluree:govdemo:main:config:ledger",
"@type": "f:LedgerConfig",
"@graph": "urn:fluree:govdemo:main#config",
"f:shaclDefaults": {
"f:shaclEnabled": true,
"f:validationMode": { "@id": "f:ValidationReject" },
"f:shapesSource": { "@type": "f:GraphRef",
"f:graphSource": { "f:ledger": "govdemo:main",
"f:graphSelector": { "@id": "f:defaultGraph" } } } } } ] }
EOF
fluree insert govdemo -f config-nested.jsonld # Committed t=2, 9 flakesThen write a record the shapes forbid:
cat > bad-record.jsonld <<'EOF'
{ "@context": { "cm": "http://example.org/cm#" },
"@id": "cm:REQ-BAD-001", "@type": "cm:Requirement",
"cm:title": "missing actor and mappedControl" }
EOF
fluree insert govdemo -f bad-record.jsonldExpected
Either the nine triples of the config document all land in urn:fluree:govdemo:main#config, or the
document is refused. A f:LedgerConfig whose f:shaclDefaults does not resolve inside the config
graph is not a config — and it must not be worse than writing no config at all.
Actual
The config write is accepted:
Committed t=2, 9 flakes
The forbidden record is also accepted — nothing enforces:
Committed t=3, 2 flakes
Decoding the config commit shows where the nine triples went. Flakes 7 and 8 — the f:LedgerConfig
node's own two triples — carry a graph; flakes 0 through 6 — every nested setting — carry none:
fluree show -l govdemo <commit> # commit id from `fluree log govdemo`0 ['_:fdb-…-b0', 'f#shaclEnabled', True, xsd:boolean, True]
1 ['_:fdb-…-b0', 'f#shapesSource', '_:fdb-…-b1', '@id', True]
2 ['_:fdb-…-b0', 'f#validationMode', 'f#ValidationReject', '@id', True]
3 ['_:fdb-…-b1', 'rdf#type', 'f#GraphRef', '@id', True]
4 ['_:fdb-…-b1', 'f#graphSource', '_:fdb-…-b2', '@id', True]
5 ['_:fdb-…-b2', 'f#graphSelector', 'f#defaultGraph', '@id', True]
6 ['_:fdb-…-b2', 'f#ledger', 'govdemo:main', xsd:string, True]
7 ['urn:fluree:govdemo:main:config:ledger', 'rdf#type', 'f#LedgerConfig',
'@id', True, {'graph': 'urn:fluree:govdemo:main#config'}]
8 ['urn:fluree:govdemo:main:config:ledger', 'f#shaclDefaults', '_:fdb-…-b0',
'@id', True, {'graph': 'urn:fluree:govdemo:main#config'}]
Reading the config graph back confirms it holds two triples:
fluree query govdemo --sparql --format table \
-e 'SELECT ?s ?p ?o FROM <urn:fluree:govdemo:main#config> WHERE { ?s ?p ?o }'urn:fluree:govdemo:main:config:ledger rdf:type f:LedgerConfig
urn:fluree:govdemo:main:config:ledger f:shaclDefaults fdb-…-b0
(2 rows)
So the config graph holds a type and a f:shaclDefaults pointing at a blank node that has no
properties in that graph. The chain is severed at the first nesting. The seven settings triples are
in the default graph, alongside the user's own data. That is visible in an export, and the export is
behaving correctly — it is serializing what the writer wrote. fluree export govdemo emits the seven
as three free-floating blank nodes in the default graph; fluree export govdemo --all-graphs --system-graphs --format trig emits a dataset whose f:shaclDefaults sits in one graph and points at
a blank node defined in another, which is not a round-trippable RDF dataset. Nothing here is an export
defect — the export-side defect is #1847, and its silent form no longer reproduces at 0c5d32c11
(--format trig now warns "1 named graph not exported; pass --all-graphs to include it", and
--all-graphs emits it).
Three controls, same binary, same shapes, same forbidden record
No config at all still enforces. A ledger with only shapes.jsonld refuses the same record:
error: Transaction error: SHACL validation failed with 2 violation(s):
1. Expected at least 1 value(s) but found 0
Focus node: cm:REQ-BAD-004
Path: cm:actor
Constraint: http://www.w3.org/ns/shacl#MinCountConstraintComponent
2. …Path: cm:mappedControl…
This is the control that matters: the documented JSON-LD config does not fail to add enforcement, it
removes enforcement that was there without it.
The same document with an explicit @id and its own @graph on every nested node commits the
same nine flakes and enforces.
The same config written with SPARQL INSERT DATA and a GRAPH clause — the route the same docs
page prescribes at :39-52 — keeps the whole chain, blank node included:
fluree update govsparql -f config.ru --format sparql # Committed t=2, 4 flakesfdb-…-#bnpl0 f:shaclEnabled true
fdb-…-#bnpl0 f:validationMode f:ValidationReject
urn:fluree:govsparql:main:config:ledger rdf:type f:LedgerConfig
urn:fluree:govsparql:main:config:ledger f:shaclDefaults fdb-…-#bnpl0
(4 rows)
and the forbidden record is refused. So blank nodes are not the problem, the config graph is not the
problem, and the reader is not the problem. The JSON-LD writer's handling of a node-level @graph
is. The docs' own four-triple JSON-LD snippet (writing-config.md:81-96), run against the same
shapes, splits the same way: 4 flakes committed, 2 in the config graph, f:shaclEnabled and
f:validationMode left in the default graph, forbidden record commits.
Root cause
fluree-db-transact/src/parse/jsonld.rs, in parse_expanded_object_with_ctx (:1347):
:1364reads the node-level@graph,:1379interns it throughctx.write_graphs.get_or_assign,
and:1381falls back toctx.default_graph. The result is a localnode_graphbinding. It is
never written back intoctx.:1446recurses into each property value —
parse_expanded_objects_with_ctx(value, ctx, &mut templates)— passingctxbut notnode_graph.
Nested node objects re-enterparse_expanded_object_with_ctxat:1616(nested node with@id)
and:1678(anonymous node), where:1364finds no@graphon the nested object and:1381
falls back toctx.default_graph, which isNone. Their templates are appended untagged at
:1617/:1679.:1419-1420and:1451-1452then tag the parent node's own@typeand property triples with
node_graph— the only two triples that get scoped.ctx.default_graph(:858) is written in exactly one place::968-970, the update-template
sugar["graph", <iri>, <pattern>], which replaces it, parses the body, and restores the previous
value. The insert and upsert paths construct the context withdefault_graph: None(:291,
:347) and never set it, so on those paths a node-level@graphis the only way to address a
named graph and it cannot reach a nested node.
The right shape is already in the same file. parse_graph_insert (:198) — the request-level target
graph, used by parse_sync_transaction (:183) and fluree-db-api/src/tx.rs:2334 — re-homes every
template in the transaction, nested ones included:
// :224-226
for t in &mut txn.insert_templates {
t.graph = TemplateGraph::Iri(Arc::clone(&target));
}Node-level @graph is the one graph-addressing path that tags a node rather than a subtree.
The reader is consistent and does its job: fluree-db-api/src/config_resolver.rs resolves every
config field against CONFIG_GRAPH_ID — find_instances_of_type at :797 and
query_config_predicate at :818, which builds GraphDbRef::new(snapshot, CONFIG_GRAPH_ID, overlay, to_t) at :834. It looks only in the config graph, which holds only the severed head of the chain.
read_shacl_defaults (:1148) therefore returns Some(ShaclDefaults) with every field None, and
merge_shacl_opts (:510) turns that into enabled: shacl.enabled.unwrap_or(false) (:540) — the
inversion. The comment at :536-539 explains the false default as the safer posture, which it is
for a config the user wrote; it is the wrong outcome for a config the user wrote and the writer lost.
Impact
docs/ledger-config/writing-config.md prescribes the failing shape, and is unchanged at
0c5d32c11. The "Writing via JSON-LD" section (:77-96) is the document reproduced above — node-level
@graph, f:shaclDefaults as a nested anonymous object — and :54 says "The JSON-LD form below works
with fluree insert unchanged." A config written the documented way, through the documented command,
disables the enforcement the ledger had before it.
The same page's SPARQL route (:39-52) works. So the page ships a working recipe and a broken one,
four lines apart, with a sentence in between promising the broken one works.
The same mechanism applies to any config group resolved out of the config graph —
f:policyDefaults, f:reasoningDefaults, f:datalogDefaults — and to any user document that nests
nodes under a node-level @graph, where the effect is quieter still: the nested triples are written
into the default graph and become indistinguishable from data.
A config is a bad place for a silent failure, because its whole job is to be believed later. A write
that fails loudly gets retried; a write that succeeds and does nothing gets depended on. A write that
succeeds and quietly disables the thing it asked for is worse than either.
Proposed fix
-
Nested nodes inherit the enclosing node's
@graph. Inparse_expanded_object_with_ctx, set
ctx.default_graph = node_graph.clone()around the property loop and restore it afterwards — the
same save/parse/restore the update-template wrapper already does at:968-970. A nested node that
carries its own@graphstill wins, because:1364is read before the:1381fallback. The
restore has to survive the?returns inside the loop (a guard, or hoisting the loop into a
helper), not just the happy path. Nothing else on the insert/upsert paths is affected, because
they construct the context withdefault_graph: None(:291,:347).parse_graph_insert's
whole-subtree re-home at:224-226is the semantics to match. -
Fix the docs either way.
writing-config.md:54must stop promising the JSON-LD form works, and
:77-96must either go or show every node in the chain with its own@idand@graph. The
working SPARQL recipe is already on the page. -
Name blank nodes in the TriG parse errors. A blank node inside a
GRAPHblock is refused with
a message that names the token, not the construct. Two lines each:GRAPH <urn:g> { [ f:shaclEnabled true ] . }→Parse error: expected subject, found '['GRAPH <urn:g> { <urn:a> f:shaclDefaults [ f:shaclEnabled true ] . }→
Parse error: expected object, found '['
The same blank nodes outside a
GRAPHblock commit fine, so the construct, not the syntax, is
what is unsupported — and neither message says so, which makes the fix (give every node an IRI)
undiscoverable from the error. AGRAPHblock nested inside aGRAPHblock produces
expected subject, found 'GRAPH', and so does TriG fed tofluree insert, which routes to the
streaming Turtle parser (fluree insert -f g.ttlon a singleGRAPHblock:Turtle parse error: Parse error at position 38: expected subject, found 'GRAPH'). A singleGRAPHblock through
upsertdoes not error — the non-streaming parser reads it and places the graph — so the trap is
insert-specific, not "TriG through the Turtle parser". The string is pinned as a documented trap in
fluree-graph-turtle/src/parser.rs:2532,fluree-db-api/tests/it_reserved_graph_writes.rs:120
anddocs/transactions/turtle.md:513. All four messages come from
fluree-graph-turtle/src/parser.rs:819/:1031, which format the token kind and nothing else.Reaching any of them now needs
--format turtle: at0c5d32c11a.trigfile is refused up front
byfluree-db-cli/src/detect.rs:94("'trig' is a dataset format and carries named graphs, which
insert cannot place"), where at6b63e64b3fluree upsert -f config.trigcommitted the file. The
refusal's help points atfluree create <ledger> --from <file>.trig, which cannot add config to a
ledger that already exists;fluree upsert -f config.trig --format turtlestill works and places
the named graph correctly.docs/transactions/turtle.md:513still says "Named-graph blocks are
read byfluree upsert -f file.trig", which the extension check now refuses — worth a separate
look, but it means the TriG workaround this issue's readers will reach for is no longer the one
the docs describe.
If (1) is judged too large a semantic change — "@graph": "<iri>" as a string-valued key inside a
node object is a Fluree extension, not JSON-LD 1.1, where @graph takes a node or array of nodes —
then the alternative is to refuse a node that carries @graph and has a nested node object without
one, rather than accept a partial write. What should not stay is the current outcome, where the
document is accepted, two of its nine triples are honored, and the ledger ends up less governed than
if the document had never been sent.
Related
3b8136c8d"fix: route named graphs by ledger graph id, not transaction-local numbers" (bplatz,
2026-09-24) — same family, does not fix this. It deletedGraphIdAssignerand the
default_graph_idfield, so templates now carry the graph IRI (TemplateGraph) and transactions
carryTxn::write_graphs; its own commit message lists "SHACL validated staged subjects against
that same wrong graph … so JSON-LD writes to named graphs (local 2 = #config) were effectively
never validated" as one of the bugs it closes. That was the routing of the graph a template
already carried. This defect is one level earlier: the nested templates never get a graph at all,
so there is nothing to route. The renameOption<u64>→Option<Arc<str>>moved the mechanism
without changing it —:1381still falls back to actxfield that only the update-template
wrapper ever sets. Empirically identical before and after: 9 flakes, 2 scoped, forbidden record
commits, at both6b63e64b3and0c5d32c11.5abd39033"fix(transact): a written graph missing from the registry fails the commit" — follow-up
to the above; makes an unresolvable written graph IRI an error instead of a silent drop. Does not
reach this case, because a template with no graph is not an unresolvable graph.fluree-db-api/tests/it_config_graph.rsgained 154 lines in3b8136c8d, including a test named
config_write_json_ld. It writes TriG. Every config-write test in that file writes TriG with an
explicit IRI on every node, which is the shape that works; the nested-anonymous-object JSON-LD
shape the docs prescribe is not covered.- fluree export --format trig / --format nquads omit named graphs entirely #1847 (open) —
fluree export --format trig/--format nquadsomit named graphs. Different
end of the pipe and deliberately out of scope here: that one is triples that have a graph and lose
it on the way out, this one is triples that never get a graph on the way in. Its silent form is gone
at0c5d32c11— the export warns and--all-graphscarries the graph — so what is left of it is
the opt-in default, not data loss. Kept separate for that reason; if a maintainer reads the two as
one defect, this is the half that lives inparse/jsonld.rs. - security: f:policySource enforced on reads but ignored on writes (modify paths hardcode default graph) #1416 (closed) —
f:policySourceenforced on reads but ignored on writes (modify paths hardcode the
default graph). Closest neighbour: a config-graph setting that silently fails to take effect.
Different mechanism — that one is the write path hardcodingg_id = 0, this one is the parser not
propagating a node-level@graphinto nested nodes. - Ledger-configured f:defaultAllow false does not apply to requests carrying no policy inputs (and reads/writes disagree) #1640 (closed) — ledger-configured
f:defaultAllow falsenot applying to requests carrying no
policy inputs. The other shape of "the config graph was read and still did not govern", reached
through gate ordering rather than graph scoping. Worth reading beside this one because it poses the
same question directly: whether a ledger's own declared posture should be escapable — there by a
request that says nothing, here by a JSON-LD spelling. - Branch merge/rebase/revert commit without SHACL validation — a merge silently writes state the ledger's own shapes reject #1782 (closed) / Validate SHACL rules on merge operations #1822 (merged) — merge/rebase/revert committing without SHACL validation. Shares the
symptom (a ledger ends up in a state its own shapes reject, silently) but not the cause; Validate SHACL rules on merge operations #1822 fixed
that path. - Bulk TriG import persists reserved-graph triples into an unreachable graph id #1846 (closed) — bulk TriG import persists reserved-graph triples into an unreachable graph id.
Adjacent: also triples that are committed but not where the reader looks, on the TriG import path
rather than the JSON-LD one. - The API-side symptom is written up separately in a solo draft (
issue-solo-success-for-a-noop.md,
item 4): the transaction routes return the engine's commit envelope verbatim, sostatus: success
with atis a statement about the commit and never about whether the config was ingested.
🤖 Generated with Claude Code
Activity
transact: one lexical graph scope for JSON-LD templates
tests: JSON-LD graph scope end to end, with SPARQL twins
api: config reader normalization + diagnostics
api: explicit-only SHACL posture
api: staged config guard, merged with the reasoning-mode check
docs: graph scoping, explicit-only SHACL, config checks and recipes
api: the config guard refuses a group split across transactions
merge/rebase/revert: re-check the target's config groups