Compound Documents

Documents assembled from live pieces of other documents — not copies, but transclusions that maintain their bond to the source and update when the source changes.

1. What Is a Compound Document? 2. The Legal Brief Example 3. How to Create a Compound Document 4. Visual Markers — Seeing Where Pieces Come From 5. The Compound Panel 6. Compound vs. Link — When to Use Which 7. How It Works Under the Hood 8. Xudanu vs. Udanax-Gold Compounds

1. What Is a Compound Document?

A compound document is a document whose content is assembled from pieces of other documents. Each piece is a transclusion — a live reference to a span of text in another work, not a copy.

Think of it like a film editor's decision list (EDL): the final film is a sequence of clips, each pointing back to the original footage. The film IS the assembly — the clips aren't links, they ARE the content. If the original footage is recoloured, the final film reflects the change.

STATUTE "All persons shall have the right to privacy..." CASE LAW "The court held that privacy extends..." DISSENT "Privacy is not absolute..." LEGAL BRIEF (compound) "All persons shall have the right to privacy..." This right has been consistently upheld. "The court held that privacy extends..." However, this principle is contested. "Privacy is not absolute where..." We disagree with this framing. Each coloured region is a live transclusion from a source work

A compound Legal Brief assembled from three source works. Each coloured region is a transclusion — live content from another document, not a copy.

2. The Legal Brief Example

Imagine you're building a legal argument. You have three source works on your Xudanu server:

Your Legal Brief is a compound document — its content is assembled from pieces of all three sources, interleaved with your own analysis:

Statute [0:72] "All persons shall have the right to privacy in their personal communications."
This right has been consistently upheld. In particular,
Case Law [10:65] "the court held that privacy extends to digital communications."

However, this principle is contested. Critics argue that
Dissent [0:58] "privacy is not absolute where national security is concerned."

We disagree with this framing.

The Brief is one document whose content literally comes from four places: three transclusions (from Statute, Case Law, and Dissent) plus your own original text. If the Statute work is ever updated, the transclusion in the Brief resolves to the new content.

3. How to Create a Compound Document

1 Create source works

Create separate documents for each source. For the legal brief example, create "Statute", "Case Law", and "Dissent" with their respective texts.

2 Open the Compound Builder

Open the document you want to build into a compound (or create a new one). Click Build in the document toolbar. A three-panel layout opens: source pool on the left, your document in the center, and a structure outline on the right.

3 Add sources

Click "+ Add source" in the left panel and pick a source document from your library. The source text loads in the lower-left panel. Add as many sources as you need — they stay open simultaneously.

4 Include passages

Click a source to read its text. Select a passage (click and drag). An "Include passage" button appears at the top. Click it to transclude the passage into your document. The text appears in the center panel with a coloured background and source label.

5 Mix in original text

Between transcluded passages, type your own analysis, commentary, or connecting text. The structure outline on the right shows which sections are [Original] vs [From: Source], giving you a live overview of the document's composition.

6 Review and finish

Check the structure outline to see how many sources you've drawn from and the ratio of original to transcluded content. Click "Done" to return to the normal editor. Your compound is saved.

To view the compound structure later, click the compound icon in the left rail to open the Compound Panel (read-only), or click Build again to continue assembling.

Alternative method: You can also transclude without the Builder. Select text in any document, click Transclude (amber button in the floating toolbar), navigate to your target document, and place it at the cursor. The Builder is better for multi-source assembly; the Transclude button is better for quick one-off inclusions.
Learn more: See the Compound Builder Guide for detailed examples (single-source, multi-source, legal brief, literary anthology) and stretch goals for future capabilities.

4. Visual Markers — Seeing Where Pieces Come From

When a document contains transclusions, you'll see these visual elements:

"All persons shall have..." STATUTE This right has been upheld. "The court held that..." CASE LAW However, this is contested. "Privacy is not absolute..." DISSENT We disagree with this framing. ■ 3 sources □ 3 L source label (above region) compound badge toggle

Anatomy of a compound document: colour-coded transclusion regions with source labels, left-margin bars, a compound badge in the toolbar, and a toggle button.

The colour palette

Each source work gets one of eight colours, determined by a hash of the work ID:

ColourHexBackground tint
Teal#00897brgba(0,137,123,0.12)
Indigo#5c6bc0rgba(92,107,192,0.12)
Orange#f4511ergba(244,81,30,0.12)
Purple#7b1fa2rgba(123,31,162,0.12)
Red#c62828rgba(198,40,40,0.12)
Green#2e7d32rgba(46,125,50,0.12)
Cyan#00838frgba(0,131,143,0.12)
Amber#e65100rgba(230,81,0,0.12)

Hover tooltips

Hovering over a transclusion region (or its left-margin bar) shows a tooltip with:

The compound toggle

A small button in the editor's filter row shows {"\u25A3"} N where N is the number of transclusion elements. Click it to toggle compound highlighting on or off. This is useful when you want to read the document without visual distractions.

The compound badge

When a document contains transclusions, a badge appears in the document toolbar: {"\u25A3"} 3 sources. This makes it immediately clear that the document is compound — you don't need to open the compound panel to know.

5. The Compound Panel & Compound Builder

Xudanu provides two complementary tools for working with compound documents:

The Compound Panel (read-only viewer)

Click the compound icon in the left rail to open the Compound Structure panel. This is a read-only viewer showing:

The panel includes a "Build" button that opens the full Compound Builder for adding new transclusions.

The Compound Builder (authoring tool)

Click "Build" in the document toolbar (or the Build button in the Compound Panel) to open the three-panel assembly view:

See the Compound Builder Guide for detailed examples and stretch goals.

6. Compound vs. Link — When to Use Which

Compound (Transclusion)Link
What it doesMakes foreign text appear inline in your documentConnects two passages with a typed relationship
Content changesYour document's content changes when source updatesNeither document's content changes
VisualColoured background + source labelColoured underline + margin bar
ProvenanceRecursive chain via again()One-hop provenance
Use whenYou want the source text to BE part of your documentYou want to reference or annotate a passage
They're complementary: A legal brief might transclude the statute text (so it appears inline) AND link to a commentary on that statute (so the connection is visible without copying the commentary). The transclusion is content; the link is metadata.

7. How It Works Under the Hood

Xudanu's compound mechanism is architecturally different from Udanax-Gold's:

GOLD: O-TREE document text GOLD: SIDE-TABLE compound spans (separate) can drift! XUDANU: O-TREE text + transclusion elements (inline) single source of truth

Gold stored compound spans in a separate side-table alongside the O-tree (two copies that could drift apart). Xudanu stores transclusions directly in the O-tree as RangeElement::Transclusion — a single source of truth.

Resolution pipeline

  1. Transclusion element lives in the O-tree at a specific position
  2. resolveInlineTransclusions walks the O-tree, finds each transclusion element, and fetches the source text
  3. Resolution is recursive up to 32 levels with cycle detection (a transclusion of a transclusion of a transclusion...)
  4. Span migration keeps transclusion positions correct when the source work is edited
  5. Live updates — the server pushes CompoundSourceChanged events; the frontend also polls every 30 seconds as a fallback

8. Xudanu vs. Udanax-Gold Compounds

FeatureUdanax-GoldXudanu
Storage modelSide-table (drift-prone)Inline in O-tree (single source of truth)
Collaborative editingSingle-userCRDT multi-user
Span migrationManualAutomatic through arbitrary deltas
Live updatesPull-basedPush + poll (CompoundSourceChanged event)
Recursive resolutionagain() method32-level recursive with cycle detection
Lazy/template fillingPlaceHolder + FillDetector + AgendaNot implemented (all resolution synchronous)
Federated resolutionTheoreticalNot implemented (future work)
Flatten/break transclusionNot implementedNot implemented (future work)
Xudanu's key innovation: Moving transclusions directly into the O-tree as RangeElement::Transclusion eliminates the dual-copy drift problem that plagued Gold's side-table architecture. This is a design not found in Gold or any other system.
Gold's unrealised vision: Gold had a sophisticated lazy-resolution system: PlaceHolder (unfilled slots), FillDetector (async fill events), and Agenda (crash-surviving background work queue). These would enable "living documents" that auto-assemble as content appears in the docuverse. Xudanu has stubs for these but doesn't implement them — all resolution is synchronous. This remains a future direction.