Elffuss BraidHub

utopia-ia/elffuss-braid public

52e22f93c9da · 37.7 KiBSourceRawPermalink

<img src="docs/assets/braid-animated.svg" alt="Three strands braided together" width="320">

✳ Elffuss Braid

Version control for repositories where many agents land changes at the same time.

A from-scratch version control system in Rust. Creating a change costs what the change touches, not what the repository weighs. Agents commit in parallel, and landing on main is one short step they take in turn. Git stays at the edges, so GitHub keeps working.

License: Apache-2.0 CI Rust 1.89+ Version 0.1.1 Format v1: frozen

Website Hugging Face Space For agents: AGENTS.md llms.txt BraidHub PRs welcome Last commit

elffuss.com · Code · Claw · Translator · Copilot · Blog · Hugging Face · Dev log


Three agents commit at the same time, each in its own workspace, and land on main in turn: the first is a fast-forward, the second is rebased onto it, and the third changed the same line as the first, so main does not move and braid reports the conflict with exit status 2

The real CLI, recorded by <code>scripts/demos/render.sh</code>: three agents, one <code>main</code>.


In this repository: why braid · how it works · use it from your agent · quick start · working with git · BraidHub · design · status · what is honest about this · measured against git · credits


Why braid

Git was designed for people who work offline and sync now and then. Agents work differently: there are many of them, each change is small, they are always connected, and they all want to land on main at once. In git that shows up as:

Braid starts from the opposite assumptions:

gitbraid
Unit of changea commit: a full tree snapshota changeset: the files that changed against the first parent, plus the root tree id
Landing on mainthe client pushes and is rejected if behindland rebases in one short step that landings take in turn, at a cost that follows the change
Many writersone index per working treeone workspace per agent over a shared append-only store; creating a change takes no repository lock
Fetchingnegotiated packs, unique per clientimmutable objects by id, so any cache (local daemon, nginx, CDN) can serve them
Large directoriesrewritten whole on every changesplit into content-defined nodes; an edit rewrites only its path
Large filesa separate extensioncontent-defined chunks, deduplicated across versions
HashSHA-1BLAKE3
For agentsparse human output--json everywhere; changes can be created through the API without a checkout

This is the design. Status says what exists today.

How it works

flowchart LR
    subgraph machine["One machine"]
        A1["agent 1 · workspace"] --> ST
        A2["agent 2 · workspace"] --> ST
        A3["agent N · workspace"] --> ST
        ST[("shared store<br/>immutable objects + op log")]
    end
    ST -- "land: one short step, taken in turn" --> MAIN(["main"])
    ST <-- "objects by id" --> SRV["BraidHub (optional)"]
    ST <-- "import / export" --> GIT["git bridge"]
    GIT <--> GH["GitHub · Gitea"]
  1. Everything is an immutable object named by its BLAKE3 hash: file contents, directories, and changesets. Nothing is ever rewritten in place.
  2. A changeset records what changed against its first parent, plus the root tree it produces. History, blame and rebase read the short list; the root id commits to the whole repository.
  3. Agents commit in parallel; landing is one short step they take in turn. If the change was built on the current head it fast-forwards. If not, braid rebases it path by path and merges only the files both sides touched. Conflicts come back as data that an agent can act on.
  4. Many processes share one store without a daemon. Segments are leased with locks the kernel releases if a process dies, objects are published before anything refers to them, and an append-only op log records every operation so it can be undone.
  5. The same API at every tier. A local store, a per-machine daemon, a cache and a server answer the same requests, so a client never cares which one it talks to. The server has its first version, BraidHub; the caches and the daemon are planned (milestones 6 and 7).

Use it from your agent

Braid comes with instructions written for coding agents. In a project that is a git repository, ask your agent, whatever harness runs it:

Install braid in this project and set it up for agents, following https://braid.elffuss.com/agents.md (read it whole, with curl -fsSL)

