Why your CI pipeline misses conflicts between parallel PRs
Every CI system tests each pull request alone against the base branch. That is a problem when several agents are working in parallel. Here is what happens: Agent A opens a PR that changes login() to take an options object. Agent B opens a PR that calls login(email, password) — the old form. CI tests A against main. Green. CI tests B against main. Green. A merges. Main still works. B merges. Main…
Unlike typical CI systems that test pull requests independently against the base branch, CI pipelines can miss conflicts when several agents work in parallel. This issue arises because Agent A opens a PR changing a login() function to require an options object, while Agent B opens a PR that calls login(email, password). When CI tests A against main, it passes, as does testing B against main.
However, merging both PRs results in a broken main branch due to the incompatible changes. CI's design focuses on testing one change at a time, failing to account for the combined effects of multiple PRs.
Merge queues, like GitHub's, Mergify, and Graphite, attempt to address this issue by testing PRs sequentially. However, they only catch conflicts when both PRs are merged together, and not while they are in review. The core problem is that these queues test the order of merges, not the actual combination of changes. To catch these conflicts, one needs to compare PRs against each other rather than just against the main branch.
There are three key steps to resolving this problem: 1) in-memory merge of every open PR pair, 2) code-level comparison, and 3) combined build and test. In-memory merge involves merging the diffs of each PR pair into the base branch, checking for git merge conflicts. Code-level comparison parses the diffs as code, identifying semantic conflicts that git's merge would not detect, such as a function signature change causing a signature break.
Lastly, combining the build and tests of the risky PR pairs in a temporary branch helps catch combined failures that individual PR builds might not reveal.
Lanekeeper's GitHub Action addresses this issue by running on every PR event, comparing each PR against all other open PRs on the same branch, and reporting clashes with suggested merge orders. It also adds annotations to clashing lines and fails the job on high-severity clashes. Additionally, Lanekeeper sizes each PR's blast radius, identifying which APIs, migrations, routes, environment variables, and dependencies it changes, and assigns a tier to each PR as contained, coordinated, or requiring human intervention. This enables reviewers to prioritize which PRs need attention before merging.
To implement this solution, users can install Lanekeeper locally using npm i -g lanekeeper && lk init to catch conflicts while agents work, before PRs are even opened. Adding the Lanekeeper Action to a repository can also help catch conflicts between PRs in CI. For those who prefer a manual approach, having agents search for existing callers of exported functions with changed signatures can help catch most common cases.
Lanekeeper is free and open source, running locally without sharing code, and has been measured on 187 scenarios, with 33 derived from real open-source projects.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to