Putting multiple AI agents on the same Git repository looks like a simple way to go faster. It is, until two sessions commit, that is, record their changes, at the same moment. Here we describe the two parts of Biomine Console that prevent collisions: a lock and a board. And the three mistakes we made using them.
The problem
Git was built to let many people work on the same code. But its usual model is that everyone has their own clone, on their own machine. Conflicts show up when work is combined (merge) or sent to the shared repository (push), and Git reports them.
The angels, the AI roles of the Console, often work inside the same Docker container, on the same checkout, that is, the same working copy of the files. In that case they also share the staging area: the list of files that git add prepares for the next commit. There Git can no longer tell who did what.
git add on a file takes the file as it is on disk at that moment. Not the changes of whoever runs the command: the whole file. If another session has just touched it, its lines go into the first session’s commit.
It happened to us: files written by another angel ended up in someone else’s commit. No error, no conflict reported. The code was correct. It had just been published half-done, under the name of someone who had not written it.
There is a second, slower problem: two sessions working on the same bug without knowing. Nothing breaks. Work is wasted, and in the end there are two different fixes for one defect.
These are two different problems, and they have two different tools.
How it is built
The lock. Before committing and pushing to a repository, a session asks for the lock on that repository. A single arbiter grants it: the Console’s service process, which is a program and not a model. If the lock is taken, the answer says who holds it and for how many more seconds. Whoever comes second waits and retries.
The lock is a lease: it has an expiry. This is the part that matters most. A session can stop halfway, because of a crash or because the conversation ends. A lock with no expiry would then block all the others until someone steps in by hand. With an expiry, a dead session releases what it held by itself.
The work board. It is a shared list of work items: who is doing what, on which files, in which state. There are few states: planned, claimed, in progress, done, blocked. There is one more, which we added later: “I am looking”.
This is the difference between the two.
| Lock | Board | |
|---|---|---|
| What it answers | who may commit and push now | who is working on what |
| How long it lasts | seconds: the time of one commit | hours or days: the time of one job |
| If you ignore it | the push is refused | nobody stops you, but it shows |
| What it prevents | a commit carrying someone else’s work | two fixes for the same bug |
The lock excludes. The board informs. We tried to make one do the other’s job, and it does not work.
A case that runs through it
The first mistake: holding the lock beyond the commit. It was taken for the commit and released at the end of the job, after analysing something else. It looked like caution.
It was the opposite. A job lasts hours; the sequence git add, commit, push lasts seconds. With the lock held for long, the other sessions queued behind one that was only reading code.
We counted the refused lock requests in the logs. Contention was not constant: it came in bursts, at the moments when several sessions were working on the same repository. That is exactly when coordination mattered most.
The fix: reading, editing and running tests need no lock. The lock is taken just before git add and released just after the push. Not at the end of the job, not at the end of the turn.
To say “I am working on this” there is the board. It lasts as long as the job and blocks nobody.
The second mistake was about names. The lock excludes on a string, and nothing else. If one session asks for the lock “console” and another for “console-release”, the arbiter sees two different resources. Both get one and push to the same repository, each convinced it is protected.
Neither gets a refusal. A lock that grants to both looks, from the outside, exactly like one that works. When we counted the labels in use, there were many more labels than repositories.
Since then the label is the name of the repository, spelled one way. It says where you write, not which operation you are doing.
The third mistake was about the board. It recorded who writes, not who looks. But duplicates were born before any commit: two sessions analysing the same bug, both following the rules, neither with a line of code changed yet.
That is why the “I am looking” state exists. It grants nothing and blocks nothing. It only says: someone is already on these files.
Where the limits are
The lock is cooperative: it protects those who ask for it. A session that commits without asking is not stopped by the lock itself. We stop it later, with a hook, an automatic check that verifies at push time that the lock is there and has not expired. It is a second layer, not a guarantee.
An expiry is a trade-off. Too short, and it expires in the middle of a slow commit: the push fails and the lock goes to another session. Too long, and a dead session blocks the others for longer. We size it on the worst case of the operation, not on the average. And an expired lock does not say the work is finished: before writing to the same files, you look at the board.
The board is only as good as it is current. Work that is not on the board does not exist for the system, and an entry that has not moved for days states something no longer true. We have a script that compares the board with recent commits and reports the gaps. It finds commits made without a board entry. It does not find what a session is only thinking of doing.
Finally, all this has a cost. Every commit carries two extra calls, and every job an entry to open and close. For a single developer it would be bureaucracy. It pays off when more than one session works on the same repository.
The principle holds without AI too, for any team sharing an environment. Hold the lock for the time of the commit, not of the job. Declare intent somewhere else, where it blocks nobody. And a lock with no expiry will sooner or later be held by someone who is no longer there.
See the Console at work: https://console.biomine.it