It installs braid with cargo, tells you what in the project braid does not run, such as git hooks, offers to make a git remote if the project has none, imports the project's git history, and writes the rules for agents into the project's AGENTS.md with braid agents init. From then on, every agent session works in a braid workspace of its own, where git refuses to run, lands through braid, and tells you when what it landed is waiting for a sync to the git remote. Git stays the source of truth, and in a clone where braid is not set up, agents work with git as before. The instructions are part 1 of AGENTS.md, which the site serves as braid.elffuss.com/agents.md, next to an llms.txt.

Setting braid up in a project's git checkout: braid init, git told to ignore .braid, braid git import brings in the history, braid agents init writes the braid section into AGENTS.md, the section's rules are listed, and a new session starts in a workspace of its own under .braid/work

Set it up by hand

The same steps, for a git checkout on its main branch with nothing to commit, where git has a user.name and a user.email. agents.md says what to check first (git hooks, submodules, LFS, a branch that takes only pull requests) and what to do when a step fails.

cargo install --locked --git https://github.com/KikoCis/elffuss-braid --tag v0.1.1 elffuss-braid-cli
braid init                       # .braid/: the store and the agents' workspaces
mkdir -p "$(git rev-parse --git-path info)"
echo .braid >> "$(git rev-parse --git-path info/exclude)"   # git ignores braid, in this checkout only
printf 'name = %s\nemail = %s\n' "$(git config user.name)" "$(git config user.email)" > .braid/config
braid git import .               # the project's whole history
touch CLAUDE.md                  # only if agents work here with Claude Code
braid agents init                # the rules for agents, into AGENTS.md
git add AGENTS.md CLAUDE.md      # leave CLAUDE.md out if there is none
git commit -m "Set up braid for agents"
braid git import .               # braid's main takes that commit

What goes into your Markdown files

Agents follow braid because the project tells them to, in the files their harness reads at the start of every session. braid agents init writes them, and they are committed with git, so every clone and every new session has them:

Quick start

Braid stores history, moves it in and out of git bit for bit, and gives each agent a workspace of its own that lands on main in one short step.

git clone https://github.com/KikoCis/elffuss-braid
cd elffuss-braid
cargo build --release
export PATH="$PWD/target/release:$PATH"
SRC="$PWD"                       # any git repository will do; this one is at hand

braid init /tmp/demo
cd /tmp/demo
braid git import "$SRC"          # every branch and tag
braid log main -n 5
braid log main -- README.md      # only the changes to a path
braid blame main README.md       # who last changed each line
braid show main --json
braid fsck
braid stats        # objects by kind, and how they are stored: whole, deltas, chunks

Exporting writes the same commits back, with the same ids:

git init --bare /tmp/mirror.git
braid git export /tmp/mirror.git

Every operation is in the op log, and the newest can be undone, one at a time:

braid op log      # who did what, newest first
braid undo        # takes the whole import back

Ids can be checked with any BLAKE3 implementation, for example the reference b3sum tool:

b3sum --derive-key "elffuss-braid 2026 blob v1" README.md

Many agents, one repository

Each agent gets its own workspace. There is no staging area and no shared index: an agent commits what it changed and lands it, and braid rebases it onto whatever the others landed first.

export BRAID_AUTHOR="Ada Lovelace <ada@example.org>"
export BRAID_AGENT=agent-1           # recorded with everything this agent does
braid workspace add agent-1          # .braid/work/agent-1, tracking main
cd .braid/work/agent-1
echo 'fn main() {}' > main.rs
braid status
braid commit -m "Add main.rs"
braid land                           # fast-forward, or a rebase onto main

When two agents change the same lines, the second land exits with status 2, prints the conflicts as data and leaves main where it was. With --json, each conflict names its sides from the agent's point of view: base, branch (what is on the branch now) and workspace (its own change), with the hunks in conflict, and next says what to run: braid update, which rebases the change and writes git-style conflict markers. Fix the file, then braid commit (the change keeps its message unless -m gives another) and braid land.

The third agent asks for the conflict as JSON and gets the base, branch and workspace text of the line; braid update writes conflict markers into the file; the agent settles the line, commits and lands, and braid log shows the three agents' changesets on main

