Weave — version control for code stored as a syntax tree

AST-native version control · v0.01

Version control for code stored as a syntax tree

Weave keeps your code as a syntax tree in a SQLite database instead of as lines in files. Commits, branches, and merges operate on the tree, so edits to different parts of a file don't conflict the way they do in git.

How it differs from git

Merges happen on the syntax tree, not on lines of text.

In git

Git treats a source file as a sequence of lines of text. When two branches change the same file — even in different functions — git compares line ranges and reports a conflict when those ranges overlap or sit adjacent. It works on line positions, not on the structure of the code.

With several coding agents working in one repo at once, this comes up often. They produce large, overlapping edits, and much of the time goes into resolving conflicts that aren't actual disagreements about the code.

In Weave

Weave parses your code into an abstract syntax tree and stores it in SQLite, where every node has a stable id. A change is a structural operation on a node — replace an expression, insert a function, delete a branch — rather than a text diff.

Two edits conflict only if they touch the same node. Different functions are different nodes, so they merge automatically, and adjacent lines or formatting don't cause conflicts. When there is a real conflict, it's scoped to the single node both sides changed.

How it works

Four ideas, one operation log.

Everything in Weave is an append-only log of structural ops. Any version of your code is just those ops replayed onto a tree.

01 — the store
CODE IS A TREE, NOT A FILE

Parsed into nodes, kept in SQLite

Your source is parsed into AST nodes with stable ids and stored in a WAL-mode database. Nothing lives on disk as text — even running the program renders the tree in memory.

02 — a commit
EVERY CHANGE IS AN OP

Revisions are transactions of ops

A commit is a set of structural operations — replace, insert_after, append_child, delete — each targeting a node id. State is materialized by replaying the op chain.

03 — a branch
WORKTREES ARE BRANCH HEADS

Fork main, work in isolation

Each agent gets its own worktree forked from main. It reads, edits, and runs code entirely inside the database — no checkout, no working directory to dirty.

04 — a merge
MERGE = REPLAY OPS ONTO MAIN

Different nodes auto-merge

Ops touching nodes untouched on main replay cleanly. Only a same-node collision returns a conflict — a tiny base/main/worktree report scoped to one node, small enough to hand to an LLM that writes code combining both intents.

Merge queue

Commits land through a speculative merge queue

Structural merging avoids conflicts in the code. A merge queue avoids conflicts in CI: agents can commit to main concurrently, and main only advances through revisions that pass the test suite.

Verification runs outside the lock

Conventional CI serializes: each commit locks main, runs the whole suite, then unlocks — so ten agents mean ten suites back to back. Weave's commit_to_main is a speculative queue (bors / GitHub-merge-queue style). Enqueuing takes a millisecond write-lock — enough to run conflict checks and assign node ids — then releases. Verification then runs concurrently, against the predicted landing state: the current head, plus every transaction queued ahead of you, plus your own ops.

Main only advances through green states

Landing is a hash check. If the state you verified is byte-identical to the real landing state, it lands immediately with no re-run. If a commit ahead of you was evicted, your hash no longer matches and you re-verify against the corrected state. Main advances only through verified states, in ticket order, so every revision on main passes the suite. A failing commit is evicted and returned to its author; the commits behind it re-check and continue.

commit_to_main — speculative merge queue
ms write-lock (conflict check) verifying / verified evicted → re-run
#1 feat-A
lands → r1
#2 feat-B
lands → r2
#3 hotfix
✗ evicted → author
#4 feat-D
lands → r3
main r0 r1 r2 r3 // #3 never touches main — every landed revision is green
~0.6s3 disjoint commits land · serial gating ≥ 1.8s
0.01sre-verify when the slow test is untouched*
100%of landed revisions pass the suite

*Each test's pass is cached against the content hash of its dependency closure. A test re-runs only when code it can actually observe changed, so the landing gate is usually nearly free. Figures measured in test_speculative.py.

Demo

Merging two overlapping edits

