Skip to content

feat(core)!: a new ledger files an IRI ending in a delimiter under the namespace before it - #2422

Merged
bplatz merged 10 commits into
nextfrom
feat/ns-split-named-local
Nov 19, 2026
Merged

bplatz merged 10 commits into
nextfrom
feat/ns-split-named-local

Conversation

@bplatz

@bplatz bplatz commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2429.

Partially addresses #2135. What remains: measuring a BSBM 100M import under the new mode against MostGranular. #2135 also asks whether to widen namespace ids, which this does not decide.

Under MostGranular, an IRI ending in /, # or : is the whole prefix of a namespace of its own, with an empty local name. A page address per entity is then a namespace per entity. In BSBM 100M, offer-webpage IRIs (…/dataFromVendorN/OfferN/) took about 54,200 of the 65,521 user codes during import. The producers, vendors and rating sites that share real prefixes then found the table full, and 95.6% of subjects were stored under OVERFLOW with their whole IRI as their name. Without those prefixes the dataset has about 17,300, which fit.

What changes

NsSplitMode::NamedLocal, the mode new ledgers split under. It behaves like MostGranular, except that an IRI ending in a delimiter splits at the delimiter before it, so no local name is empty:

IRI MostGranular NamedLocal
http://ex.com/v7/Offer12 http://ex.com/v7/ + Offer12 same
http://ex.com/v7/Offer12/ http://ex.com/v7/Offer12/ + (empty) http://ex.com/v7/ + Offer12/
http://ex.com/onto# http://ex.com/onto# + (empty) http://ex.com/ + onto#
urn:a:b: urn:a:b: + (empty) urn:a: + b:

A built-in namespace's own IRI (http://www.w3.org/2001/XMLSchema#) keeps its code. The split looks for one only in an IRI ending in /, # or :, since every built-in prefix but @ (handled separately) ends in one.

