cd /news/ai-agents/two-green-pull-requests-can-still-br… · home › topics › ai-agents › article
[ARTICLE · art-174227] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Two green pull requests can still break main

A developer detailed how two individually green pull requests can break main when merged, a problem they call semantic merge conflicts, and outlined established fixes including required up-to-date branches, GitHub merge queues, and GitLab merge trains. The writeup notes that AI coding agents worsen the risk by increasing the volume of open changes and producing broad mechanical edits like renames and signature changes. It also promotes AI CodeOps, a release gate that runs tests on the exact commit to be merged and fails closed with a signed evidence pack.

recommendation

Enable a merge queue or merge train and re-run required checks on the combined state, invalidating green results whenever the branch or target branch changes.

more in playbook: Working with AI coding agents
by read3 min views1 publishedNov 22, 2026

Here is a failure most teams have seen at least once. Two pull requests are open against main. Both have green checks. Both get approved. Both merge within an hour of each other. Main fails to build.

Nobody did anything wrong. Each change was tested, just not against the code it ended up next to.

CI on a pull request usually tests the branch, or the branch merged with main as main looked when the pipeline ran. Once one pull request merges, every other open pull request was tested against a version of main that no longer exists.

Most of the time that doesn't matter. Sometimes it does:

getUser to fetchUser and updates every caller. Pull request 2, opened earlier, adds a new call to These are sometimes called semantic merge conflicts: Git merges the text cleanly, but the program no longer works.

The chance of this goes up with the number of changes open at the same time and how long they stay open. AI coding agents push on both. A team that used to have a handful of open pull requests can have many more, each produced quickly and each tested in isolation. Agents also tend to make broad, mechanical changes (renames, signature changes, refactors) which are exactly the kind that break code elsewhere.

The fix is a rule: the code that lands on main should have passed your tests in exactly that state. Not the branch on its own, not the branch merged with an older main.

There are a few established ways to get there.

Require branches to be up to date. Many Git hosts can require a branch to include the latest main before merging. It works, but every merge forces every other open branch to update and re-run CI, which gets slow when many changes are in flight.

Merge queues. GitHub's merge queue adds pull requests to a queue and creates a temporary branch containing the latest target branch plus the changes ahead of it in the queue. Required checks run on that combined state. If you use GitHub Actions, your workflows need to run on the merge_group event as well as pull_request, or the required checks never report and the merge doesn't happen.

Merge trains. GitLab's merge trains (Premium and Ultimate tiers) do the same thing: each merge request's pipeline runs on its changes combined with the target branch and the merge requests ahead of it in the train. If one fails, it drops out and the pipelines behind it restart without it.

Re-test on change. Whatever mechanism you use, a new commit on the branch or a moved target should invalidate the earlier result. A green check from an hour ago describes code from an hour ago.

If the answer to the last one is "it goes through," fix that first. In AI CodeOps, AI agents plan, build, review and test changes on your repository, and the release gate decides whether a pull request opens. Your own tests run in a sandbox on the exact commit that will merge. If that commit wasn't tested, or the tests didn't pass on it, the pull request doesn't open. The AI review of the real diff must have no open high or critical findings, and a person must approve. If any step can't complete, the gate fails closed and nothing merges.

Every change also gets a signed evidence pack recording which commit was tested, what the review found and who approved it, so "were the tests run on what shipped?" has a direct answer.

Merge queues and merge trains solve the ordering problem on your Git host; a gate like this makes sure an AI-written change only gets that far with evidence attached. Used together, green means what people assume it means.

AI CodeOps works with GitHub, GitLab, Bitbucket, Gitea and Forgejo, including self-hosted. Free during the open beta, and free forever for non-commercial open-source projects: https://aicodeops.dev

── more in #ai-agents 4 stories · sorted by recency
── more on @github 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/two-green-pull-reque…] indexed:0 read:3min 2026-11-22 · —