cgcardona / muse public
README.md markdown
181 lines 9.4 KB
368bcde6 Add security test coverage and reference documentation Gabriel Cardona <gabriel@tellurstori.com> 9h ago
1 # Muse Documentation
2
3 > **Version:** v0.1.3 · [Project README](../README.md) · [Source](../muse/)
4
5 This directory contains the complete documentation for Muse — a domain-agnostic version control system for multidimensional state.
6
7 ---
8
9 ## Quick Navigation
10
11 | I want to… | Start here |
12 |-------------|-----------|
13 | Understand the full architecture | [Architecture Reference](architecture/muse-vcs.md) |
14 | Authenticate with MuseHub | [Auth Reference](reference/auth.md) |
15 | Connect a repo to a hub | [Hub Reference](reference/hub.md) |
16 | Understand the security model | [Security Architecture](reference/security.md) |
17 | Push, fetch, or clone a repo | [Remotes Reference](reference/remotes.md) |
18 | Browse the CLI command tiers | [CLI Tiers Reference](reference/cli-tiers.md) |
19 | See all MIDI semantic commands | [MIDI Domain Reference](reference/midi-domain.md) |
20 | See all Code semantic commands | [Code Domain Reference](reference/code-domain.md) |
21 | Build a new domain plugin | [Plugin Authoring Guide](guide/plugin-authoring-guide.md) |
22 | Learn CRDT semantics | [CRDT Reference](guide/crdt-reference.md) |
23 | See an end-to-end walkthrough | [E2E Demo](architecture/muse-e2e-demo.md) |
24 | Read the protocol spec | [Plugin Protocol](protocol/muse-protocol.md) |
25 | Understand domain concepts | [Domain Concepts](protocol/muse-domain-concepts.md) |
26 | Look up a named type | [Type Contracts](reference/type-contracts.md) |
27 | Configure merge strategies | [`.museattributes` Reference](reference/muse-attributes.md) |
28 | Exclude files from snapshots | [`.museignore` Reference](reference/museignore.md) |
29 | Watch the demo narration | [Demo Script](demo/demo-script.md) |
30
31 ---
32
33 ## Directory Map
34
35 ```
36 docs/
37 ├── README.md ← you are here
38
39 ├── architecture/
40 │ ├── muse-vcs.md — full technical design: protocol stack, storage,
41 │ │ diff algorithms, OT merge, CRDT semantics,
42 │ │ config system, and CLI command map
43 │ └── muse-e2e-demo.md — step-by-step lifecycle: init → commit → branch
44 │ → merge conflict → resolve → tag
45
46 ├── guide/
47 │ ├── plugin-authoring-guide.md — complete walkthrough for writing a new domain
48 │ │ plugin, from core protocol through OT merge
49 │ │ and CRDT convergent merge
50 │ └── crdt-reference.md — CRDT primer: lattice laws, all six primitives
51 │ (VectorClock, LWWRegister, ORSet, RGA, AWMap,
52 │ GCounter), composition patterns, when to use CRDTs
53
54 ├── protocol/
55 │ ├── muse-protocol.md — language-agnostic MuseDomainPlugin spec: six
56 │ │ required methods, StructuredMergePlugin and
57 │ │ CRDTPlugin optional extensions, invariants
58 │ ├── muse-domain-concepts.md — universal vocabulary: what "state", "delta",
59 │ │ "dimension", "drift", and "merge" mean across
60 │ │ music, genomics, simulation, and beyond
61 │ └── muse-variation-spec.md — variation semantics for the MIDI domain
62
63 ├── reference/
64 │ ├── auth.md — muse auth login/whoami/logout: identity lifecycle,
65 │ │ ~/.muse/identity.toml format, env vars, flows
66 │ ├── hub.md — muse hub connect/status/disconnect/ping: hub fabric,
67 │ │ hub vs remote distinction, HTTPS enforcement
68 │ ├── remotes.md — muse push/fetch/clone/pull/remote: transport arch,
69 │ │ PackBundle wire format, tracking branches
70 │ ├── security.md — security architecture: validation trust model,
71 │ │ path containment, ANSI injection, XML safety,
72 │ │ transport hardening, identity store guarantees
73 │ ├── cli-tiers.md — three-tier CLI architecture: Tier 1 plumbing
74 │ │ (JSON, pipeable), Tier 2 porcelain (core VCS),
75 │ │ Tier 3 semantic (midi/code/coord namespaces)
76 │ ├── midi-domain.md — MIDI domain complete reference: all 31 semantic
77 │ │ porcelain commands, flags, JSON schemas, types
78 │ ├── code-domain.md — Code domain complete reference: all semantic
79 │ │ porcelain commands, symbol identity model, types
80 │ ├── type-contracts.md — single source of truth for every named type:
81 │ │ TypedDicts, dataclasses, Protocols, Enums,
82 │ │ and TypeAliases with Mermaid diagrams
83 │ ├── muse-attributes.md — .museattributes TOML format reference:
84 │ │ [meta] domain, [[rules]] syntax, all five
85 │ │ strategies, multi-domain usage, examples
86 │ └── museignore.md — .museignore format: glob patterns, negation,
87 │ dotfile exclusion rules
88
89 └── demo/
90 ├── midi-demo.md — MIDI domain demo walkthrough: all 31 semantic
91 │ porcelain commands with CLI output examples
92 ├── demo-code.md — Code domain demo walkthrough
93 └── demo-script.md — narration script for the video demo
94 ```
95
96 ---
97
98 ## Architecture at a Glance
99
100 Muse separates the **VCS engine** (domain-agnostic) from **domain plugins** (domain-specific). The engine never changes when a new domain is added — only a new plugin is registered.
101
102 ```
103 ┌─────────────────────────────────────────────┐
104 │ muse CLI │
105 │ Tier 1: plumbing · Tier 2: porcelain │
106 │ Tier 3: midi / code / coord domains │
107 └──────────────────────┬──────────────────────┘
108
109 ┌──────────────────────▼──────────────────────┐
110 │ Muse Core Engine │
111 │ DAG · object store · branching · merging │
112 │ content-addressed blobs · lineage walking │
113 └──────┬────────────────────────────┬─────────┘
114 │ │
115 ┌──────▼──────┐ ┌──────▼──────┐
116 │MuseDomainPlugin│ │MuseDomainPlugin│
117 │ (music) │ │ (your domain) │
118 │ 6 methods │ │ 6 methods │
119 └──────────────┘ └───────────────┘
120 ```
121
122 The six required methods:
123
124 | Method | What it does |
125 |--------|-------------|
126 | `snapshot()` | Capture live state → content-addressed dict |
127 | `diff()` | Compute typed delta between two snapshots |
128 | `merge()` | Three-way reconciliation against a common ancestor |
129 | `drift()` | Compare committed state against live working tree |
130 | `apply()` | Apply a delta to reconstruct historical state |
131 | `schema()` | Declare data structure → drives diff algorithm selection |
132
133 Two optional protocol extensions enable richer merge semantics:
134
135 | Extension | Adds | Effect |
136 |-----------|------|--------|
137 | `StructuredMergePlugin` | `merge_ops()` | Operation-level OT merge — minimal real conflicts |
138 | `CRDTPlugin` | `join()` + 3 helpers | Convergent merge — `join` always succeeds, no conflict state |
139
140 ---
141
142 ## Adding a New Domain
143
144 1. Copy `muse/plugins/scaffold/` → `muse/plugins/<your_domain>/`
145 2. Rename `ScaffoldPlugin` → `<YourDomain>Plugin`
146 3. Replace every `raise NotImplementedError(...)` with real implementation
147 4. Register in `muse/plugins/registry.py`
148 5. Run `muse init --domain <your_domain>` in a project directory
149
150 All Tier 2 core VCS commands work immediately for the new domain. Tier 3 semantic commands live in the new `muse/<domain> …` sub-namespace. See the [Plugin Authoring Guide](guide/plugin-authoring-guide.md) for the full walkthrough.
151
152 ---
153
154 ## Config Files Generated by `muse init`
155
156 | File | Location | Purpose |
157 |------|----------|---------|
158 | `repo.json` | `.muse/repo.json` | Immutable identity: repo UUID, schema version, domain |
159 | `config.toml` | `.muse/config.toml` | Mutable: `[user]`, `[auth]`, `[remotes]`, `[domain]` |
160 | `HEAD` | `.muse/HEAD` | Current branch ref |
161 | `.museattributes` | repo root | TOML merge strategy overrides (`[[rules]]`) |
162 | `.museignore` | repo root | Glob patterns to exclude from snapshots |
163
164 ---
165
166 ## Testing Standards
167
168 Every public function has a unit test. Integration tests wire real components. E2E tests invoke the CLI via `typer.testing.CliRunner`.
169
170 ```bash
171 # Run all tests
172 pytest tests/ -v
173
174 # Type-check
175 mypy muse/
176
177 # Zero-Any audit
178 python tools/typing_audit.py --dirs muse/ tests/ --max-any 0
179 ```
180
181 All three gates must be green before any PR merges.