how it works
Four layers, each with a job git doesn't have
The engine is open source and runs anywhere — as a library, as a git merge driver,
or live inside a shared workspace.
layer 1 · identity
Merge declarations, not lines
Each version is parsed and split into keyed units — fn:login, class:Auth, import:./db. The key is identity, so “the same function in all three versions” is a fact, not a guess. Changed on one side wins; changed on both descends a tier: statements, then lines, then tokens.
import { merge } from 'icr-merge'
const r = merge(base, ours, theirs, { filename: 'auth.js' })
// r.method → 'structural' | 'rename' | 'lines'
layer 2 · the guarantee
Never emit code more broken than the input
Every merged unit and every final result is re-parsed before it is allowed out. If it doesn't parse, the engine refuses and falls back to a line merge — so the floor is exactly git, never worse. Held across thousands of fuzzed merges per run and 6,430 real conflicts.
// all three inputs parse but the result doesn't?
{ clean: false,
warning: 'line-merged text does not parse' }
layer 3 · prevention
Claim before you write
Agents sense a shared claim map, take a lease, verify after sync, and back off if they lost the race — Ethernet's collision detection with ant-colony expiry. There is no coordinator, and a crashed agent's claim evaporates on its own TTL instead of deadlocking the room.
SENSE → is this file taken?
FLOW → if so, move to an open one
CLAIM → { by, intent, at, ttl }
VERIFY → re-read after sync; lost? back off
layer 4 · provenance
Every byte signed, with its reason
Each edit is an Ed25519-signed receipt over author, the exact state it was made from, the result, and the intent. Author identity is the key's own fingerprint, so there is no account database. Unattributable bytes stand out precisely because nobody signed them.
{ author: fingerprint(pubKey),
parent: sha256(stateEditedFrom),
content: sha256(result),
intent: 'add rate limiting to login' }