Skip to the content
Krizaka Blog

39

Two agent teams, the same files: a merge train lands both, no collision

Nov 19, 20269 min read

What I faced, Two agent teams changing the same files without knowing it; What we built, a gate that sees the overlap before the pull request, a train that lands one after the other

Ink and watercolor drawing of a small railway yard at dusk: two sidings meet at one switch, each with a flat wagon carrying the same stack of papers with orange tags; a small engine takes the first wagon towards the lit station, the second waits at a red signal, and a falcon watches from the top of the signal

A few days ago, we posted on LinkedIn the readable log of an agent team at work. The picture carried a plain note: it is a simulation, we show the idea, not our code. This time it is not a simulation. It is the same console, but it replays the log of a real run, on 19 November, on Verikora, our product whose code is public. Anyone can open and check every pull request I name here.

The question is simple. When several agent teams work at the same time on the same product, what happens when two of them touch the same file without knowing it? Among people, it is stepping on each other's toes: two changes that collide, a conflict to untangle, work to redo. We wanted to see, on a real and measured case, whether our way of working avoids it.

The idea, in broad strokes

It stays a technology of our own, but the idea fits in four sentences.

Several agent teams work at the same time, each in its own lane, on its own ticket, without talking to each other. Before a team opens its pull request, a gate compares its files with those of the pull requests already open: if two teams touch the same thing, it sees it before they collide. Then a merge train lands the pull requests on the main branch, one at a time, each on the latest version. And when a pull request rests on another (a stacked PR), the train waits for the first to land, then replays the second on top: the replay.

Nobody tells the teams to avoid each other. The point is to see whether the system is enough.

19 November, as the log wrote it

We launched two agent teams, separately, on two real Verikora tickets. Team A was fixing a label: a blocking finding in a file must read “À corriger” (to fix) everywhere, in the header, the library and the home. Team B was fixing an upload: a 24-megapixel phone photo failed with no reason. Two unrelated subjects, but both touched the site's file that describes documents, and the four files of the interface's words. Nobody had planned it.

The console below replays the run's log, line by line, in UTC. It is written by the tool that watched the run, and copied as it is into this blog.

real run, 2026-11-19

verikora — the run’s log (UTC)
§ two teams start, each on its own ticket
16:18  team A  team A starts (an agent session)
16:18  guard   refuses a command of team A: the code index is asked before any file is read (ticket interne)
16:21  team B  team B starts (an agent session)
16:21  guard   refuses a command of team B: the code index is asked before any file is read (ticket interne)
16:25  team A  commits « fix(report): a blocking finding makes the header, the library and the… »
16:25  team A  commits « chore(quality): lock the no-enum-string-compare gain (9 to 8) »
16:30  team A  commits « fix(report): the mobile row and the shared client say « À corriger » … »
16:38  team A  opens verikora#889: fix(report): a blocking finding reads « À corriger » on the header, the library and the home
16:38  train   boards #889: it is the head of the train
16:40  team B  commits « fix(upload): a large phone photo is accepted within the upload's time… »