braid status --help, braid land --help, braid update --help and braid agents init --help describe every JSON field.

An agent that knows exactly what it changes needs no checkout at all, and can check that nobody changed the file under it:

braid change create --base main --set src/lib.rs=@new-lib.rs \
  --expect src/lib.rs=<blob id it read> -m "Fix the parser" --land main

New files that look like secrets (.env*, *.pem, id_*) or are larger than 1 MiB are not committed until braid track <path> says so: braid commit refuses while they wait, naming them, and --force leaves them out.

A changeset that landed and should not have is undone with another: braid revert <rev> makes a changeset that puts its files back, modes and links included, names the one it undoes in a reverts field, and lands it, rebased over whatever landed since. When later work touched the same lines, it stops with conflicts and exit status 2, as land does, and nothing moves. --no-land only makes the changeset, and a merge needs --mainline 1.

Keeping main green

braid verify runs the project's tests on the head of a branch and keeps braid/green/<branch> at the newest changeset that passed. When they fail, it bisects the changesets since the green one, along first parents, to find the first that fails, and with --revert it reverts that one and lands the revert. One run is one pass: run it after landings, or on a schedule.

braid verify --branch main --revert --json -- cargo test --workspace

Working with git

Repositories come in with their whole history and keep a git mirror.

braid git sync takes a branch of a git repository with its history; after agents land two changes in braid and a person pushes one to the git repository, the next sync merges both and pushes a fast-forward, and git log shows the original commits with their ids unchanged

BraidHub

BraidHub keeps repositories that agents on any machine land on. People and agents sign in with GitHub; a repository is private unless its owner makes it public; and each one can keep a GitHub repository as its mirror: every landing on its default branch is pushed there as a fast-forward, so the people who work with git keep doing so. The protocol braid speaks with it is documented. Signing up takes one click: https://braidhub.elffuss.com/login signs you in with GitHub and makes your account.

braid login                      # GitHub's device flow: open the link anywhere, enter the code
braid hub publish                # create the repository on the hub, upload every branch and tag
braid hub clone you/project      # on another machine: a linked copy, with a workspace on main
cd project/.braid/work/main
braid commit -m "Fix the parser"
braid land                       # lands on the hub, then moves the workspace onto the new head

Coding agents have their own guide (docs/hub-agents.md): sign in once per machine, ask the user once whether to publish the new projects they start (braid hub autopublish on|off keeps the answer), and work from the hub from then on.

Design

Status and roadmap

MilestoneScopeState
0Public repository, CI, object ids, braid hash-object✅ done
1Format v1: canonical codec, trees (flat and split), changesets, name rules; frozen✅ done
2Local store and op log: many processes, crash-safe, fsck, undo✅ done
3History and the git bridge: import, export, log, show✅ done
4Many agents on one machine: workspaces, land, conflicts, git sync✅ done
5Performance: deltas, chunking, derived indexes, blame, benchmarks against gitin progress
6Server: BraidHub with GitHub sign-in, landing over HTTP, GitHub mirrors and sparse clones; caching tiersfirst version; caching planned
7Daemon, virtual file system, WebAssembly coreplanned

Each milestone ships when its tests pass: golden vectors and fuzzing for the format, crash and many-process tests for the store, bit-for-bit round trips and differential tests against git for the bridge, deterministic simulation for landing.

What is honest about this

Measured against git

Each number is braid's time, or the size of its store, divided by git's for the same work on the same machine: below 1 braid is faster or smaller, above 1 it is slower or larger. They are medians from one run of bench/run.py, which describes every scenario, measuring braid at commit 5330054; the run held rounds back while other work kept the machine busy (--max-load). The numbers come from that one machine, and yours will differ: run the script before relying on any of them.

