Transclusion Engine

How Xudanu detects, indexes, and queries content reuse across documents — the core intellectual property inherited from Udanax-Gold, enhanced with BLAKE3 fingerprinting, the Bert Canopy tree, Recorder pub/sub, and the Hoist propagation algorithm.

1. Overview 2. TransclusionIndex — BLAKE3 Content Registry 3. Bert Canopy — Hierarchical Property Tree 4. Recorder System — Publish/Subscribe for Content 5. Recorder Hoist — Incremental Propagation 6. BackfollowEngine — Cross-Document Queries 7. End-to-End Flow 8. Modern Enhancements Over Udanax-Gold 9. Performance Characteristics

1. Overview

Transclusion is Ted Nelson's foundational concept: content is linked, not copied. When the same text appears in multiple documents, the system should know they are the same content, not independent copies.

Xudanu's transclusion engine is a five-layer pipeline:

  1. TransclusionIndex — maps BLAKE3 content fingerprints to the editions containing them
  2. Bert Canopy — a hierarchical tree that indexes content properties for efficient querying
  3. Recorder System — persistent queries ("recordings") that accumulate results over time
  4. RecorderHoister — propagates recorder state incrementally up the canopy tree
  5. BackfollowEngine — given an edition, finds all other editions/works sharing content
TransclusionIndex BLAKE3 → Edition IDs Bert Canopy Hierarchical property tree Recorder System Persistent queries → Fossils Hoist Incremental propagation BackfollowEngine Cross-document transclusion queries API Response TransclusionResult, ContentMatch propagated recorders canopy walk

Figure 1: The five-layer transclusion pipeline. Content fingerprints flow left-to-right; queries flow top-to-bottom.

2. TransclusionIndex — BLAKE3 Content Registry

The TransclusionIndex is the foundation. Every RangeElement in every Edition has a 256-bit BLAKE3 content fingerprint. The index is a HashMap<[u8;32], Vec<EditionId>> that maps each fingerprint to the editions containing it.

Udanax-Gold origin: The original C++ code had a Transclusion class with a similar fingerprint-to-edition mapping, but used a weaker hash. Xudanu replaces this with BLAKE3, which is both faster ( SIMD-optimized) and cryptographically collision-resistant.

TrailBlazer — content-based queries

The TrailBlazer struct wraps the index and provides query methods:

TransclusionQuery / TransclusionResult

A TransclusionQuery specifies what to search for (a specific edition, or all works). The TransclusionResult returns matched works with their fossil_id (from the Recorder), edition_be_id, and whether the match is direct or transitive.

3. Bert Canopy — Hierarchical Property Tree

The Bert Canopy is a binary tree structure where each node ("crum") holds computed property flags for the editions beneath it. This is the key data structure that makes transclusion queries efficient across large corpora.

Root Crum flags: union of all Bert Crum L1 Bert Crum L1 Leaf A Leaf B Leaf C Leaf D Leaf E

Figure 2: The Bert Canopy tree. Leaf nodes hold per-edition property flags. Interior nodes hold the union of their children's flags. The PropFinder can prune entire subtrees when flags don't match.

CanopyCrumData

Each crum contains:

FieldTypePurpose
child1, child2Option<Arc<Mutex<CanopyCrumData>>>Binary tree children
parentOption<Arc<Mutex<CanopyCrumData>>>Upward link for hoisting
flagsu32Computed property bitmask (union of children)
own_flagsu32Flags specific to this node (not inherited)
recordersVec<RecorderId>Persistent queries installed at this node

BertProp — property flags

BertProp is a bitmask computed from an Edition's content. Each bit indicates the presence of a particular content type (text elements, edition references, work references, etc.). The canopy tree propagates these flags upward via compute_join() so a parent crum's flags are the bitwise OR of all descendants.

During a transclusion query, the PropFinder checks a crum's flags before descending. If the sought property bit is not set, the entire subtree is pruned — turning a full-corpus scan into a logarithmic search.

Udanax-Gold origin: The Bert Canopy is directly from the original codebase. "Bert" was the name for backward-edge trackers. The C++ used a Heaper-based object hierarchy; Xudanu replaces this with Arc<Mutex<CanopyCrumData>> for thread-safe shared ownership.

Two canopy types

Bert Canopy

Indexes content properties — what types of elements exist. Used for pruning transclusion queries. Every edition has a Bert crum in the canopy.

Sensor Canopy

Indexes recorder properties — what persistent queries are active. The sensor canopy's IS_SENSOR_WAITING_FLAG indicates whether any recorder in the subtree is still waiting for results.

4. Recorder System — Publish/Subscribe for Content

Recorders are the Udanax-Gold equivalent of persistent database queries. A recorder is "planted" on specific content, and when matching content appears in new editions, the recorder "fires" and accumulates a result (a Fossil).

Key types

TypeRole
RecorderQueryDefines what to search for: Transcluders (editions containing shared content) or Works (works containing shared content). Can include region filters, authority clubs, endorsement filters, and watched content.
FossilThe accumulated results of a recorder. Contains RecordedResult entries, each with the matched element, source edition/work, and whether the match was direct. A fossil can be extinguished (no longer active).
MatcherAn AgendaItem that executes a one-shot query against the transclusion index, feeding results into a fossil.
RecorderTriggerAn AgendaItem that fires when new matching content is detected, recording the result in the fossil.

