Architecture, merge algorithm, CRDT state, MCP tools, and CLI reference.
When git encounters a merge, it calls weave-driver with three versions of the file: base, ours, theirs. Here's what happens inside.
Entity and Interstitial regions. Interstitials are the whitespace, imports, and syntax between entities.diffy.
If that fails on a container (class/impl/trait), try inner entity merge: decompose into method-level chunks, match by name, merge each independently.
Renames are detected via structural_hash (AST-normalized).
Conflicts are classified using the ConGra taxonomy (Text/Syntax/Functional).
Five crates in a Cargo workspace. Each can be used independently.
sem-core for entity extraction and diffy for line-level fallback.%O %A %B %L %P. Reads three temp files, calls entity_merge(), writes result to %A. Exit 0 = clean, 1 = conflicts..weave/state.automerge. Not committed to git — local coordination state.weave setup, weave preview, weave status, weave claim, weave release.CRDT stands for Conflict-free Replicated Data Type — a data structure that multiple agents can edit simultaneously without conflicts. Think of it like a Google Doc that always merges correctly.
The merge driver is reactive — it resolves conflicts after they happen. But if two agents are about to edit the same function, you want to know before they collide. The CRDT gives agents a shared "who's editing what" map. Agent A claims processData, Agent B sees the claim and picks a different function instead.
Claims are signals, not hard locks. If an agent ignores a claim and edits anyway, the merge still works — weave's merge driver handles it. This matches the optimistic concurrency model: trust agents to cooperate, handle it gracefully if they don't.
The state is an Automerge document saved to .weave/state.automerge. It has three top-level maps:
{ "entities": { // every code entity weave knows about "src/lib.ts::function::processData": { "name": "processData", "type": "function", "file_path": "src/lib.ts", "content_hash": "a1b2c3...", "claimed_by": "agent-1", // advisory lock "claimed_at": 1706745600000, "last_modified_by": "agent-1", "version": 3 } }, "agents": { // registered agents "agent-1": { "name": "agent-1", "status": "active", "branch": "feature-auth", "last_seen": 1706745600000, "working_on": ["src/lib.ts::function::processData"] } }, "operations": [...] // audit log of claim/release/modify }
weave_agent_register with its ID and branch. Gets added to the agents map.weave_claim_entity. Gets back Claimed, AlreadyOwnedBySelf, or AlreadyClaimed { by }.weave_agent_heartbeat with its working_on list. Other agents can check weave_who_is_editing before starting work.weave_release_entity when done. If an agent crashes, cleanup_stale_agents releases its claims after a timeout.| Operation | What it does |
|---|---|
claim_entity | Set advisory lock on an entity for an agent |
release_entity | Remove the lock (only the owner can release) |
record_modification | Mark that an agent changed an entity, bump version |
detect_potential_conflicts | Find entities being worked on by multiple agents |
register_agent | Add an agent to the state with name and branch |
agent_heartbeat | Keep-alive + update working_on list |
cleanup_stale_agents | Release claims from agents that stopped heartbeating |
sync_from_files | Extract entities from working tree files into CRDT state |
MCP (Model Context Protocol) lets AI agents call tools. weave-mcp exposes 15 tools over stdio transport. Add it to Claude Code, Claude Desktop, or any MCP-compatible client.
$ cargo install --git https://github.com/Ataraxy-Labs/weave weave-mcp
# Add to Claude Code (available in all projects) $ claude mcp add --scope user weave -- weave-mcp # Restart Claude Code, then verify with /mcp
# Add to ~/.config/claude/claude_desktop_config.json { "mcpServers": { "weave": { "command": "weave-mcp", "args": [] } } }
{file_path}{agent_id, file_path, entity_name}{agent_id, file_path, entity_name}{file_path}{file_path, entity_name}{agent_id?}{base_branch, target_branch, file_path?}{agent_id, branch}{agent_id, working_on}{base_branch, target_branch, file_path?}{file_path, entity_name}{file_path, entity_name}{file_path, entity_name}{base_ref, target_ref?, file_path?}{file_path}// Agent starts up weave_agent_register({ agent_id: "claude-1", branch: "feature-auth" }) // Check what's in the file weave_extract_entities({ file_path: "src/auth.ts" }) // → [{name: "validateToken", type: "function", ...}, // {name: "authenticate", type: "function", ...}] // Claim before editing weave_claim_entity({ agent_id: "claude-1", file_path: "src/auth.ts", entity_name: "validateToken" }) // → "Claimed" // ... agent edits the function ... // Release when done weave_release_entity({ agent_id: "claude-1", file_path: "src/auth.ts", entity_name: "validateToken" }) // → "Released successfully"
The weave CLI wraps all functionality for human use.
--driver <path> Path to weave-driver binary (auto-detected if omitted)--file <path> Preview a specific file only--file <path> Show entities for a specific file--agent <id> Show status for a specific agent