Elffuss BraidHub

utopia-ia/elffuss-braid public

Docs: braid revert, and keeping main green with braid verify

The guide no longer says there is no revert command, and the section braid
agents init writes tells a session what to do when verify reverted one of
its changesets.
Changeset5ec9b745eea15600100fdd4546f345a3e08540a94e1b0738edcb5aeab90fe406
AuthorKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 11:51 +02:00
CommitterKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 11:51 +02:00
Parents9e7f0f69e18e

Browse the files at this changeset

5 files changed

modified AGENTS.md +5 −2
@@ -396,8 +396,11 @@
396396 first. A landing undone leaves its changeset in the workspace that made
397397 it, ready to land again. A sync undone moves braid's refs back, but not
398398 the git remote: what it pushed stays there.
399-- A change that landed under other changes cannot be undone that way.
400- There is no revert command yet: land a change that puts the files back.
399+- A change that landed under other changes cannot be undone that way:
400+ `braid --agent agent-1 revert <changeset> --json` lands a changeset that
401+ puts its files back, rebased over what landed since. When later changes
402+ touched the same lines, it exits with status 2, `land` in its JSON has
403+ the conflicts, and nothing moves: undo the change by hand in a workspace.
401404 - To take braid out of a project: land what the workspaces hold, sync it
402405 and run `git pull --ff-only`; remove each workspace
403406 (`braid workspace remove <name>`, which refuses while work has not
modified README.md +41 −0
@@ -326,6 +326,47 @@
326326 1 MiB are not committed until `braid track <path>` says so: `braid commit`
327327 refuses while they wait, naming them, and `--force` leaves them out.
328328
329+A changeset that landed and should not have is undone with another:
330+`braid revert <rev>` makes a changeset that puts its files back, modes and
331+links included, names the one it undoes in a `reverts` field, and lands it,
332+rebased over whatever landed since. When later work touched the same lines,
333+it stops with conflicts and exit status 2, as `land` does, and nothing
334+moves. `--no-land` only makes the changeset, and a merge needs
335+`--mainline 1`.
336+
337+### Keeping main green
338+
339+`braid verify` runs the project's tests on the head of a branch and keeps
340+`braid/green/<branch>` at the newest changeset that passed. When they fail,
341+it bisects the changesets since the green one, along first parents, to find
342+the first that fails, and with `--revert` it reverts that one and lands the
343+revert. One run is one pass: run it after landings, or on a schedule.
344+
345+```bash
346+braid verify --branch main --revert --json -- cargo test --workspace
347+```
348+
349+- The command runs as given, with no shell, in a fresh copy of the
350+ changeset's files in the system's temporary directory: outside the
351+ repository, so every run builds from scratch. `BRAID_TOKEN` and the other
352+ `BRAID_HUB` variables are taken out of its environment, and
353+ `BRAID_VERIFY_CHANGESET` and `BRAID_VERIFY_BRANCH` say what it tests.
354+ After `--timeout` (10 minutes by default) it is killed with every process
355+ it started.
356+- A failing run is run again (`--reruns`, once by default) before it counts;
357+ one that then passes is `flaky`. With no green ref yet, verify tests only
358+ the head, unless `--from` names a changeset to bisect from.
359+- It never reverts a merge, nor a revert it made itself, which it keeps in
360+ `.braid/verify/<branch>.json`, and it lands at most three reverts an hour
361+ (`--max-reverts-per-hour`). The green ref does not move after a revert:
362+ the next pass tests the new head. `--dry-run` reports and changes nothing.
363+- Bisecting tests each changeset as it is: an earlier revert in the range is
364+ not undone first, so a culprit found among reverted work needs a look.
365+- Exit status 0 means green (`pass` or `flaky`), 4 red (`red`, `reverted`,
366+ `refused` or `no_culprit`), 2 a revert that conflicts, and 1 an error.
367+ `braid status --json` shows the green changeset as `green`, and
368+ `braid verify --help` describes every JSON field.
369+
329370 ## Working with git
330371
331372 Repositories come in with their whole history and keep a git mirror.
modified crates/cli/src/agents.rs +2 −0
@@ -722,6 +722,8 @@
722722 standard error, even with `--json`.
723723 - **Before a new task**, `braid --agent agent-1 update` brings your
724724 workspace onto `{branch}`.
725+- If `braid verify` reverted a changeset of yours, fix it and land a new
726+ changeset.
725727 - **On a hub:** when `braid hub status` names a hub (the repository was
726728 published on [BraidHub](https://braidhub.elffuss.com) or cloned from it;
727729 elsewhere it says the repository is not linked), `land` and `update` go
modified docs/design.md +10 −0
@@ -172,6 +172,16 @@
172172 normalisation, a directory removed under a new file, and the same file renamed
173173 two ways.
174174
175+A revert is a landing like any other. The revert `R` of a changeset `C` has
176+`C` as its only parent, the change list from `C`'s tree back to its first
177+parent's, and a `reverts` extra field naming `C`. Landed on a head that moved
178+past `C`, it is rebased path by path with `C` as the base, the head as ours
179+and `C`'s parent as theirs: later work on other lines stays, and later work
180+on the same lines is a conflict. `braid verify` lands the reverts it makes
181+the same way; which reverts it made, it keeps in a file of its own rather
182+than trusting the `reverts` field, which anyone can write. Its green ref,
183+`braid/green/<branch>`, lives in braid's own namespace and is never exported.
184+
175185 **Invariants.** A branch only moves forward. A branch never contains a
176186 conflict. No value is overwritten except by a change whose base already
177187 contained it. An acknowledged landing is durable. Readers only see durable
modified site/agents.md +5 −2
@@ -396,8 +396,11 @@
396396 first. A landing undone leaves its changeset in the workspace that made
397397 it, ready to land again. A sync undone moves braid's refs back, but not
398398 the git remote: what it pushed stays there.
399-- A change that landed under other changes cannot be undone that way.
400- There is no revert command yet: land a change that puts the files back.
399+- A change that landed under other changes cannot be undone that way:
400+ `braid --agent agent-1 revert <changeset> --json` lands a changeset that
401+ puts its files back, rebased over what landed since. When later changes
402+ touched the same lines, it exits with status 2, `land` in its JSON has
403+ the conflicts, and nothing moves: undo the change by hand in a workspace.
401404 - To take braid out of a project: land what the workspaces hold, sync it
402405 and run `git pull --ff-only`; remove each workspace
403406 (`braid workspace remove <name>`, which refuses while work has not