Data branches and what-ifs
A data branch is a sandbox of the lake. It starts from main at a point you choose and sees a fixed snapshot from then on, while main keeps moving. Everything the platform does can run on it: actions with their writeback, pipelines, sync, agents, evaluations, SQL and the audit log. When you are done you look at the diff, merge it if it should stand, or discard it. A what-if is the shortest use of one: run an action on a throwaway branch and see what it would change
In the platform today
- Data branches, marks, diffs, merges, evaluations on a branch and what-ifs run in the platform service with tests, on the demo airline
- They branch the lake's data, not the ontology's definitions: changes to object types and actions are made in change sets, which preview on a throwaway data branch and are described on branches and proposals
- Data branches have a screen in Data, then Data branches, and a merge is applied table by table rather than as one transaction across tables
- Changing pipelines on a branch
- A signed-in person. A branch belongs to whoever created it: only they and administrators can see, use, merge or discard it
- Administrator to create a named mark
- For the lakeFS store, a reachable lakeFS server and its keys; the built-in store needs nothing
How a branch works
Creating a branch records a branch point: one Delta Lake version per table, called its pins. A read of a table the branch has not written goes through to the parent at the pinned version, so the branch sees a fixed snapshot. The first write to a table gives the branch its own copy, and every later write lands there. Versions, history and the change data feed carry on from the branch point, and a diff can read the branch point back by version
| Store | Where copies live | When it is used |
|---|---|---|
| Built in | In the lake, sharing unchanged data files with the source | Always available, and the default |
| lakeFS | One lakeFS repository per lake and one lakeFS branch per branch, one lakeFS commit per Delta commit | When the service is set to use lakeFS, or to choose it when lakeFS is reachable and its keys are set |
Main stays in the plain lake folder with either store, so a merge is the same row-level merge for both
Create a branch
A branch starts from main or another branch, at its current versions, at a named mark, at a point in time through Delta time travel, or at versions you list. The built-in mark seeded is the lake right after its first full refresh, which is what evaluations usually start from
{ "name": "swap-411-test", "from": "main", "mark": "seeded",
"description": "Try the 411 swap against the morning as it was seeded" }
| Field | Meaning | Default |
|---|---|---|
name | 1 to 80 characters: a to z, 0 to 9, ., - and _, not main | Required |
from | The parent branch | main |
mark, asOf, versions | The branch point: a named mark, a timestamp, or a map of table to version | The parent's current versions |
backend | builtin or lakefs | Set per implementation |
Work on a branch
Any /api/v2 route runs on a branch when the request carries the X-MSO-Branch header or ?branch=. Object reads, queries, actions, proposals, pipelines, agent runs, evaluations, SQL and the audit check then use the branch's lake. Actions write back to the branch's own copies of the raw tables, and writeback defined as calls to a system's API makes no outside call on a branch, so a test never reaches a source system. Signed deliveries and rows pushed by source systems through inbound push always land on main. A retention purge deletes its rows in every open branch as well as in main. The model gateway stays main's, so model spend on a branch is counted once with everything else
POST /api/v2/actions/swap-aircraft:run HTTP/1.1
X-MSO-Branch: swap-411-test
Content-Type: application/json
{ "parameters": { "flight": "MKA214-20261023", "newAircraft": "411",
"reason": "Test the swap" } }
Diff, merge and discard
The branch record includes its diff. Per table, it lists rows added, changed and removed against the branch point, by key: _key for object tables, the step key for pipeline outputs, the writeback key for source tables, the id column for operational tables, keys set under branches.keys, or else a unique *_id column. A table with no key is compared by whole row. Per object type, it lists objects created, modified and deleted with their values before and after. A diff shown to a person respects their access labels, row policies, hidden properties and SQL grants
Merge applies the branch's changes to its parent, table by table, optionally limited to tables, and dryRun shows what would merge. If the parent changed any of the same rows since the branch point, the merge is refused with CONCURRENCY_CONFLICT and a report of the conflicting rows, and nothing changes. A branch with open child branches cannot merge
The branch's audit events are not copied into main, so main's hash chain stays intact. Main's audit gets one branch.merged event that names the branch's audit head and lists its events. Sync progress is not merged either; the next sync on main catches up. POST /api/v2/branches/{id}:discard closes a branch without merging
Evaluations on a branch
{ "suite": "aog-desk", "mark": "seeded" }
An evaluation suite runs on a fresh branch cut at a mark, a time or versions, and the branch is discarded afterwards unless keep is true. This is how a suite whose cases need the morning's open situations still passes after the morning's work has been approved on main
What-ifs
{ "action": "ground-aircraft",
"parameters": { "aircraft": "703", "reason": "What if 703 is grounded" } }
A what-if runs one action on a throwaway branch with its writeback, rebuilds the pipelines and syncs the objects, unless rebuild is false. It returns the action result, the objects that would change with before and after values, the row counts per table, the builds and syncs, and the pipeline expectations that would fail, with those that fail only because of the action marked as newly failing. The branch is discarded afterwards unless keep is true. Main is never touched
{
"branch": { "id": "…", "name": "what-if-ground-aircraft-x7k2qp", "kept": false },
"objects": [
{ "objectType": "aircraft", "created": 0, "modified": 1, "deleted": 0,
"objects": [ { "op": "modified", "key": "703",
"properties": ["status", "statusReason", "statusSince"],
"before": { "status": "In service", "…": "…" },
"after": { "status": "AOG", "…": "…" } } ] },
{ "objectType": "flight", "created": 0, "modified": 3, "deleted": 0, "objects": ["…"] }
],
"tables": [ { "table": "raw.mis_aircraft", "added": 0, "changed": 1, "removed": 0 }, "…" ],
"expectations": { "checked": 41, "failing": [], "newlyFailing": 0 }
}
API
| Endpoint | Does |
|---|---|
GET, POST /api/v2/branches | Lists the caller's branches, or creates one |
GET /api/v2/branches/{id} | The branch with its diff, up to 1,000 rows per table |
POST /api/v2/branches/{id}:merge, :discard | Merges into the parent, or closes the branch |
GET, POST /api/v2/branches/marks | Named branch points; creating one is for administrators |
GET /api/v2/branches/status | Which store is in use and whether lakeFS is reachable |
POST /api/v2/branches/evaluations | Runs a suite on a fresh branch |
POST /api/v2/branches/what-if | Runs an action on a throwaway branch |
X-MSO-Branch or ?branch= on any route | Runs that request on the branch |
Limitations
- Branches hold data, not definitions. A branch reads the same ontology, pipelines and actions as main
- A merge is applied table by table. It checks every table for conflicts first, but it is not one transaction across tables
- A branch is private to its creator and administrators; it cannot be shared for review
- Model calls made on a branch use main's gateway and count against main's budgets
- Diffs return up to 1,000 rows per table; larger changes are counted but not listed
- The Data branches screen, with what-ifs and evaluations on a branch, is in Data, in the app when connected to the platform service