0162: vc merge granularity is the item
Status: Accepted — implementation authorized 2026-11-05
Context
About 50 agents will edit one codebase at once. Line merges
produce text that has no meaning to the compiler and that agents
must spend tokens reading. Semantic merges of whole refactors are
hard to get right. Storage is units keyed by outline
selectors (ADR-0161).
Decision
sync and the merge queue run
merge3(base, ours, theirs). The base is the
base recorded in the branch tip's commit, or the tip
itself once a landing has moved the branch onto the protected
history. No ancestor search is needed. merge3 is a
pure function of three trees and never runs the resolver. Units
are matched by key within each module:
- A unit changed, added or removed on one side only takes that side.
- A unit changed identically on both sides takes either side.
- A unit changed differently on both sides is a conflict, with no line merge inside a unit. This includes a delete on one side and an edit on the other.
- Impl methods, impl heads and impl tails are separate units.
- Header imports merge as a three-way set of
(path, name, alias)entries, rendered byfmt. Any other change to the header on both sides is a conflict. - Unit order is ours, with each of theirs' new units placed after its nearest predecessor in theirs that exists in ours. Order is never a conflict.
- Blobs and
rawfiles merge as whole files. - v1 has no rename or move detection: a rename is a delete plus an add.
A conflicted file becomes raw, with markers for
each conflicting unit, and commit refuses it until
its markers are gone. A clean merge is not trusted on its own: the
protected branch advances only after the merge queue gates the
merged tree.
Consequences
The rules are few, deterministic and syntactic. Two agents editing the same function conflict even when their lines are disjoint; M-VC.11 measures how often.
Some semantic breakage merges cleanly, for example:
- a rename plus a new caller of the old name;
- an interface change plus a new impl method.
The queue gate catches it, not the merge.
Alternatives
- Line-level merge inside units: fewer
conflicts but silent bad merges. This is the
intra-item-mergeexperiment and is adopted only on measured data. - Operation-based merge (replaying recorded
refactors): handles renames properly, but needs recorded
intents, which
harness renamedoes not produce today. This is therefactor-replayexperiment. - Conflicting the whole impl when its interface signature changed: this needs the resolver and cross-module lookups, so merge would no longer be pure. The gate covers the case instead.
- Rename detection by exact body hash: this guesses wrong when two trivial functions share a body, and merge has no use for it in v1.
- Whole-file merge: too many conflicts for 50 agents.