Skip to content

A branch of a never-indexed ledger ignores its source's ledger config: configured policy fails open, uniqueness is off #2069

Closed

Description

@bplatz

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

  1. Create mydb and insert ex: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.
  2. 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 .
    }
    
  3. Run create_branch("mydb", "dev", None, None) without building an index on main.
  4. Run {"select": ["?s"], "where": {"@id": "?s", "ex:name": "?n"}} through fluree.graph(..).query():
    • mydb:main: 0 rows
    • mydb:dev: 1 row
  5. Build and publish an index for dev (rebuild_index_from_commits over branched_content_store). dev still returns 1 row.

Cause (from reading the code)

  • A commit lists the system graphs it writes in its graph_delta by full IRI. The comment in fluree-db-transact/src/commit.rs reads "System graphs stay listed". So main's config commit records urn:fluree:mydb:main#config.
  • Loading dev with no index replays from genesis:
    • Its registry is seeded for the branch (GraphRegistry::new_for_ledger), so the config slot (g_id 2) is urn:fluree:mydb:dev#config.
    • The replay collects every graph_delta IRI (fluree-db-ledger/src/lib.rs, all_graph_iris) and registers urn:fluree:mydb:main#config as a new user graph.
  • 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 main is 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

  1. added
    bug
    P1
    area:transact
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:transactbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions