"""
def _render_domain_card(d: dict) -> str:
domain = d.get("domain", "unknown")
active = d.get("active") == "true"
schema = d.get("schema", {})
desc = schema.get("description", "")
dims = schema.get("dimensions", [])
caps = d.get("capabilities", [])
cap_html = " ".join(
f'{c}'
for c in caps
)
dim_html = " · ".join(
f'{dim["name"]}' for dim in dims
)
status_cls = "active-badge" if active else "reg-badge"
status_text = "● active" if active else "○ registered"
dot = '' if active else ""
short_desc = desc[:150] + ("…" if len(desc) > 150 else "")
return f"""
{status_text}{domain}
{dot}
{short_desc}
{cap_html}
Dimensions: {dim_html}
"""
def _render_planned_card(p: dict) -> str:
dims = " · ".join(f'{d}' for d in p["dimensions"])
cls = "planned-card yours" if p["status"] == "yours" else "planned-card"
return f"""
{p['icon']}
{p['name']}
{p['tagline']}
{dims}
{'Build it →' if p["status"] == "yours" else 'coming soon'}
"""
def _render_dist_card(d: dict) -> str:
steps = "".join(
f'
{s}
' for s in d["steps"]
)
return f"""
{d['icon']}
{d['tier']}
{d['title']}
{d['desc']}
{steps}
"""
def render(output_path: pathlib.Path) -> None:
"""Generate the domain registry HTML page."""
print(" Loading live domain data...")
domains = _load_domains()
print(f" Found {len(domains)} registered domain(s)")
print(" Computing live CRDT demos...")
crdt_demos = _compute_crdt_demos()
active_domains_html = "\n".join(_render_domain_card(d) for d in domains)
planned_html = "\n".join(_render_planned_card(p) for p in _PLANNED_DOMAINS)
dist_html = "\n".join(_render_dist_card(d) for d in _DISTRIBUTION_LEVELS)
crdt_cards_html = "\n".join(_render_capability_card(c) for c in crdt_demos)
html = _HTML_TEMPLATE.replace("{{ACTIVE_DOMAINS}}", active_domains_html)
html = html.replace("{{PLANNED_DOMAINS}}", planned_html)
html = html.replace("{{DIST_CARDS}}", dist_html)
html = html.replace("{{SCAFFOLD_SNIPPET}}", _SCAFFOLD_SNIPPET)
html = html.replace("{{TYPED_DELTA_EXAMPLE}}", _TYPED_DELTA_EXAMPLE)
html = html.replace("{{CRDT_CARDS}}", crdt_cards_html)
html = html.replace("{{DIFF_ALGEBRA}}", _DIFF_ALGEBRA_HTML)
# Inject SVG icons into template placeholders
_ICON_SLOTS: dict[str, str] = {
"MUSIC": _ICONS["midi"],
"GENOMICS": _ICONS["genomics"],
"CUBE": _ICONS["cube"],
"TRENDING": _ICONS["trending"],
"ATOM": _ICONS["atom"],
"PLUS": _ICONS["plus"],
"ACTIVITY": _ICONS["activity"],
"PEN_TOOL": _ICONS["pen-tool"],
"CODE": _ICONS["code"],
"LAYERS": _ICONS["layers"],
"GIT_MERGE": _ICONS["git-merge"],
"ZAP": _ICONS["zap"],
"GLOBE": _ICONS["globe"],
"SEARCH": _ICONS["search"],
"PACKAGE": _ICONS["package"],
"LOCK": _ICONS["lock"],
"CHECK_CIRCLE": _ICONS["check-circle"],
"X_CIRCLE": _ICONS["x-circle"],
}
for slot, svg in _ICON_SLOTS.items():
html = html.replace(f"{{{{ICON_{slot}}}}}", svg)
output_path.write_text(html, encoding="utf-8")
size_kb = output_path.stat().st_size // 1024
print(f" HTML written ({size_kb}KB) → {output_path}")
# Also write as index.html so the domain registry IS the landing page.
index_path = output_path.parent / "index.html"
index_path.write_text(html, encoding="utf-8")
print(f" Landing page mirrored → {index_path}")
# ---------------------------------------------------------------------------
# Diff Algebra section — five algorithm visualizations + StructuredDelta flow
# ---------------------------------------------------------------------------
_DIFF_ALGEBRA_HTML = """
Diff Algebra
Five Algebras. One Typed Result.
The engine selects the algorithm per dimension from your plugin’s
schema(). You declare the shape — the engine handles identity,
diffing, and merge selection automatically.
Identity is hash-based: two elements are equal iff their SHA-256 hashes match — content is never inspected by the core. Delete + insert pairs sharing the same hash are collapsed into MoveOps in a post-pass.
TreeZhang-Shasha / GumTree
scene graphs · ASTs · track hierarchies
Edit distance over node hierarchy — moves preserve subtree identity across parent changes.
Configurable ε threshold. Sparse mode records only changed blocks — efficient for large tensors.
SetSet algebra · add / remove
annotations · tags · gene ontology terms
before
GO:0001234GO:0005634GO:0006915GO:0016020
—
—
× del
—
+ ins
after
GO:0001234GO:0005634GO:0016020GO:0042592
Unordered — no position tracking. Pure membership delta: {removed} and {added}.
MapRecursive key-by-key delegation
metadata · configs · nested structures
tempo120 → 140scalar → PatchOp
notes[…] → […′]sequence → LCS
tags{…} → {…′}set → algebra
author"Bach" = "Bach"unchanged
Each key is diffed by whichever algorithm matches its declared type — recursively, to arbitrary depth.
diff() → StructuredDeltaall five algorithms produce the same typed operation list
InsertOpDeleteOpMoveOpReplaceOpPatchOp
merge_mode: “three_way”
Operational Transformation — independent ops commute automatically; conflicting ops surface for human resolution
or
merge_mode: “crdt”
CRDT join() — convergent, no coordination required; any two replicas always reach the same state
"""
# ---------------------------------------------------------------------------
# Large HTML template
# ---------------------------------------------------------------------------
_HTML_TEMPLATE = """\
Muse — Version Anything
muse
Version Anything
One protocol. Any domain. Six methods between you and a
complete version control system — branching, merging, conflict resolution,
time-travel, and typed diffs — for free.
Every domain — MIDI, source code, genomics, 3D spatial, financial models —
implements the same six-method protocol. The core engine
handles everything else: content-addressed storage, DAG, branches, log,
merge base, cherry-pick, revert, shelf, tags.
6methods to implement
14CLI commands, free
∞domains possible
0core changes needed
Method
Signature
Purpose
snapshot
snapshot(live) → StateSnapshot
Capture current state as a content-addressable blob
diff
diff(base, target) → StateDelta
Compute minimal change between two snapshots (added · removed · modified)
merge
merge(base, left, right) → MergeResult
Three-way reconcile divergent state lines; surface conflicts per dimension
drift
drift(committed, live) → DriftReport
Detect uncommitted changes between HEAD and working state
apply
apply(delta, live) → LiveState
Apply a delta during checkout to reconstruct historical state
schema
schema() → DomainSchema
Declare data structure — drives diff algorithm selection per dimension
Registry
Registered Domains
Domains currently registered in this Muse instance. The active domain
is the one used when you run muse commit, muse diff,
and all other commands.
{{ACTIVE_DOMAINS}}
Ecosystem
The Plugin Ecosystem
MIDI and code are the two shipped domains — both fully active with typed
deltas, structured merge, and .museattributes rule control.
These are the domains planned next — and the slot waiting for yours.
{{PLANNED_DOMAINS}}
Engine Capabilities
What Every Plugin Gets for Free
The core engine provides four advanced capabilities that any domain plugin
can opt into. Implement the protocol — the engine does the rest.
{{ICON_CODE}} Typed Delta Algebra
StructuredDelta — every change is a typed operation
Unlike Git's blob diffs, Muse deltas are typed objects:
InsertOp, ReplaceOp, DeleteOp — each
carrying the address, before/after hashes, and affected dimensions.
Machine-readable with muse read --json.
Each plugin's schema() method declares its dimensions and merge mode.
The engine uses this to select the right diff algorithm per dimension and to
surface only the dimensions that actually conflict.
{{ACTIVE_DOMAINS}}
{{ICON_GIT_MERGE}} OT Merge
Operational transformation — independent ops commute automatically
Plugins implementing StructuredMergePlugin get operational
transformation. Operations at different addresses commute automatically —
only operations on the same address with incompatible intent surface a conflict.
Scenario AIndependent ops at different addresses
leftInsertOp"ot-notes-a.mid"tick=0 · C4 E4 G4
rightInsertOp"ot-notes-b.mid"tick=480 · D4 F4 A4
transform → no overlap → ops commute{{ICON_CHECK_CIRCLE}} Clean merge · both files applied
leftReplaceOp"shared-melody.mid"C4 E4 G4 · major triad
rightReplaceOp"shared-melody.mid"C4 Eb4 G4 · minor triad
transform → same address · non-commuting content{{ICON_X_CIRCLE}} Conflict · human resolves
{{ICON_ZAP}} CRDT Primitives
Convergent merge — any two replicas always reach the same state
Plugins implementing CRDTPlugin get six battle-tested
convergent data structures. No coordination required between replicas.
The MIDI plugin extends RGA into MidiRGA — a
voice-aware variant that orders concurrent note insertions by voice lane
(bass → tenor → alto → soprano) before falling back to
op-id, preventing voice crossings without human intervention.
{{CRDT_CARDS}}
{{DIFF_ALGEBRA}}
Build
Build in Three Steps
One command scaffolds the entire plugin skeleton. You fill in six methods.
The full VCS follows.
Step 1 · Scaffold
Generate the skeleton
One command creates the plugin directory, class, and all six method stubs
with full type annotations.
muse domains --new genomics
Step 2 · Implement
Fill in the six methods
Replace each raise NotImplementedError with your domain's
snapshot, diff, merge, drift, apply, and schema logic.
vim muse/plugins/genomics/plugin.py
Step 3 · Use
Full VCS, instantly
Register in registry.py, then every Muse command works
for your domain out of the box.
muse init --domain genomics
The Scaffold
What muse domains --new genomics produces
A fully typed, immediately runnable plugin skeleton. Every method has the
correct signature. You replace the stubs — the protocol does the rest.
Three tiers of distribution — from local prototype to globally searchable
registry. Start local, publish when ready.
{{DIST_CARDS}}
{{ICON_GLOBE}}
MuseHub is coming
A centralized, searchable registry for Muse domain plugins —
think npm or crates.io, but for any multidimensional versioned state.
One command to publish. One command to install.