AI in practice from Performance Metrics

From the engine room #6: Four levels of branches and a backlog in git

Written by Thomas Petersen | Nov 23, 2026, 2:15:00 PM

A story that has been judged (#5) has to get into the code. It sounds simple, but the runner runs up to eight sessions at a time in one repo, and several epics work in the same area. This part is about how they avoid treading on each other's toes, how the work gets up to master, and where the runner keeps track of it all: in a git repo of its own.

Four levels

Branches are split into four levels, and each level has one who merges.

  • master is production. Direct push is rejected by Azure DevOps. Everything goes through a pull request, and I merge it.
  • runner/main is the AI's integration branch. The runner merges finished epic groups up here and keeps it up to date from master.
  • runner/epic/<group> gathers an epic group. Epics that work in the same area share a group and thus a branch.
  • runner/story/<group>/<story> is one story. Each story has its own branch and its own worktree, so several stories can be built at the same time without sharing a working directory.

When a story is approved, a session first merges the epic branch into the story, so it is on the latest, and then the story into the epic branch. The runner builds afterwards. My own changes go via a work branch and a pull request to master, like everyone else's.

When may two stories run at the same time?

Two stories on the same epic branch can harm each other in three ways. They can change the same files, so the merge gives a conflict. They can both regenerate the same generated code, for example the API clients, so one overwrites the other's. Or they can both build fine on their own and break when they meet.

The first attempt at a rule was a flag on the epic: parallel: yes or no. On 12 and 14 September the work got stuck twice, and both times the solution was an operator flipping the flag by hand. One time it was flipped for an hour. A third time, a hand edit of the flag collided with the runner, which was moving the same file. The flag did not measure the conflict. It measured a proxy for it. And every time the flag was wrong, work stood still that could have been running.

Since 14 September the runner decides from what the story will actually touch:

  • The footprint is the union of the file lists of the story's tasks from refine. Two stories that share a file or a folder do not run at the same time. A design document counts per section, not as one file. A whole project or a whole test tree may not be one entry, because it locks everything else. A story that did that held 14 others back for over half an hour.
  • Generated code comes in two kinds: API clients and database context. Two stories that regenerate the same kind run one after the other. Others do not.
  • A per-branch cap of two stories at a time by default, and only one merge at a time.
  • Order is set as dependencies: on the story. That was the only part the flag could actually be used for.

parallel: no still exists, but only as a way to opt out for a single epic. The footprint is not perfect. When we measured, 7 of 174 changed files, 4%, were not in the story's file list, and they were exactly the files many stories touch. That risk is accepted, because the post-merge build catches the rest.

In access per data type, never more than two stories ran at the same time, and that happened six times. Refine itself wrote down when two stories would be run one after the other: "both regenerate WebApi clients", and "shares the registration file with two other stories".

Build after merge

When a story is merged into the epic branch and the merge is not a plain fast-forward, the runner builds the branch's tip with the commands the story's validation plan specifies. That catches the third way: two stories that are each green on their own, but not together. If the merge is a fast-forward, the tip is the commit the story's own gate has just built, and it is not built again. If the build is red, every active epic in the group is blocked, so the failure does not spread to the next story.

In access per data type, 19 of the 32 merges were fast-forwards. The other 13 were built, and all 13 were green. One of the 19 still landed with a failing test, because the story's validation plan did not run it (#7).

The last manual step

Until mid-October I merged finished epics up myself: from the epic branch to runner/main and on to master. On 14 October the blocked lane became autonomous (#7), and then the merge chain was the only thing I still did by hand. That was inconsistent. The same day it was grilled into a design.

The runner merges a group up when it is quiescent: no epic in the group is being planned, is active or is blocked, every story is done, archived or in the inbox, no UX inspection is in progress, and the epic branch has something runner/main does not have. Then it merges runner/main into the epic branch in the group's own worktree, builds it all and only then opens the pull request. It validates before, not after. On 21 October it turned out that 40 of 41 merge-ups had not run a single command, because the plan was empty. That was fixed the same day.

Each merge gets an entry with commits, files, pull request and merge commit, and a line on how to roll it back: git revert -m 1 on a work branch and then my own merge to master.

The design has a level flag. At runner-main the runner stops at runner/main. At master it also takes the last step. The plan was that I would set master once the first merge-ups had gone cleanly. I have not done that. Every single merge-up the runner has started has run with runner-main. The last step is still mine.

Two alternatives were rejected. One was to batch master merges per day or per a number of epics. That gives bigger jumps and harder reverts and saves nothing. The other was a decision card for me with automatic acceptance after 24 hours. The point was that it should not happen without my acceptance, and a card that accepts itself is the same as no acceptance.

The runner does one thing on the master side: when master has something runner/main does not have, because my own work branches have landed, it synchronises runner/main from master before it touches a group. Of the 251 merges the runner has made since 14 October, 129 are such synchronisations, and 122 are epic groups.

On the very first day, a merge-up went red. A group tried to build a project that had been moved out of the repo the week before. The group was blocked, and nothing reached runner/main.

In access per data type all four merge-ups went through on the first attempt. The third built 12 commands in about 35 seconds. While the epics were running, runner/main moved because other groups were merged up, and the runner then merges runner/main down into the epic branch. That happened 14 times between 4 and 9 November. The first three reached master at 9:37, 9:58 and 9:17, after between six and 24 hours, depending on when I got to it. The fourth is from 19 November, carries two follow-up fixes and is waiting for me.

A backlog in git

Where is the backlog? In a git repo of its own, the state repo. That was decided on 13 August and taken into use on 2 September.

Before, stories, tasks and logs were outside git on one machine, and epics were in the product repo, on whatever branch you happened to be on. The latter was wrong in itself, and the former made it impossible to run the runner on a different machine from the one I write on. Now it does.

The question that split the files was: who changes the file? The process files, that is contracts, templates, documentation and configuration, stay in the product repo, because I am the one who changes them, and they have to follow the code. Epics, stories, tasks, logs and insights are state. It is changed by the runner all the time and lives in the state repo. So does the telemetry, because it is the only thing the reports on consumption and key metrics calculate from. It takes up just under 16 MB across a good 21,500 files.

The rules are few:

  • There is one branch. Both machines push directly to it, and the history may only grow. Force-push is rejected for the runner's user.
  • Every change of state is its own commit.
  • The runner pulls before every planning pass and again between commit and push.
  • Changes that do not touch the same files are rebased automatically. A real conflict blocks, and that has to be visible.

There have been collisions. On 20 October a checkout that was 175 commits behind assigned an epic id that was already in use. On 5 November two stories got the same id two seconds apart, one created on my machine and the other by the runner. There are now checks for both: at assignment, at push and before a session is started.

The state repo has 37,045 commits since August. On 17 November there were 996. Of the 4,132 commits since 12 November, 4,121 were made by the runner. Every status change can be found, with who made it and when.

The decision

Isolate where it is cheap: a worktree per story costs almost nothing. Measure the conflict, not a proxy for it. Validate before merge, not after. And master is mine. Not because the runner couldn't, but because the last step is the place where I see the result before it lands.

The backlog lives in git for the same reason as the code: everything has to be findable afterwards, and everything that has happened is a commit.

The next part is about what happens when something goes wrong: a task that gets stuck, and a runner that goes down at 3:00 in the morning (#7).

Numbers as of 19 November 2026.

—
The code is written by AI. So is the text. The decisions are mine.