What was comparedbraid / gitReproduce
Import tmux 3.5a, 10,287 commits: braid init + braid git import vs git clone --no-local --bare17.6python3 bench/run.py --only import
Import it and check it out: braid init + braid git import + braid workspace add vs git clone --no-local17.1python3 bench/run.py --only import
Size after that import: du of .braid/store vs the bare clone after git gc --aggressive25.1python3 bench/run.py --only store
Status of a tree of 100,000 files, clean: braid status vs git status, no untracked cache, no fsmonitor2.6python3 bench/run.py --only status
Status of that tree, clean: braid status vs git status with core.untrackedCache=true, no fsmonitor5.8python3 bench/run.py --only status
Status of that tree, 10 files modified: braid status vs git status, no untracked cache, no fsmonitor3.0python3 bench/run.py --only status
Status of that tree, 10 files modified: braid status vs git status with core.untrackedCache=true, no fsmonitor5.7python3 bench/run.py --only status
Commit one changed file of that tree: braid commit vs git add + git commit5.0python3 bench/run.py --only commit
Commit one new file in a directory of 20,000 files, 200 times: braid commit vs git add + git commit1.8python3 bench/run.py --only wide
Commit one new file in that directory without a working copy, 200 times: braid change create --land vs git add + git commit0.9python3 bench/run.py --only wide
4 agents land 10 commits each, at once: braid commit + braid land, a workspace each, vs git commit + git push, a clone each, with git pull --rebase and a new push when rejected0.4python3 bench/run.py --only agents
8 agents, the same0.3python3 bench/run.py --only agents
16 agents, the same0.2python3 bench/run.py --only agents
Newest 1,000 changesets of tmux: braid log -n 1000 vs git log --first-parent -n 1000 --format=%H after git gc --aggressive1.7python3 bench/run.py --only history

braid log -- <path> and braid blame came after this run, so it does not measure them; the script does now.

At commit 5330054, braid was slower than git at most of this, for the reasons below. Much of it has been worked on since: braid now stores deltas and cuts large files into chunks, walks the working copy in parallel through directory handles, edits a large directory in place, and looks objects up through the store's indexes instead of mapping the whole store first. The ratios above show none of that; it takes a new run of the script to say how much it changed.

Braid is faster where it was designed to be: many agents landing at once. A push to git goes in only from a clone that has the latest commit, so each agent that loses the race fetches, rebases and pushes again: on average 1.1 times per push with 4 agents, 2.5 times with 8 and 5.2 times with 16. braid land rebases onto whatever landed first, in one short step that landings take in turn, so no agent retried, and nearly every landing was such a rebase.

Part of Elffuss

Braid is part of Elffuss, a family of tools for building software with agents.

Prior art and credits

Contributing and security

License

Apache-2.0. Copyright 2026 UtopiaIA. See NOTICE.


En castellano

Braid es un sistema de control de versiones escrito de cero en Rust, para repositorios en los que muchos agentes aterrizan cambios a la vez.

Parte de las ideas que Anthropic contó en público sobre Scion, su sistema interno. Es una implementación independiente, sin código de Anthropic y sin relación con la empresa.

Hoy, en su versión 0.1, guarda historia, la mete y saca de git bit a bit, y cada agente tiene su propio espacio de trabajo y aterriza en main en un paso corto.

Para trabajar desde varias máquinas está BraidHub: se entra con GitHub, los repositorios son privados salvo que su dueño diga lo contrario, y cada uno puede tener un repositorio de GitHub como espejo, al que el hub empuja cada aterrizaje. Los agentes tienen su propia guía en https://braidhub.elffuss.com/agents.md: preguntan una sola vez si deben publicar ahí los proyectos nuevos que empiezan y, desde entonces, trabajan desde el hub. Para darte de alta basta un clic: https://braidhub.elffuss.com/login te hace entrar con GitHub y crea tu cuenta. Las fases dicen qué llega después y qué pruebas tiene que pasar cada una.

Para usarlo en un proyecto, pídeselo a tu agente:

Instala braid en este proyecto y configúralo para agentes siguiendo https://braid.elffuss.com/agents.md (léelo entero, con curl -fsSL)

Lo instala con cargo, te avisa de lo que braid no ejecuta, como los hooks de git, importa la historia de git del proyecto y, con braid agents init, escribe en su AGENTS.md las reglas para que cada sesión trabaje en su propio espacio de trabajo y aterrice sus cambios con braid.