Recorder lifecycle

  1. Plant: A RecorderQuery is created and installed at a canopy crum. A new Fossil is allocated.
  2. Initial match: A Matcher agenda item runs the query against the current transclusion index, populating the fossil with existing matches.
  3. Watch: The recorder sits in the canopy tree, listening for new content via the sensor canopy.
  4. Trigger: When a new edition is registered and its content matches, a RecorderTrigger fires, adding a new RecordedResult to the fossil.
  5. Extinguish: When no longer needed, the fossil is marked extinct and its recorders are removed from the canopy.
Udanax-Gold origin: The recorder/fossil terminology is directly from the original C++. In Gold, recorders were part of the "Agenda" system for deferred background work. Xudanu preserves this model but adds BLAKE3 fingerprint-based deduplication in Fossil::record().

5. Recorder Hoist — Incremental Propagation

When recorders are installed at leaf nodes of the canopy, they need to be visible to ancestors for efficient querying. The RecorderHoister is an AgendaItem that incrementally propagates recorders upward through the tree.

Two phases

Phase 1: Hoisting

The hoister walks from the current crum upward to the parent. At each step, it removes the recorders from child nodes and installs them at the parent. This continues until the recorders already exist at an ancestor (deduplication) or the root is reached.

Phase 2: Propagating

Once recorders are installed, property flags need to be recomputed upward. The change_canopy() call recomputes flags = own_flags | children.flags at each level, walking to the root.

Why incremental?

A naive approach would recompute the entire canopy on every edition registration. The hoister instead does the minimum work: it only walks the path from the affected leaf to the root, touching O(log n) nodes. For a corpus of 10,000 editions, this means ~13 nodes instead of 10,000.

6. BackfollowEngine — Cross-Document Queries

The BackfollowEngine is the top-level query engine. Given an edition or work, it finds all other works that share content with it.

How it works

  1. Walk the edition's elements and collect their BLAKE3 fingerprints
  2. For each fingerprint, look up the TransclusionIndex to find other editions containing the same content
  3. Use the PropFinder to walk the Bert Canopy, pruning subtrees whose flags don't match the query
  4. For matching canopy leaves, check installed recorders and their fossils
  5. Aggregate results into TransclusionResult structs with work IDs, edition IDs, and match types (direct or transitive)

Query types

QueryReturnsUse case
WorkQuery::ByEdition(id)All works sharing content with the given edition"What documents reuse this content?"
WorkQuery::AllWorksFull cross-reference of all worksDocument Map visualization
RecorderQuery::TranscludersEditions that transclude from the target"Who cited this passage?"
RecorderQuery::WorksWorks containing shared content"Related documents"

7. End-to-End Flow

Here's what happens when a user pastes a transclusion (copies content from Document A into Document B):

1. User pastes content from Doc A into Doc B via transclusion API Server creates new edition of Doc B with the pasted RangeElements 2. TransclusionIndex updated: each element's BLAKE3 hash → new edition ID O(1) per element — just a HashMap insert 3. Bert Canopy: new BertProp flags computed for the edition's crum compute_join() propagates flags upward to root 4. Sensor Canopy: check for matching recorders at ancestors If IS_SENSOR_WAITING_FLAG is set, trigger matching recorders 5. RecorderTrigger fires: new RecordedResult added to Fossil Deduplicated by BLAKE3 fingerprint — each unique element recorded once 6. RecorderHoister propagates new recorders up the canopy tree O(log n) nodes touched — only the path from leaf to root 7. Content-watch subscribers notified (WebSocket push to clients) Real-time notification: "New content match found in Doc B for your watch on Doc A" 8. Attribution panel shows "via work:XXXX" for the transcluded passage Ed25519-signed provenance chain traces content back to original author

Figure 3: End-to-end transclusion flow when content is pasted between documents.

8. Modern Enhancements Over Udanax-Gold

AspectUdanax-Gold (C++)Xudanu (Rust)
Content hashingBasic FNV hashBLAKE3 (256-bit, SIMD-optimized, collision-resistant)
Thread safetySingle-threaded, no concurrencyArc<Mutex> throughout; concurrent queries
Memory modelManual Heaper allocation with garbage collectionRust ownership + Arc reference counting
Recorder dedupNo fingerprint deduplicationBLAKE3-based dedup in Fossil::record()
ProvenanceNo cryptographic signingEd25519-signed element and span provenance
Real-time pushNo live updates (batch only)WebSocket content-watch notifications
PersistenceIn-memory only (no disk)WAL + dual manifest + chunk store
Query APIInternal C++ API, no network access140+ WebSocket operations with JSON/binary codecs

9. Performance Characteristics

OperationComplexityNotes
Register edition (fingerprint indexing)O(n)n = elements in edition. One HashMap insert per element.
Canopy flag propagationO(log N)N = total editions. Only path from leaf to root.
Recorder hoistO(log N)Walk from affected crum to root, O(log N) steps.
Backfollow query (single edition)O(k · log N)k = unique fingerprints in edition, each with canopy pruning.
Full cross-reference (all works)O(N · k_avg)Linear in corpus size, mitigated by canopy pruning.
Recorder trigger (new match)O(1)Single fingerprint lookup + fossil insert.
Fossil dedup checkO(1)HashSet lookup by BLAKE3 fingerprint.
Key insight: The Bert Canopy's flag-based pruning is what makes transclusion queries feasible at scale. Without it, every query would need to scan all editions. With it, only editions in subtrees whose flags overlap with the query are visited.