worktree · feature-1 (quantity)
op append_child → qty param
op replace node #payment.tax
op replace node #total_price.body
worktree · feature-2 (discount)
op append_child → discount param
op insert_after node #cart.summary
op replace node #total_price.body
main — merge_worktree
auto qty & discount params → different nodes, replayed
auto #payment.tax, #cart.summary → no overlap, replayed
conflict #total_price.body → same node, both sides changed
llm resolve_merge → return price*qty - discount
Press Run merge to replay two overlapping worktrees onto main.

Conflict size

Conflicts are scoped to a single node.

When two edits do touch the same node, Weave reports just that node — the base, main, and worktree versions — instead of a file full of conflict markers. That's small enough to hand to an LLM to resolve, and edits to different nodes don't conflict in the first place.

Comparison

How Weave relates to existing tools

You still branch, commit, and merge. Here's where Weave overlaps with tools you already use, and where it differs.

Weave vs. Git
In common
Commits, branches, merges, a reviewable history, and an explicit merge step you control. The workflow feels like git.

How Weave differs
Git diffs and merges lines of text; Weave diffs and merges AST nodes. No line-level or adjacent-line conflicts, and your working copy is a database, not a checkout you have to keep clean.
Weave vs. GitHub / Pull Requests
In common
Isolate work, propose a change set, and review before it lands on the main line.

How Weave differs
A PR still resolves at the textual diff. Weave's unit of review is a structural op set; conflicts arrive pre-scoped to nodes and can be auto-resolved by an LLM instead of a human rebasing a branch.
Weave vs. Unison / content-addressed code
In common
The conviction that code should be stored as structured, identity-bearing definitions — not as files of text.

How Weave differs
Unison is a whole language you adopt. Weave is a VCS layer you point at ordinary code, with git-style worktrees, commits, and merges — plus an MCP interface built for agents.
Weave vs. CRDT live editors (Docs, multiplayer IDEs)
In common
Many writers on one document, combined by operations rather than manual conflict resolution.

How Weave differs
Character-level CRDTs converge always — and can silently interleave two edits into broken syntax. Weave's ops are AST-aware, so a merge is always valid code; a genuine clash surfaces as an explicit conflict instead of corrupt text.
Weave vs. semantic-merge tools (SemanticMerge, difftastic)
In common
They parse code into a tree to merge and diff more intelligently than plain line comparison.
How Weave differs
Those tools bolt structural awareness onto a file- and line-based git. Weave is structural all the way down — the tree is the store, so there are no files to reconcile in the first place.

FAQ

Common questions

Do I have to give up git? +

Conceptually, no — Weave keeps the branch/commit/merge model you already think in. Under the hood it replaces text storage with a syntax-tree database, so the everyday operations map over directly. It's a different engine, not a different mental model.

What actually happens on a real conflict? +

When two worktrees change the same node, Weave returns a per-node conflict report with the base, main, and worktree versions of just that node. Because the scope is one expression rather than a whole file, it's small enough to resolve automatically — the merge agent writes code that combines both sides' intent via resolve_merge.

How do coding agents plug in? +

Through a dependency-free MCP stdio server exposing the store as tools — create_worktree, read_source, commit, run_program, merge_worktree, resolve_merge, and more. Agents run with filesystem and shell access disabled: the code never exists as a file for them to touch.

Is the code ever written to disk? +

No. The tree lives in SQLite, and even running the program renders the projection in-memory — so “run the code” never materializes a file. The database is the single source of truth.

What languages does it support? +

The reference implementation demos Python via its AST, but the architecture is language-agnostic: anything with a parser to build the tree and a renderer to project it back to source can ride the same op-log and merge engine.

Is this production-ready? +

Not yet — Weave is v0.01, a working research prototype exploring what version control looks like when the store is a syntax tree. It runs the full loop today: parallel agents, node-level auto-merge, and LLM-resolved conflicts. Treat it as a demo of the idea, not a drop-in for your team repo.