§ the gate sees the overlap
16:44  guard   the gate sees the branch share apps/web/lib/documents.ts, apps/web/messages/console/en.json, apps/web/messages/console/fr.json, apps/web/messages/en.json, apps/web/messages/fr.json with #889: noted, a fix is not held back
16:44  team B  opens verikora#890: fix(upload): a large phone photo is accepted within the upload's time, never a 504 with no reason
16:44  github  team A (#889) and team B (#890) both change apps/web/lib/documents.ts, apps/web/messages/console/en.json, apps/web/messages/console/fr.json, apps/web/messages/en.json, apps/web/messages/fr.json
16:47  team A  commits « fix(report): the home's binders read « À corriger » for a collection … »
16:49  train   #889 skipped: #889 red: ci / CI gate (head 1783480): stop
16:49  train   boards #890: it is the head of the train

§ a pull request stacked on the first
16:54  guard   the gate records the branch as stacked on #889: the train lands it after its base
16:54  team A  opens verikora#891 (stacked on #889): fix(report): the home's binders read « À corriger » for a blocking finding
17:01  team A  pushes a fix of its own PR #889, no shared file: « fix(report): the database test reads « À corriger » for its blocking … »

§ the train lands the first two
17:31  train   lands #890
17:31  train   verikora#890 merged into main
17:31  team B  team B closes: success, 71 min, 81 turns
17:32  train   boards #889: it is the head of the train
17:45  train   merges main into #891 (update before landing)
17:52  train   verikora#889 merged into main

§ the stacked one meets a conflict
17:54  train   lands #889
17:54  train   boards #891: it is the head of the train
17:54  train   #891 meets a conflict with main (conflict)
17:54  train   #891 meets a conflict with main (stopped)
17:55  train   #891 skipped: #891 has conflicts with main: stop
18:04  team A  merges main into #891 by hand to clear a conflict (rework)
18:08  train   boards #891: it is the head of the train
18:31  train   #891 skipped: #891 left the merge queue without merging (its merge-group checks failed): stop, read the merge_group run
18:49  train   boards #891: it is the head of the train
19:05  train   lands #891
19:05  train   verikora#891 merged into main
  • team session3
  • guard2
  • commit5
  • pull request opened4
  • train10
  • overlap seen2
  • alert2
  • push2
  • merge3
  • conflict3

The lines are the log’s, as the tool wrote them. Three touches only: the names of our internal tools are said in public words, a branch is called “the branch”, and the cost of a session is taken out.

S1: two teams, the same files

At 16:38, team A opens its pull request, #889. The train takes it at the head.

At 16:44, team B is about to open its own. Before it exists, the gate compares: B's branch shares 5 files with #889. It notes it in the log. As both are fixes, it does not hold B back: a fix goes first, that is our rule. Two seconds later, B opens #890.

At 16:49, #889's check is red, for a reason of its own: a formatting line and an old test that encoded the very bug. The train does not block the line for it: it moves on to #890. Team A fixes its red at 17:01, without touching B's files.

At 17:31, the train lands #890. At 17:52, #889 lands on top. The result: 0 conflict with the main branch, 0 rework push, on either one. #890 stayed open 47 minutes, #889 74 minutes.

That is what we wanted to see: the overlap spotted before the second pull request, then both set down one after the other on the same files, with nobody redoing anything.

S2: the stacked pull request, and the failure

The second scenario was harder. At 16:54, team A opens a second pull request, #891, for the rest of its ticket. It needs #889's new status, so it stacks it on top. The gate records it: the train will land #891 after its base.

Except that in the meantime, #889 moved. At 17:01, team A pushed the fix of its red to it, and that fix had reformatted a file of the mobile app. #891 had been stacked on the state before.

At 17:54, when #889 landed, the train tried to replay #891 on top. It refused: #891 was not built on the latest version of its base, so it had nothing to replay. #891 found itself in conflict with the main branch, on a file it had never changed. At 18:04, team A had to merge the main branch by hand to clear it. #891 finally landed at 19:05, after one exit from the merge queue that was not its own doing (the mobile check could not unpack the Android development kit it downloads).

I say it as it is: S2 failed. A merge by hand is exactly what the system must avoid. We stopped the run there, without retrying the case until it passed.

Here are the three pull requests, with their figures, read from the run's proof file:

Each pull request, from the run’s proof file
pull requestteamconflictsrework pushesminutes, opened to mergedverdict
#889team A0074passed
#890team B0047passed
#891stacked on #889team A11131failed

The fix

The cause was precise. The replay of a stacked pull request covered one case only: a stack built on its base's latest version. But the usual case is the other one: the base still takes a push after the stack, because a red is fixed or a review is answered. That case was not covered.

We opened a ticket the same day, with one rule: S2's rerun would be its proof. The fix merged at 20:01 UTC: a stacked pull request is now replayed even when its base moved after it was stacked.

The S2 rerun

The rerun reproduces the failure exactly, on two new Verikora tickets. Team A opens a base pull request, #893, at 20:26. A team B stacks its own on it at 20:45, #894. Then, at 21:31, team A pushes one more commit to its base: the base moves after the stack, as it did in the afternoon. What we expect: when the base lands, the train replays the stacked PR, and #894 lands with no conflict and no merge by hand.

The rerun's verdict

It passed. Not at the first try, and that is the part I care about.

At 22:11, #893 lands as a squash merge: its three commits become one new commit on the main branch. #894 still carries the three old ones, so for git it conflicts with the main branch. That is exactly the case the replay is there for. It did not handle it: the train skipped #894, and at 23:30 the system flagged it as stuck on its own. Nobody had to watch it. What was left was to understand why.

Two gaps, in our tooling, not in Verikora's code:

  • The replay rebuilds the stacked PR in a separate folder, and that folder had none of the project's dependencies. Verikora's guard, which checks every push before it leaves, could not run, so it refused the push. It was right to. The folder was incomplete.
  • A stacked PR whose base landed as a squash merge is retargeted to the main branch. In that case the train's entrance no longer saw it as stacked: it refused it, and the replay never started.

Both were fixed during the night, the second with a test that walks the whole path end to end. At 4:15, #894 goes back into the train with not one line changed. The train sees the conflict the squash merge left, then at 4:20 the replay rebuilds the stacked PR on the main branch (eb2d135 becomes 78c07ed) and pushes it itself. At 4:39, #894 enters the merge queue. At 4:54, it lands.

The verdict: 0 merges by hand, 0 human pushes. The only push to #894 after its base landed is the replay's. That is what S2 had to show. But I will not round it up: the tool needed two fixes before it worked, and #894 waited a little over six hours between its base landing and its replay.

One more thing, because it is part of the true story: our own proof tool first marked #894 “fail”. Its rule predated the replay, so it counted the train's replay push as a manual rescue. We changed the rule (written down, dated, with a test) so that it tells the bot's replay from a human push, and the raw counts stay next to the verdict.

The figures below come from the rerun's proof file:

Each pull request, from the run’s proof file
pull requestteamconflictsrework pushesminutes, opened to mergedverdict
#893team A00105passed
#894stacked on #893team B20489passed, replayed by the train

What it proves, and what it does not

What it proves: the mechanism, on one case. The gate sees the overlap between two teams before the second pull request exists, and the train lands both on the same files with no conflict and no rework. And when a stacked PR fails, we see it in the log, we know why, and the fix has its own proof: the rerun, passed with no merge by hand, after two gaps in the tooling found on the way.

What it does not prove: a rate. One case bounds nothing. With 0 failures in n cases, the 95 % upper bound of the failure rate is about 3 divided by n: with 2 cases it says nothing useful, it would take 10 to bring it down to 30 %. In S1, the two teams changed different functions of the shared file, so git merged it by itself; the case where two teams change the same lines is not covered here. And both S1 pull requests were fixes, which the gate lets through: a new feature would have been held back, then folded or stacked, and that branch is measured elsewhere.

The measure across all our work is the 14-day study we run again on everything our teams did, due on 3 December. It will say whether overlaps still cost us redone work. Until then, I do not say “our teams no longer step on each other”. I say: on this real case, we saw it coming, and we avoided it.

Our real goal

This case is one step. Our real goal fits in one sentence: we want to do one thing only, prioritise the backlog. Everything else will be automated, all the way to production.

So one human decision: the order. What goes first this week, and why. Everything after it, writing the code, checking it, seeing that another lane touches the same files, landing the pull requests in order, replaying a stacked PR when its base moves, has to run without us.

Where we stand, without rounding. This chapter shows the part that already runs: from the ticket to the main branch, agent teams in parallel, the guard, the gate, the merge train, the replay, and a system that flags a stuck pull request on its own. What does not run by itself yet: when the tooling has a gap, someone still has to find it and close it, and last night there were two. What speaks in our name, like this text, is still read by a person before it goes out. And the last step, from the main branch to production, I will tell when I can prove it the way I proved this one: with a log, and pull requests anyone can open.

Chapter 39

Results

files changed by both teams at the same time

5

S1: two teams, the same files

conflict and rework push for the first two pull requests

0

S1: two teams, the same files

merge by hand for the stacked pull request

1

S2: the stacked pull request, and the failure

merge by hand for the S2 rerun

0

The rerun's verdict