Repository navigation
feat(ci): report colliding open PRs before claiming and confirming - #3275
Merged
Merged
Conversation
Trial-merges open PR heads pairwise with git merge-tree and compares their affected closures with the CI selection code, reporting textual, closure or unknown collisions. planUnitChecks accepts a prebuilt import graph so one graph serves every PR. Refs #2941 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ming Refs #2941 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Heads on different bases conflict wherever main moved underneath the older one. A pairwise conflict needs a path both PRs changed; report only those paths. Refs #2941 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schlessera
force-pushed
the
feat/2941-collision-report
branch
from
November 2, 2026 09:30
e3b8116 to
a621b3a
Compare
schlessera
marked this pull request as ready for review
November 2, 2026 09:30
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2941
What changed
bun scripts/collisions.tsis a new read-only repository script that reports which open PRs collide. It lists open ready and draft PRs throughgh(the listing is an injectable function, so tests never touch the network) and trial-merges each pair of heads withgit merge-tree --write-tree. When a merge is clean, it compares the two PRs' affected closures using the CI selection code. Each colliding pair is reported once:textual, with the conflicting paths;closure, with the shared affected workspaces (reverse manifest dependants, fromplanUnitChecks), the shared paths (changed files plus runnable unit owners fromunitImportOwners), and the proof categories both sides select;unknown, when the selection graph cannot be built, a head or base commit cannot be read, or the trial merge errors. An unknown is never reported as disjoint.--jsonprints the full report: graph commit and status, PR numbers and head SHAs, and the collisions.--pr <n>keeps only the pairs that involve PR n.--paths <glob...>reports which open PRs touch an area (path) or share its closure (closure) before any branch exists.work-issuenow runs--pathson the candidate's cited files before claiming, preferring a non-colliding candidate among those of the same priority. It runs--prbeforeconfirmand records the result in the PR.CONTRIBUTING.mddescribes the command.Why this shape
discoverUnitImports,unitImportOwners,planUnitChecks,changedFiles) instead of reimplementing them.planUnitChecksgained an optional prebuiltgraphargument, so one import graph (about 4s) serves every PR instead of being rebuilt for each one. Callers that omit it behave exactly as before.--no-write-fetch-head --refmap= --no-auto-maintenanceand no destination refspec. That adds objects but writes no ref, noFETCH_HEADand no remote-tracking update.merge-treewrites only objects.Proof
The fixture repository puts every PR head only under
refs/pull/<n>/headin a bareorigin. The clone uses--no-local, so the command has to fetch the heads, and the test asserts they are absent beforehand. It has two textually conflicting branches, one disjoint docs branch, and one branch that changes a different file in the same closure. Refs,HEAD,packed-refs, the index,FETCH_HEAD, the tracked and untracked file listing and the porcelain status are compared before and after.Before the change, nothing was compared (stub:
collisions: []). These named tests fail on their assertions, not on a module load:ONE_TEXTUAL_PAIR: Expected −18 / Received +1SAME_CLOSURE_IS_CLOSURE: −21 / +1UNKNOWN_GRAPH_NEVER_DISJOINT: −8 / +1Mutations, each restored afterwards (
cmpagainst the original, then 7 pass):disjointUNKNOWN_GRAPH_NEVER_DISJOINT: Expected −5 / Received +0ONE_TEXTUAL_PAIR(−1 / +2) andUNKNOWN_GRAPH_NEVER_DISJOINT--no-write-fetch-head --refmap=from the fetchCOLLISIONS_READ_ONLY:fetchHead"absent"became a hashmerge-treeconflict path, not only paths both PRs changedBASE_DRIFT_IS_NOT_TEXTUAL: received atextualpair onpackages/ithaca/src/oars.tsSAME_CLOSURE_IS_CLOSURE, plus the--prand--pathstestsThe fetch mutation was green at first, because a local
git clonecopies every object and so the command never fetched. The fixture now clones with--no-local, and the mutation fails as shown above.Base-drift fix, found by dogfooding. The first
--pr 3275run reported #3056×#3275 astextualon ui-react files this PR never touches. #3056 sits on an older main, so the pair's merge base carried main's own later edits. A pairwise conflict needs a path both PRs changed, so the report now keeps only those paths.BASE_DRIFT_IS_NOT_TEXTUALcovers this case. It fails with the filter removed (restored afterwards; 8 pass).Live read-only run against this repository: 5 open PRs in 7.7s. A
for-each-refhash taken before and after was identical.Pre-confirm collision report (
bun scripts/collisions.ts --pr 3275, graph at0e326d93a, head at that time0e326d93a): notextualand nounknownpairs. There areclosurepairs with #3054, #3069 (shared ui workspaces) and with #3056, #3059, #3116 (shared CI tooling tests such astests/ci-plan.test.ts). These are detection only;e3b81162aonly touchesscripts/collisions.tsand its test.Checklist
braincommand; the issue records no contract impact.)docs/reflect the change, or nothing documented moved. (CONTRIBUTING.mdand thework-issueskill.)docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.Anything left open
Semantic conflicts beyond closure overlap are out of scope (#2941). Nothing else.
🤖 Generated with Claude Code