Which ledgers get it.

  • NsSplitMode::FOR_NEW_LEDGERS is NamedLocal. LedgerSnapshot::genesis and NamespaceRegistry::new (a bulk import's registry) start under it, and the ledger's first commit declares it.
  • An existing ledger keeps the mode its first commit declared, whether it is loaded from commits or from an index root. Every first commit has declared one since 4.0.
  • The snapshot that compiles inline SHACL shapes stands in for an existing ledger, so it takes that ledger's mode (LedgerSnapshot::genesis_with_split_mode).

Persistence. The index root stores the mode as one byte, NamedLocal as 0xFF, which once meant HostPlusN(254); no release wrote a HostPlusN above 1, the value the bulk-import preflight selects. HOST_PLUS_N_MAX is now 253.

In the first commit's envelope, 0xFF is an escape followed by an extended mode id, 0x00 for NamedLocal. Every 4.x decoder reads any nonzero mode byte as HostPlusN(n-1), so it would read a bare 0xFF as HostPlusN(254), replay the ledger, and encode every new IRI differently from it: constant lookups would find nothing, and its writes would give existing IRIs a second identity. With the escape, a 4.x decoder refuses the id after it as a trailing byte, so it refuses the ledger's first commit and with it the ledger. An extended id this release does not know is refused too, so a later mode gets the same refusal without another format change. 4.x already refuses a v5 root, so the root needs no escape. The behavior change is in docs/reference/compatibility.md.

The indexer encodes predicates as the write path does (first commit).

  • The indexer derived each predicate's SID, for the root's predicate table and for the property statistics, by the longest registered prefix of its IRI.
  • Under NamedLocal that differs from the canonical split for a predicate ending in a delimiter whose own text is also a registered prefix: …/ns/tag/ came out as (…/ns/tag/, ""), not (…/ns/, "tag/").
  • The planner found no statistics for such a predicate and estimated it at zero rows.
  • The full build, the incremental build and graph import now encode through StatsIriEncoder, the encoder the planner reads statistics with.
  • Answers were not affected: the store rebuilds predicate IRIs from the root and re-encodes them.

The bulk-import preflight counts prefixes as a new ledger splits.

  • Before a bulk import parses, the preflight samples the file and counts distinct prefixes. Past the budget it switches the new ledger to HostPlusN(1).
  • It counted an IRI ending in a delimiter as a prefix of its own, the MostGranular rule. A file whose sample windows held page IRIs therefore fell back to HostPlusN(1), although it fits under NamedLocal, so whether such data got the new mode depended on where its page IRIs sat in the file.
  • It now counts as NamedLocal splits. The preflight chooses only a new ledger's mode, so that is the rule to count by. The turtle crate does not depend on fluree-db-core, so the scanner keeps its own copy of the rule.

Tests

  • it_named_local_split (grp_misc) runs a new ledger and a ledger whose first commit declares MostGranular through the same steps:

    • write;
    • reload from commits;
    • a full rebuild;
    • an incremental build over it.

    At each step it checks the mode, the namespace table, a page IRI found as object and as subject (SPARQL and JSON-LD), and the statistics of a predicate ending in /.

  • Each fails when its change is undone: the new-ledger default, replay taking the declared mode, and the mode given to either index build's encoder.

  • ns_encoding unit tests cover the split table, every built-in namespace's own IRI, the byte round-trip, and the bytes earlier releases wrote.

  • Envelope codec tests pin NamedLocal's escape and id, check that MostGranular and HostPlusN keep their single byte, and refuse an unknown extended id.

  • A splitter test feeds a preflight window of page IRIs, which stays under the budget, and one of as many distinct namespaces, which still exceeds it.

  • The codec, splitter and built-in tests each fail with their change undone.

Not in this PR

@bplatz bplatz added enhancement New feature or request breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section area:storage Storage backends, nameservice, ledger lifecycle, index storage, caches labels Nov 16, 2026
The indexer derived each predicate's SID, for the root's predicate table
and for the property statistics, by the longest registered prefix of its
IRI. The write path and the planner split an IRI canonically under the
ledger's split mode and look the prefix up exactly. Where the two differ,
the planner finds no statistics for the predicate and estimates it at
zero rows.

The full build, the incremental build and a graph import now encode
through `StatsIriEncoder`, the encoder the planner reads the statistics
with, built from the namespace table and the ledger's split mode.
…e namespace before it

Under `MostGranular`, an IRI that ends in `/`, `#` or `:` is the whole
prefix of a namespace of its own. A page address per entity is then a
namespace per entity: in BSBM 100M those took about 54,200 of the 65,521
user codes, and 95.6% of subjects went to OVERFLOW with their whole IRI
as their name.

`NsSplitMode::NamedLocal` splits such an IRI at the delimiter before it
(`…/Offer12/` is `…/` + `Offer12/`), so no local name is empty. A
built-in namespace's own IRI keeps its code. It is
`NsSplitMode::FOR_NEW_LEDGERS`: a new ledger, and a bulk import into
one, starts under it and declares it in its first commit. An existing
ledger keeps the mode its first commit declared, as every first commit
has since 4.0. A snapshot standing in for an existing ledger's, for
inline SHACL shapes, takes that ledger's mode.

The mode persists as byte 0xFF, which once meant `HostPlusN(254)`; no
release wrote a `HostPlusN` above 1. `HOST_PLUS_N_MAX` is now 253.

@aaj3f aaj3f 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.

@bplatz this is a nice, narrow answer to the BSBM overflow (Claude's page-IRI import A/B ran 8.8× faster), and the first commit's encoder fix stands on its own. I'm on board with new ledgers taking NamedLocal; one decision I'd like on the record is below, with an ask that the compatibility entry say how to move an existing ledger over.

The one thing I don't think should merge as-is is how the mode persists: Claude published a ledger from this branch to a v4.2.7 server, which accepted it, answered IRI-constant queries with nothing, and on its next write gave an existing IRI a second identity that survives upgrading back. Your DROP commits and v5 roots refuse on 4.x rather than misread; a guard byte in the NamedLocal envelope would do the same. Details below:

Full review below:


✅ Approving to unblock: please get the 4.x refusal (a guard byte in the NamedLocal envelope, plus its compatibility entry) in before merging. The split is narrow and holds up everywhere Claude pushed on it: the PR's own tests go red under each mutation the body lists, and the page-IRI import is 8.8× faster with a third less storage. The one must is a few lines.

Before merging:

  1. fluree-db-core/src/ns_encoding.rs:81: make a commit that declares NamedLocal refuse on 4.x, and add the Behavior-changes entry.

Decisions on the record: My reading is that every ledger created from here on splits under NamedLocal and every existing one keeps its declared mode for good, so a ledger that has already overflowed only gets the new split through an export and re-import. I think that makes sense, but I'd like your confirmation that it's the intended decision. With that said, I'd recommend the compatibility entry from the must above say how to move an existing ledger over: export it, then import into a new ledger.

Notes:

  • This PR's first commit is another instance of a class: an IRI→SID encoder that disagrees with the write path's. The others are #2413 (a constant IRI encodes to EMPTY where a full table stores OVERFLOW), #1891 (build_reverse_graph keys graph SIDs with encode_iri) and #1842 (bound-IRI lookups miss overflow subjects).
    • Class fix: one encoder, built from both inputs that decide it (split mode and table-full), that every reader takes. encode_registered with #2413's table_full argument is most of it.
    • Still open-coded at this head: BinaryIndexStore::encode_iri, find_subject_id, find_subject_sid and the datatype table (binary_index_store.rs:2468, 2682, 2697, 4307), and bulk import's predicate_sids_v6 (import.rs:7354).
    • Not for this PR. The point fixes are right here.
  • When main merges into next, #2413 and this PR meet in StatsIriEncoder. The file merges clean but doesn't compile (E0063): #2413 adds table_full, and from_namespace_codes here doesn't set it. The merge needs table_full: false there, with a comment saying why. Taking fullness from the codes would make the builders write OVERFLOW predicate SIDs into the root, which build_dictionary_set refuses at load: Claude ran #2413's it_overflow_iri_bound_lookups on the merged tree, and it fails with unknown ns_code 65534. With false, #2413's load-time re-key turns (0, iri) into (OVERFLOW, iri), so the planner still finds full-table predicates.
  • A few lines no test pins, by mutation:
    • The incremental build's build_predicate_sids mode: harmless, because the store decodes the root's predicate table back to IRIs (binary_index_store.rs:4167-4176).
    • Both inline-SHACL genesis_with_split_mode calls: reverting either passes all 18 it_shapes_inline tests. A test would be contrived, since the stand-in only re-encodes IRIs it can't hold codes for, so a comment saying why would do.
    • commit_subject.rs:111-115: checks "every split mode" without NamedLocal.
Adherence: Patterns ✔ · Performance ⚠️ · Deployment targets ⚠️ · Testing ✔ · Conventions ⚠️ · verification
  • Patterns/abstractions: ✔ The new mode goes through the existing NsSplitMode / canonical_split. The indexer moves onto StatsIriEncoder, the encoder the planner already reads with, rather than gaining a third.
  • Performance (speed first, memory second): ⚠️ Big end-to-end win on page-IRI data: import 27.20 s → 3.09 s median, store 77.7 MB → 52.0 MB. Import of data the two modes split identically is flat (1.006). NamedLocal's split is +55% per call in isolation, and a one-line guard removes it (inline). No regression for existing ledgers.
  • Deployment targets: ⚠️ Pure computation in fluree-db-core, and CI's wasm32 and wasm-smoke passed at this head. The exposure is version skew rather than a host fence: a 4.x host handed the commits misreads them. Publish was run; a 4.x clone, a mixed cluster and a 4.x browser peer are by reading.
  • Testing: ✔ it_named_local_split goes red under each change the body lists (Claude reverted the new-ledger default, replay's declared mode and both index builds' stats encoder mode), and the split table has unit tests. The inline-SHACL stand-ins are not pinned (Notes).
  • Conventions: ⚠️ Multi-line commits; the ! and the breaking-change label are right; the body uses "Partially addresses #2135" as CLAUDE.md asks. A breaking storage change still needs its Behavior-changes entry in docs/reference/compatibility.md.

Verified at 9194b0159:

  • CI run 44076756965 green, 17,590 tests passed.
  • On a box: the PR's targeted tests at head, and nine mutations (six killed, three survivors explained).
  • v4.2.7 against this head's ledgers: shared store refused; publish misread; the upgrade back keeps the split identity.
  • A five-rep release import A/B against df486db37, a canonical_split microbench with and without the guard, and both preflight orders.

Approving so you can merge once the refusal is in. The rest are small notes we should probably accommodate.

/// release ever wrote a `HostPlusN` above 1.
pub const HOST_PLUS_N_MAX: u8 = 253;

const NAMED_LOCAL_BYTE: u8 = 0xFF;

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.

Blocking. A 4.x binary that is handed this ledger's commits takes them without complaint and encodes every new IRI differently from the ledger. It answers IRI-constant queries with nothing, and its next write gives an existing IRI a second identity, which survives upgrading back.

Every 4.x NsSplitMode::from_byte maps a nonzero byte to HostPlusN(n-1) (fluree-db-core/src/ns_encoding.rs:91-96 at v4.2.7), so 0xFF reads as HostPlusN(254). That mode counts up to 254 path segments past the host, which for nearly any IRI is the whole IRI, so the canonical prefix is never a registered one. On a shared storage directory, next's ns@v3/ nameservice already keeps a 4.x binary from finding the ledger at all. Claude checked: v4.2.7 reports ledger 'shop' not found. But nothing in the commit itself refuses, so any path that hands 4.x the commits gets through.

Claude ran it on a box (logs in the review folder):

  1. The CLI built from this head creates a ledger, inserts offer/page/tag triples modeled on it_named_local_split's, and fluree publishes it to a v4.2.7 server. The CLI reports "✓ Published 'shop:main' to 'v4' (1 commit(s), remote head t=1)".
  2. The v4.2.7 server answers SELECT ?s ?p ?o with all 5 rows. It answers SELECT ?p ?o WHERE { <http://example.com/vendor7/Offer12> ?p ?o } with 0 rows (3 expected), and the page-title query with 0 rows (1 expected). A ledger that same server creates itself, with the same triples, answers 3 and 1.
  3. A v4.2.7 insert of <…/Offer12> ex:price 11 commits. After it, GROUP BY ?s lists …/Offer12 twice, with counts 3 and 1.
  4. The server built from this head then serves the same store, i.e. the upgrade back. The constant query returns the 3 original facts and not price 11, and GROUP BY ?s still lists …/Offer12 twice.

Publishing from an upgraded CLI to a server that hasn't upgraded yet is an ordinary order of operations. The same decoder would also be reached by a 4.x clone/pull from a 5.0 server, a cluster mid-upgrade, or a browser peer pinned to a 4.x @fluree/db-wasm once #2423 publishes it; those are by reading, not run. The body's reason for next names exactly this risk, but targeting next decides which release ships the mode. It doesn't make 4.x refuse a ledger that uses it.

Your DROP commits already refuse on an earlier release rather than misread (docs/reference/compatibility.md:495), and main refuses a v5 root outright (fluree-db-binary-index/src/format/index_root.rs:204-208). The same can hold here cheaply. Every 4.x envelope decoder since 4.0.0 fails on bytes past its last field (envelope.rs:384 at v4.2.7), so one guard byte after the mode byte, written only for NamedLocal, makes every 4.x path refuse the genesis commit:

// fluree-db-core/src/commit/codec/envelope.rs, encode_envelope_fields
if let Some(mode) = envelope.ns_split_mode {
    buf.push(1);
    buf.push(mode.to_byte().map_err(/* as today */)?);
    // 4.x reads 0xFF as HostPlusN(254). One byte past its last field makes
    // every 4.x decoder refuse the commit ("trailing bytes") instead.
    if mode == NsSplitMode::NamedLocal {
        buf.push(NAMED_LOCAL_GUARD);
    }
}

Then the decoder reads and checks the guard after a NamedLocal mode byte, and a codec test pins that a NamedLocal envelope ends with it. Bumping the commit header version for that one commit would also work, but it touches more (the replacement codec checks VERSION). The Behavior-changes entry in docs/reference/compatibility.md can borrow the DROP entry's words: "A ledger created by this release cannot be read by an earlier one, which refuses it rather than reading new IRIs differently from the ledger. A ledger created earlier is unchanged." The embedder notes fit in the same entry: genesis() and NamespaceRegistry::new() now split under NamedLocal, NsSplitMode gains a variant, and HOST_PLUS_N_MAX is 253. (Commenting here because fluree-db-core/src/commit/codec/envelope.rs and docs/reference/compatibility.md are not in this diff.)

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.

Addressed in 496a5eb and 58d20ad (design doc). The byte after 0xFF is an extended mode id rather than a bare guard: 0xFF in the envelope is an escape, NamedLocal is extended id 0, and an id the decoder doesn't know is refused, so a later mode gets the same 4.x refusal without another format change.

Comment thread fluree-db-core/src/ns_encoding.rs Outdated
}
}

if mode == NsSplitMode::NamedLocal && is_builtin_namespace_iri(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.

Optional (perf). This is more of a cheap fix than a concern. Under NamedLocal, is_builtin_namespace_iri walks the built-in trie for every IRI before the split, though only an IRI ending in a delimiter can equal a built-in prefix.

Every built-in prefix ends in /, # or : (namespaces.rs's default_namespace_codes; @ is handled above this line, and the trie never holds the empty prefix). Claude timed canonical_split in a release build over a BSBM-shaped mix of 1.4M IRIs: NamedLocal costs about 45 ns more per call than MostGranular in the same binary (126.3 vs 81.0 ns median, +55%). With the guard below, it drops to 84.4–85.9 vs 81.0–81.8 ns over two runs, and the ns_encoding unit tests stay green. MostGranular itself is unchanged from base (61.0–64.8 vs 58.2–61.8 ns, layout noise). I don't think this shows end to end: the import A/B on data the two modes split identically was flat (3.22 s vs 3.20 s median, five reps each). But it is on every IRI of every write and import, and the fix is one line:

Suggested change
if mode == NsSplitMode::NamedLocal && is_builtin_namespace_iri(iri) {
if mode == NsSplitMode::NamedLocal
&& matches!(iri.as_bytes().last(), Some(b'/' | b'#' | b':'))
&& is_builtin_namespace_iri(iri)
{

It's minor and non-blocking, but if you agree it's right, I'd rather see it folded in now than lost in the backlog.

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.

Addressed in 4bb6189

Comment thread docs/design/namespace-allocation.md Outdated

1. `StreamingTurtleReader` samples bounded byte windows (`NS_PREFLIGHT_WINDOW_SIZE`, 8 MiB) within
the first chunk region and counts distinct prefixes under the default `MostGranular` split.
the first chunk region and counts distinct prefixes under the `MostGranular` split.

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.

Optional. The bulk-import preflight still counts the prefixes MostGranular would make. So a file whose page IRIs land in one of its sample windows imports under HostPlusN(1), not NamedLocal, and the data this PR exists for is the data most likely to miss it.

NsWindowScanner::feed (fluree-graph-turtle/src/splitter.rs:1646) takes "last / or #, inclusive" as each IRI's prefix, so …/Offer12/ counts as a prefix of its own. Past NS_PREFLIGHT_BUDGET (255), the forwarder sets HostPlusN(1) before chunk 0 parses (fluree-db-api/src/import.rs:4979-4983). The preflight's answer only matters for a new ledger (split_mode_fixed = seed.is_some(), import.rs:4968), and a new ledger now always starts under NamedLocal. So the count that decides is the NamedLocal one.

Claude checked both orders of the same 1,431,300 triples with this head's CLI (--verbose, --chunk-size-mb 32). With offers first, the first sample window holds 6,575 prefixes by the scanner's rule and 236 by NamedLocal's, and the import logged "namespace preflight exceeded budget; enabling HostPlusN(1) split mode". The ledger took 95.3 MB on disk. With offers last, the preflight passed, and the A/B's runs of that order stored 52.0 MB under NamedLocal. So whether a page-heavy import gets the new mode depends on where its page IRIs sit in the file.

The fix is a few lines in the scanner: when the IRI ends in a delimiter, back off to the one before it, as granular_split_pos does. A sketch:

let is_delim = |c: &u8| *c == b'/' || *c == b'#';
let split = self.iri_buf.iter().rposition(is_delim).map(|last| {
    if last + 1 == self.iri_buf.len() {
        // NamedLocal: an IRI ending in a delimiter files under the one before it.
        self.iri_buf[..last].iter().rposition(is_delim).unwrap_or(last)
    } else {
        last
    }
});

Then this line can say NamedLocal. A splitter unit test with a window of page IRIs under the budget would pin it. I recognize the body lists this under "Not in this PR", and HostPlusN(1) is still a correct outcome, so this is non-blocking. But the fix is small and it decides whether BSBM-shaped imports get the new mode at all, so if you agree it's right, I'd rather see it folded in now than lost in the backlog. (Commenting here because fluree-graph-turtle/src/splitter.rs is not in this diff.)

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.

Addressed in df4aafc

bplatz added a commit that referenced this pull request Nov 18, 2026
Brings #2413.

`display_name` in the Cypher procedures keeps next's `rdf:reifies`
guard and takes main's `decode_sid`, so the catalogs name an overflow
class or predicate on next too. next has no other hand-rolled Sid
decoders beyond the ones main replaced.

`StatsIriEncoder` has only the snapshot constructor on next. #2422,
still open against next, adds one for an index root's predicate
table; that constructor must set `table_full: false`, since a root
never stores OVERFLOW predicate Sids and the store refuses to load
one.
next gave StatsIriEncoder a table_full flag, set only by a snapshot's
encoder. This branch's from_namespace_codes builds the encoder that keys
an index root's predicates, which never stores OVERFLOW, so it leaves
the flag false.
A ledger's first commit declares its split mode in one byte, and
NamedLocal took 0xFF. Every 4.x decoder reads any nonzero byte as
HostPlusN(n - 1), so it read 0xFF as HostPlusN(254) and replayed the
commits without complaint. The stored facts read back, but every IRI it
encoded afresh, in a query or a write, split differently from the
ledger's: constant lookups found nothing, and a write gave an existing
IRI a second identity that stays in the commits.

In the envelope, 0xFF is now an escape: the mode is an extended id in
the next byte, and NamedLocal is extended id 0. A 4.x decoder still
reads the escape as the mode and then refuses the id after it as a
trailing byte, as every 4.x envelope decoder does, so publishing, cloning
or replicating such a ledger to 4.x fails on its first commit. An
extended id this decoder does not know is refused too, so a later mode
gets the same refusal from this release without another format change.
MostGranular and HostPlusN keep their single byte, and the index root
and the in-memory registry keep 0xFF for NamedLocal: 4.x refuses a v5
root already.

The compatibility notes gain the behavior change: what a new ledger does
differently, that an earlier release refuses it, that an existing ledger
keeps its encoding and moves over by export and import, and what
changes for embedders.
Under NamedLocal, canonical_split walked the built-in prefix trie for
every IRI before splitting it, to keep a built-in namespace's own IRI as
its namespace. Every built-in prefix but `@`, which is handled before
this check, ends in `/`, `#` or `:`, so only an IRI ending in one of
those can be one. The walk now runs only for those: it had made the
NamedLocal split about half again as slow as MostGranular's per call.

A test splits every built-in prefix's own IRI under NamedLocal, so a
built-in prefix ending in anything else fails it rather than splitting
silently.
…splits

Before a bulk import parses its first chunk, the preflight samples the
file and counts distinct namespace prefixes, and past the budget it
switches the new ledger to HostPlusN(1). It counted each IRI's prefix
through its last `/` or `#`, the MostGranular rule, so a page IRI such
as `…/vendor7/Offer12/` counted as a namespace of its own. A new ledger
splits under NamedLocal, which files that IRI under `…/vendor7/`, so a
file whose sample windows held page IRIs exceeded the budget and fell
back to HostPlusN(1), though it would have fit: whether page-heavy data
got NamedLocal depended on where in the file its page IRIs sat.

The preflight now counts an IRI ending in a delimiter under the one
before it, as NamedLocal does. Only a new ledger's mode is chosen by the
preflight, so that is the mode to count by. A test feeds a window of
page IRIs, which stays under the budget, and one of as many distinct
namespaces, which still exceeds it.
The namespace-allocation design described the split mode as one byte in
both the first commit's envelope and the index root, with 0xFF for
NamedLocal. The envelope now writes 0xFF as an escape followed by an
extended mode id, so that a 4.x decoder refuses the commit. The design
says so, and why the index root keeps the single byte.
…l too

The test that a commit's subject IRI splits at the fluree URN namespace
under every split mode listed MostGranular and two HostPlusN modes, but
not NamedLocal, the mode every new ledger now takes.
…s mode

Inline shapes compile against an empty genesis snapshot standing in for
the ledger's. genesis() takes a new ledger's split mode, NamedLocal, so
both stand-ins are built with the ledger's own mode instead: the
stand-in must encode an IRI as the ledger does. Nothing pins that in a
test, since the stand-in holds only the built-in namespace codes and a
test would have to contrive an IRI whose split differs, so the two call
sites now say why.
@bplatz

bplatz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

make a commit that declares NamedLocal refuse on 4.x, and add the Behavior-changes entry

Addressed in 496a5eb (envelope and compatibility entry) and 58d20ad (design doc); details on the thread.

every ledger created from here on splits under NamedLocal and every existing one keeps its declared mode for good … I'd like your confirmation

Confirmed. The compatibility entry in 496a5eb says an existing ledger keeps its encoding and moves over by export and import into a new ledger.

The merge needs table_full: false there, with a comment saying why.

Addressed in 917b34a. The field's doc on next gives the reason: a root's predicate table never stores OVERFLOW.

commit_subject.rs:111-115: checks "every split mode" without NamedLocal.

Addressed in 780d7d7

Both inline-SHACL genesis_with_split_mode calls … a comment saying why would do.

Addressed in 50d4787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:storage Storage backends, nameservice, ledger lifecycle, index storage, caches breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants