Each document is an ordered sequence of RangeElements stored in a BTree. Elements are content-addressed via BLAKE3 fingerprints.
Text("quick brown fox")
fp: blake3 → 0xa3f7...
BeId: 1002 (shared)
How O-tree, H-tree, and Canopy work together for O(log n) transclusion queries
Each document is an ordered sequence of RangeElements stored in a BTree. Elements are content-addressed via BLAKE3 fingerprints.
Text("quick brown fox")
fp: blake3 → 0xa3f7...
BeId: 1002 (shared)
Editions are linked into a version DAG. Each node (crum) carries metadata about its subtree. Traversal walks parent↔child edges to find transclusion relationships.
Each H-tree node carries a bitmap of endorsement types (Text=1, Link=2, Blob=4...). The canopy merges these bitmaps upward so a parent's flags are the union of all children's flags. During traversal, if a parent's flags don't include the type you're looking for, skip the entire subtree.
| Operation | Naive | Xudanu (optimized) | How |
|---|---|---|---|
| Find works containing text | O(W × L) | O(U × A) | Fingerprint intersection: U = unique chars, A = avg works per char. HashMap lookup, no scan. |
| Find shared regions (diff) | O(n × m) | O(La + Lb) | Fingerprint HashMap for seed discovery, then greedy longest-first claiming. |
| Edition element listing | O(n log n) every call | O(1) after first | OnceLock cache on Edition struct. Shared via Arc on clone. |
| Transclusion index lookup | O(n) flat scan | O(log n) | H-tree canopy-filtered traversal. Flag bits prune entire subtrees. |
| Shared region highlighting | O(r × t) | O(r + t) | Sorted regions, single pass through text. No nested loops. |
This is the same insight behind Git (content-addressed objects), IPFS (content-addressed storage), and modern databases (hash indexes). Udanax Gold had it in the 1990s — just without BLAKE3.