Elffuss BraidHub

utopia-ia/elffuss-braid public

0cba57aa99aa · 8.2 KiBSourceRawPermalink

Design

Braid is a version control system for repositories where many agents create and land changes at the same time. This document explains the architecture and the reasons behind it. The byte-level format is in spec/format-v1.md.

Goals

Non-goals

Data model

Store

A store is a directory of files that several processes share. Its correctness rests only on guarantees every local file system gives: exclusive create, appends protected by checksums, advisory locks that the kernel releases when a process dies, atomic rename, and ordered syncs.

Landing on a branch

land takes a changeset C built on base B and moves a branch to include it. Bases are always ids, never branch names, so nothing is resolved late.

  1. If the request for (branch, C) already landed, return that result. A lost acknowledgement is retried safely.
  2. B must be on the branch's first-parent chain.
  3. If B is the head, fast-forward.
  4. Otherwise rebase C onto the head, path by path: unchanged since B takes C's value; changed on both sides goes through a three-way merge. The cost follows the size of C.
  5. Write the new objects, append the landing record, sync, then publish the new head.

Locally this step runs under the op log lock; on a server, one task per branch runs it in order, grouping several landings into one sync.

Conflicts are reported as data, not as markers in a file: the path, the kind, the base, ours and theirs, and the hunks. Braid is stricter than git about structural conflicts: a file against a directory, two names that differ only in case or Unicode normalisation, a directory removed under a new file, and the same file renamed two ways.

Invariants. A branch only moves forward. A branch never contains a conflict. No value is overwritten except by a change whose base already contained it. An acknowledged landing is durable. Readers only see durable heads.

Workspaces

Git bridge

Server and caches

Testing

Performance targets

Stated as complexity and as ratios against git on the same machine. Braid's published benchmarks will only ever be ratios with the script that reproduces them.