Repository navigation
Description
Summary
A branch created from a ledger that has no index yet reads none of its source's ledger config. Nothing reports it, and indexing the branch afterwards doesn't fix it. Verified on main at c5874d586, memory storage:
Setting on mydb:main |
On main |
On mydb:dev |
|---|---|---|
Configured policy (f:policyDefaults → f:policyClass with a rule hiding ex:name) |
name hidden | name visible (fail-open) |
Same, after indexing dev |
name visible | |
Uniqueness (f:transactDefaults → f:uniqueEnabled true, ex:email f:enforceUnique true) |
duplicate refused | duplicate accepted |
SHACL with f:validationMode f:ValidationWarn |
violation committed with a warning | violation refused: the warn setting is ignored, and the shapes-exist fallback rejects |
On the branch, fluree.db("mydb:dev").ledger_config() has no policy group. Branching from a ledger that has an index keeps the config, even when the config was written after the last index build.
Reproduction
- Create
mydband insertex:alice ex:name "Alice"plus a rule:ex:hideNames a f:AccessPolicy, ex:ConfiguredPolicy ; f:action f:view ; f:onProperty ex:name ; f:allow false. - Upsert the config:
GRAPH <urn:fluree:mydb:main#config> { <urn:cfg:main> a f:LedgerConfig ; f:policyDefaults <urn:cfg:policy> . <urn:cfg:policy> f:defaultAllow true ; f:policyClass ex:ConfiguredPolicy . } - Run
create_branch("mydb", "dev", None, None)without building an index onmain. - Run
{"select": ["?s"], "where": {"@id": "?s", "ex:name": "?n"}}throughfluree.graph(..).query():mydb:main: 0 rowsmydb:dev: 1 row
- Build and publish an index for
dev(rebuild_index_from_commitsoverbranched_content_store).devstill returns 1 row.
Cause (from reading the code)
- A commit lists the system graphs it writes in its
graph_deltaby full IRI. The comment influree-db-transact/src/commit.rsreads "System graphs stay listed". Somain's config commit recordsurn:fluree:mydb:main#config. - Loading
devwith no index replays from genesis:- Its registry is seeded for the branch (
GraphRegistry::new_for_ledger), so the config slot (g_id 2) isurn:fluree:mydb:dev#config. - The replay collects every
graph_deltaIRI (fluree-db-ledger/src/lib.rs,all_graph_iris) and registersurn:fluree:mydb:main#configas a new user graph.
- Its registry is seeded for the branch (
- So the source's config lands in an ordinary named graph, and the config reader, which reads slot 2, finds nothing. Querying the branch confirms it:
GRAPH <urn:fluree:mydb:main#config> { ?s ?p ?o }returns main's config triples as user data.GRAPH <urn:fluree:mydb:dev#config>returns nothing.
- Probably why an indexed source is fine: the branch inherits the index root, whose graph table maps slot 2 to the source's config IRI, so the replayed novelty lands in slot 2.
The txn-meta graph (slot 1) probably has the same problem. Not tested.
Impact
- Policy fails open: data that a configured policy hides on
mainis readable on such a branch. - Uniqueness is not enforced on the branch.
- SHACL settings are ignored. Today the shapes-exist fallback still enforces in reject mode. Under fix: JSON-LD graph scoping, config integrity and explicit-only SHACL #2009 (SHACL enforced only where config enables it), SHACL would be off entirely on these branches.
- Which branches are affected: any branch created before its source's first index build, which is typical for agent-style workflows that branch a fresh dataset.
Possible fix
During replay, read an ancestor ledger's system-graph IRIs (urn:fluree:<source>#config, #txn-meta) as the reserved slots rather than registering them as user graphs. The branch knows its ancestry. Alternatively, record system graphs in graph_delta by slot rather than by branch-qualified IRI.
Existing branches already hold the source's config as a user graph, so a fix also needs a migration, or a read-time fallback, for them.
Activity
Test: branch merge checks no longer rely on a branch reading no config
Config: a copy or branch reads its source's config graph
Config: a copy or branch reads its source's config graph