Skip to content

Reject trie nodes that exceed the branch-count limit - #141

Merged
mcculls merged 1 commit into
mainfrom
mcculls/trie-branch-limit
Oct 19, 2026
Merged

mcculls merged 1 commit into
mainfrom
mcculls/trie-branch-limit

Conversation

@mcculls

@mcculls mcculls commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Does This Do

Reject adding a 32,768th branch to a trie node before modifying its data. Existing branches can still be overwritten or extended at the limit.

Motivation

A branch count of 32,768 sets the leaf-marker bit. When that node follows a segment, lookup mistakes it for a leaf and existing mappings become unreadable.

Additional Notes

Use the literal MAX_NODE_BRANCHES = 32767 limit. The regression test verifies byte-for-byte preservation after rejection, existing mappings, and valid overwrites and extensions. Reuse a serialization helper in the rejection tests.

Stack (merge in order):

  1. Capacity checks
  2. Long-jump table growth
  3. Builder isolation
  4. Unicode segments
  5. Empty-trie generation
  6. Branch-count limit (this PR)

This PR targets mcculls/trie-empty-generation.

Contributor Checklist

  • All 86 trie tests and the Java formatting check pass.

@mcculls
mcculls force-pushed the mcculls/trie-empty-generation branch from 19d2d70 to a1d650a Compare October 19, 2026 16:48
Base automatically changed from mcculls/trie-empty-generation to main October 19, 2026 16:53
Limit nodes to 32767 branches so their counts cannot be mistaken for
leaf markers after a segment. Reject an additional sibling before
modifying trie data, while allowing existing branches to be updated
or extended.

Add regression coverage for rejected insertions preserving serialized
data and mappings, and reuse a serialization helper in rejection tests.
@mcculls
mcculls force-pushed the mcculls/trie-branch-limit branch from 82fa3b5 to 27cb029 Compare October 19, 2026 16:54
@mcculls
mcculls merged commit 5d94d50 into main Oct 19, 2026
6 checks passed
@mcculls
mcculls deleted the mcculls/trie-branch-limit branch October 19, 2026 16:58
@github-actions github-actions Bot added this to the 0.1.0 milestone Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants