Skip to main content
This page walks one workflow from open to land. The code comes from the supplier-decisions example. An operator stages a retroactive revocation of a supplier certification in a branch. A different person reviews the branch and lands the exact version they reviewed. The client code uses two clients from connect(url, { token }), one per person: operator and reviewer.

The five steps

ctx.branch, ctx.land and ctx.discard are grave acts: bijection check lists every function that performs them.

1. Open the branch

ctx.branch({ until }) begins a writable world over the head and returns the Branch. It ends at until unless something keeps it: here the correctionBranches table’s pin option keeps the branch readable while its fact exists, and the correction fact records the version the branch began over (sys.branches(branch).from). A branch lives at most as long as its version stays inside every table’s history (the shortest history, at most 30 days): one asking to live longer is refused BeyondHistory, and one naming no until lives exactly that long. Nothing a branch does holds history back.
To name the one person who may review, the author invites them:
requireLive refuses unless the call runs at the head (ctx.frame.in === null): branches open there.

2. Work in the branch

Branch work is ordinary application code. The client selects the branch with client.in(branch), and every write lands in the branch. This mutation refuses at the head, so the change can only be staged:
The exception is the landing’s replay of the branch’s calls: then ctx.frame.on carries { kind: "landing", branch }.
A task submitted in a branch stays in the branch: performers act only at the head, and landing submits it there.

3. Review the branch

The review reads what the branch changed since it began. Each table’s change log in the branch is table.changes.in(branch).since(base), and staged tasks are sys.tasks.changes.in(branch):
sys.branches(branch).changes is the branch’s whole log across every table of the app, each entry { table, key, before, after, version }. It is a log, not a net diff: fold it by table and key (the first before, the last after) for the net effect. A review that must prove the branch holds nothing else reads it whole. It never holds a sys table: staged tasks are read from sys.tasks.changes.in(branch), as above. An entry is a BranchChange. Register the app once and it is a union discriminated by table, whose before and after are that table’s facts:
bijection/register.ts
The invited reviewer’s query answers the diff, the supplier’s segments at the head and in the branch, and seen, the branch version of the latest change. seen is what the reviewer approves:

4. Land the exact version

ctx.land(branch, { seen, then }) applies the branch to its parent. It is one task submitted with the mutation’s writes, so it exists only if the mutation commits. seen is the branch version the lander reviewed: if the branch already moved past it, ctx.land refuses Conflict; if it moves before the landing, the landing settles Conflict. Either way nothing lands. Landing checks each root against the parent and earlier roots in commit order. A root whose reads and time premises still hold can use its recorded writes. The parent carries those reads and writes through total schema lenses. A table ending or a changed dependency sends the affected root through head’s code again. Head judges each root’s grants and guards. All roots land in one append. If it conflicts, the next attempt revalidates at a fresh parent version while the landing’s deadline lasts. A branch opened with under (see the lifecycle) can hold calls at several labels. The lander’s ctx.frame.under must clear that ceiling, and the lander’s live grants must still clear its ctx.frame.under when the landing is decided (LandClearance). When the landing writes a place below or beside the lander’s label, name a release from the landing function’s releases:: ctx.land(branch, { seen, then, release }). That place learns its own landed writes, its own version token and the commit’s public instant, and the release is recorded in sys.disclosures. A refused landing writes, moves and wakes nothing there.
Without an invitation, a reviewer can review and land in two steps: prepareReview records the reviewed seen, and landReviewed lands it.

5. Settle

Landing is a task. Its continuation receives t.result(sys.land): the version the landing committed, as the lander’s own version token, or Conflict.
The app tree places all of it:

The client flow

Asking again with the same once returns the same landing task, so a lost reply (Unknown) is safe to retry. With an invited reviewer:

Refusals you can meet

To end a branch without landing it, call ctx.discard(branch).