Elffuss BraidHub

utopia-ia/elffuss-braid public

Docs: agents, short ids, status, and the reports of land and update

The README's workspace section shows BRAID_AGENT and says what agents
can read now: the conflict sides base, branch and workspace with the
next command, the fields land and update share, what status says about
being behind and what blocks a commit, the agent of every changeset,
short ids, A/M/D/T in show and diff, and that commit refuses while new
files wait for braid track.

The design describes the agent and rebased-from extra fields, short
ids, op log descriptions written once a landing's outcome is known,
the names of conflict sides and their 0-based line ranges, commit's
refusal and status's view of it, and what a resolution keeps.
Changeset4e69006693c7f0fd539ee99e48e04c96d6fed4cadd99155720fb6e2fb78e02fc
AuthorKikoCis <KikoCis@users.noreply.github.com> · 2026-10-16 00:00 +02:00
CommitterKikoCis <KikoCis@users.noreply.github.com> · 2026-10-16 00:00 +02:00
Parents44bd6adbea21

Browse the files at this changeset

2 files changed

modified README.md +31 −4
@@ -137,6 +137,7 @@
137137
138138 ```bash
139139 export BRAID_AUTHOR="Ada Lovelace <ada@example.org>"
140+export BRAID_AGENT=agent-1 # recorded with everything this agent does
140141 braid workspace add agent-1 # ./agent-1, tracking main
141142 cd agent-1
142143 echo 'fn main() {}' > main.rs
@@ -146,9 +147,34 @@
146147 ```
147148
148149 When two agents change the same lines, the second `land` exits with status 2,
149-prints the conflicts as data (`--json` for agents) and leaves `main` where it
150-was. `braid update` then rebases the change and writes git-style conflict
151-markers; fix the file, `braid commit`, `braid land`.
150+prints the conflicts as data and leaves `main` where it was. With `--json`,
151+each conflict names its sides from the agent's point of view: `base`,
152+`branch` (what is on the branch now) and `workspace` (its own change), with
153+the hunks in conflict, and `next` says what to run: `braid update`, which
154+rebases the change and writes git-style conflict markers. Fix the file, then
155+`braid commit` (the change keeps its message unless `-m` gives another) and
156+`braid land`.
157+
158+- `land` and `update` report the same fields: where each changeset went
159+ (`landed`, from its id to the one that holds it now), the paths merged, the
160+ paths of the working copy they wrote or removed, and for a landing its op
161+ log entry.
162+- `braid status --json` says how far the branch is ahead (`behind_by`), which
163+ changesets have not landed, including one whose rebase is in progress, and
164+ whether a commit would go through (`ready_to_commit`), with every reason
165+ it would not (`blocking`), which `braid commit` refuses with too.
166+- Every changeset names the agent that made it, and keeps it when it is
167+ rebased; `braid log`, `braid show` and `braid op log` show who did what,
168+ and the op log says what each landing did. Signatures use the local time
169+ zone.
170+- Revisions can be given as short ids, six hex digits or more; an ambiguous
171+ one is an error that lists the candidates.
172+- `braid show` and `braid diff <from> <to>` list the files a change adds,
173+ modifies, deletes or turns into another type (`A`, `M`, `D`, `T`), as
174+ `git diff --name-status` does.
175+
176+`braid status --help`, `braid land --help` and `braid update --help` describe
177+every JSON field.
152178
153179 An agent that knows exactly what it changes needs no checkout at all, and can
154180 check that nobody changed the file under it:
@@ -159,7 +185,8 @@
159185 ```
160186
161187 New files that look like secrets (`.env*`, `*.pem`, `id_*`) or are larger than
162-1 MiB are not committed until `braid track <path>` says so.
188+1 MiB are not committed until `braid track <path>` says so: `braid commit`
189+refuses while they wait, naming them, and `--force` leaves them out.
163190
164191 ## Working with git
165192
modified docs/design.md +38 −10
@@ -43,6 +43,16 @@
4343 - Large directories are split with a rule that depends only on entry names, so
4444 an edit rewrites a few small nodes instead of the whole directory, and equal
4545 contents always have equal ids.
46+- A changeset may carry extra fields, ordered key and value pairs that are
47+ part of its hash. Braid writes two: `agent`, the label of the agent that
48+ made the changeset, and `rebased-from`, the changeset a rebased one comes
49+ from. A rebase keeps the original's other fields, so `agent` names the
50+ agent that made the change wherever it lands. The git bridge writes extra
51+ fields as commit headers.
52+- Ids are shown as their first 12 hex digits, and any unique prefix of six
53+ digits or more names an object; the lookup scans the store's in-memory map
54+ of ids, and a prefix that several objects share is an error that lists
55+ them.
4656
4757 ## Store
4858
@@ -60,7 +70,10 @@
6070 Only files that can no longer change are memory-mapped.
6171 - **Op log.** Branch heads and the history of operations live in an
6272 append-only log behind a short lock. Every record names the agent that wrote
63- it, so `braid op log` shows who did what and `braid undo` can step back.
73+ it, so `braid op log` shows who did what and `braid undo` can step back. A
74+ record's description is written inside the transaction, once the outcome
75+ is known: a landing says how it went, which changeset landed as which, and
76+ how many paths it merged.
6477 - **Publish order.** Objects, then their journal entries, then a barrier, then
6578 the op log record that refers to them. The op log never points at an object
6679 that is not durable.
@@ -90,10 +103,13 @@
90103 runs it in order, grouping several landings into one sync.
91104
92105 Conflicts are reported as data, not as markers in a file: the path, the kind,
93-the base, ours and theirs, and the hunks. Braid is stricter than git about
94-structural conflicts: a file against a directory, two names that differ only in
95-case or Unicode normalisation, a directory removed under a new file, and the
96-same file renamed two ways.
106+what the base, the head (ours) and the change (theirs) have there, and the
107+hunks, with line numbers counted from 0 and the end excluded. The command line
108+names the sides from the caller's point of view: `base`, `branch` and
109+`workspace`. Braid is stricter than git about structural conflicts: a file
110+against a directory, two names that differ only in case or Unicode
111+normalisation, a directory removed under a new file, and the same file renamed
112+two ways.
97113
98114 **Invariants.** A branch only moves forward. A branch never contains a
99115 conflict. No value is overwritten except by a change whose base already
@@ -113,7 +129,8 @@
113129 change one workspace at once; different workspaces never wait for each
114130 other, except for the short transaction in which a landing moves a branch.
115131 - New files that look like secrets (`.env*`, `*.pem`, `id_*`) or are larger than
116- 1 MiB need an explicit `braid track`.
132+ 1 MiB need an explicit `braid track`. Until then `braid commit` refuses,
133+ naming them, and `--force` leaves them out.
117134 - Status uses a stat cache (modification time, size, inode, type, blob id),
118135 with the usual guard: a file whose modification time is not strictly older
119136 than the start of the scan that cached it, read from the workspace's own
@@ -129,18 +146,29 @@
129146 normalisation; names that would collide there, or that the platform cannot
130147 hold, are refused before anything is written. Untracked files in the way
131148 stop a checkout too. Nothing from repository content is ever run.
132-- `braid commit` records the working copy as a changeset on the base.
133- `braid land` puts the workspace's changesets on its branch in one op log
149+- `braid commit` records the working copy as a changeset on the base. It
150+ refuses while something blocks it, listing every reason at once: conflict
151+ markers left in a file, a conflict that is not about content and not marked
152+ resolved, a new file waiting for `braid track`. `braid status` lists the
153+ same reasons as `blocking`, with `ready_to_commit`; it also counts how far
154+ the branch's head is ahead of the workspace along first parents, stopping
155+ after 5000 changesets, and lists the changesets that have not landed,
156+ including those of a rebase in progress.
157+- `braid land` puts the workspace's changesets on its branch in one op log
134158 transaction: the engine fast-forwards or rebases them onto the head, and the
135159 branch moves with a compare-and-swap. The working copy then follows, writing
136160 only the difference. On conflicts the branch does not move, the conflicts
137- come back as data, and the command exits with status 2.
161+ come back as data, and the command exits with status 2. `land` and `update`
162+ report the same fields: where each changeset went, from its id to the one
163+ that holds it now, the paths merged, the paths of the working copy written
164+ or removed, and on conflicts the command to run next.
138165 - `braid update` brings a workspace onto its branch's head, rebasing its own
139166 changesets without moving the branch. On conflicts, the working copy gets
140167 the head's tree with the change's clean paths and git-style markers for
141168 content conflicts; a rebase is then in progress, `braid resolve` settles the
142169 other conflicts, and the next `braid commit` records the resolution on the
143- head, refusing while markers remain.
170+ head, refusing while markers remain. The resolution keeps the rebased
171+ changeset's author, extra fields and message, unless `-m` gives another.
144172 - A changeset can also be made without any working copy: `braid change
145173 create` takes the base, the new contents and the deletions, and can require
146174 what the base holds at each path first, so that an agent never overwrites