feat(bitcoin): add Bitcoin domain plugin — multidimensional VCS for on-chain and Lightning state
Introduces `muse/plugins/bitcoin/` as the second production-grade MUSE domain plugin, implementing all three protocol levels:
Core (MuseDomainPlugin): - snapshot() — walks workdir, hashes all non-hidden JSON files via StatCache - diff() — semantic PatchOp per recognized file (UTXO-level, channel-level, strategy field-level, fee/price time-series); falls back to ReplaceOp when the object store is unavailable - merge() — three-way merge with Bitcoin-aware double-spend detection: concurrent spends of the same UTXO produce a structured ConflictRecord with conflict_type="double_spend" before any tx reaches the mempool - drift() / apply() / schema() — standard contract implementations
OT merge (StructuredMergePlugin): - merge_ops() — operation-level merge; flags concurrent DeleteOps on the same UTXO address pattern ("utxos.json::txid:vout") as double-spend conflicts
CRDT (CRDTPlugin): - join() — convergent join across 7 dimensions: files_manifest/utxos/channels/strategy → AWMap (add-wins) labels/transactions/mempool → ORSet (add-wins) - to_crdt_state() / from_crdt_state() — lift/materialise - Satisfies all three CRDT lattice laws (commutativity, associativity, idempotency) — verified by test suite
Domain schema: 10 named dimensions (utxos, transactions, labels, descriptors, channels, routing, strategy, execution, oracle_prices, oracle_fees, network, mempool). merge_mode="crdt".
Watch-only by design: private keys are never stored. All descriptors are xpubs. The plugin versions your relationship with Bitcoin, not your secrets.
Files: - muse/plugins/bitcoin/__init__.py - muse/plugins/bitcoin/_types.py — 15 TypedDicts covering all dimensions - muse/plugins/bitcoin/_query.py — pure-functional analytics layer - muse/plugins/bitcoin/plugin.py — full MuseDomainPlugin + OT + CRDT - tests/test_bitcoin_plugin.py — 84 tests, all green - muse/plugins/registry.py — registers "bitcoin" domain
Verification: mypy muse/ → 0 errors (193 files) typing_audit --max-any 0 → 0 violations pytest tests/test_bitcoin_plugin.py → 84/84 passed
No comments yet. Be the first to start the discussion.