Edward Shen

Backend & Distributed Systems Engineer

0%

A Year of Merge Conflicts in a Million-Line Go Monolith

Over the twelve months to November 2026, 4,036 merges landed in the backend repository I work in, and 1,912 of them carried a conflict that someone resolved by hand. The repository is a single Go module: one binary that runs as fifteen process roles, about 1.3 million non-test lines, about 96,000 commits from about eighty people since March 2023.

I went through the history to see why the conflicts keep happening and why nobody has changed the structure. What keeps the repository running is procedure, not structure: hand-pushed branches, hand-resolved conflicts, hand-clicked deploys. Procedure is paid for in attention, and because it has worked so far, the structure has never had to change. Every number below comes from the git history.

I have no fix to show. Two earlier posts describe work in the same repository, moving a scan off the request path and splitting a task index under live writes; this is the background they sit on.

Layers, no modules

The backend is one Go module that builds one binary and runs it in about fifteen roles: API servers, queue consumers, cron jobs and a script runner. The product is an AI content platform: a user sends a prompt to a model, the backend runs it as a task, stores the result and bills the account. The stores are Firestore, Elasticsearch, Redis and object storage; two sibling services write three of the same Firestore collections.

Every role is layered the same way, controller → service → repository, wired through singleton.go, and the cron jobs and scripts go through the same code. The repository has layers but no modules: layers partition by technique, modules by ownership, and here there is no way to add a feature without editing a file that every other feature also edits.

s repository writes the same stores, which the cron jobs, the scripts and two sibling services also write

Where everyone appends

Those files are where the conflicts are, and so are the three largest files: a conflict is two features meeting where no boundary was built. The files that needed a manual resolution most often:

File Conflicted merges What it is
Three 14,000–20,000-line files: two controllers, one service 476, 188, 178 one file per flow
consts.go 306 registry: constants
Route registration (api.go) 282 registry: 1,500-odd routes
go.mod 258 SDK versions, every bump edits it
singleton.go 226 registry: about 350 accessors
Redis key registry 103 registry: keys
Script runner's command switch 70 registry: one case per script

Five of these are registries: every feature must add its line by hand, thirty people to the same list, and git cannot merge two appends to one place. Nobody is editing the same function; they are queueing at the same counter.

Appending is also the cheapest move in the repository. A route is one line, a constant one line, a singleton one line, and each line ships a feature the same day; the cost lands on whoever merges next, in twelve-minute pieces that no plan counts. Nobody chose a 47% conflict rate; a few thousand local choices added up to it.

By git's combined diff, that is 47.4% of the year's merges, and the true count is higher, since taking one side whole leaves no trace. The monthly rate stayed between 40% and 56% all year.

Procedure, not mechanism

Most of the resolving happens on the feature branch, before anything reaches a trunk, and it lands on a few people: four accounts resolved 1,014 of the 1,912. Those four are the integration layer, and the cost is paid out of the one budget nobody plans: attention. Nothing in the code holds that knowledge but them.

The three trunks move together: someone pushes develop forward to pre and release by hand, so 95% of the release merges are the same commits on all three. Our release path takes one feature branch through them in order, and each step waits for a test pass:

1
2
3
              ┌──▶ develop  (test)
feature ──────┼──▶ pre (staging)
└──▶ release ─▶ tag ─▶ deploy

The history matches it: for 196 of the last 200 feature branches that reached release, the tip is also reachable from develop and pre, and a branch lives about half a day from fork to release, at about four releases a day. Two ways around the path are routine: direct pushes to the trunks, and hotfix tags cut from the live tag, which never pass develop or pre. The path is a policy, not a mechanism: it holds because people follow it, and the exceptions are procedure too.

Everything writes to the same data through the same code: the roles, the cron jobs, the scripts, and two sibling services through a shared SDK. The only contract between the writers is the schema, and it is bumped by commit. With releases going out four times a day, a change to a shared model is live within hours while everything else keeps the definitions it was built with. The cadence does not cause the coupling, but it leaves nothing between a change and its consumers.

A split for the tools

Nothing I found in the history was aimed at the conflict rate. The one change to the code's shape was for the tools, not for the people: in October a command split the 32 largest Go files into 82 files in the same package, about a quarter of the Go code, so that the IDE could index them and agents could read them whole. The conflict rate stayed put, 49% in October and 43% in November, inside that band. That is what the diagnosis predicts: the split changed what the files are, not where a feature adds itself, and the registries were untouched.

A structure changes when the procedure around it breaks, and this one has not: four releases a day is the proof that it works, and that proof is what keeps it from being replaced.

Agents multiply the pattern

Agents write a growing share of the commits, 28% to 39% of them since August by the commit format the agent workflow uses, and commits touching five or more files went from 6 to 7% through July to 32% by November. The conflict rate did not move. An agent learns the repository from its history, and the most repeated instruction in that history is the append: every feature it can see added itself to the same files. Agents follow the code, not the procedure, and whatever the pattern is, n multiplies it.

That changes the arithmetic. The append rate used to be bounded by headcount: eighty people, about 1,900 interruptions a year. One engineer with agents is worth roughly n engineers of that rhythm, so the append rate is now bounded by review and release capacity, and the lists fill n times faster. The pipeline is automated end to end except for the two steps that were always manual, resolving the merge and approving it, and n does not multiply the people who do them. For a system that agents will code from the start, I would design the append points before the features: every place a feature wants to add itself should be generated or discovered rather than hand-edited, so a feature is a new file, never an edit to a shared list, and an agent has nothing to append to. The contract-generated platform in an earlier post worked this way. The size budget has to assume the n as well: a structure that carried eighty people's appends will not carry the same appends concentrated in a few people with agents.

Nothing enforces anything

Nothing in the repository enforces anything. The only CI job is an AI review that is allowed to fail; the build and the deploy run in Jenkins, started by hand, and nothing in the repository says whether the tests run. A hand-resolved merge takes a median of 12 minutes against 4 for a clean one: about 1,900 interruptions a year, paid by the people who own the branches.

I respect what the release process does. Three or four releases a day from a codebase where half the merges need a human is procedure doing real work, and the history says it is not failing. It will not fail on its own; what breaks it is n, and n is already in the commits. For this repository I still do not know what the right first move is, and splitting more files would not be it: the fixes so far make the code easier to read without making it easier to change. For the next one, I would start from the question this one never answered: where is a feature allowed to add itself?

Welcome to my other publishing channels