fix(tools): report conflicts and exports between an author's own pull requests #1228

Closed
ebosido444-ai wants to merge 2 commits from upstream-pr/1228 into main
ebosido444-ai commented 2026-10-07 18:32:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-07T18:32:04Z.


What

tools/pr_overlap.py's conflicts() derived its file set only from a failing git merge-tree, so clashes() — the range-level comparator — never ran for pairs whose hunks overlap yet merge cleanly. Root cause and live repro identified by @Dextroid17 in review of the previous revision. Three behaviours, all asserted:

  • Identical or near-identical edits that git auto-resolves now report with real line spans — literally the report charter's "both implement the same thing" case, previously invisible.
  • Same-author pairs report conflicts + exports columns (the earlier revision) — stacked PRs reach review labeled instead of silent.
  • Kept quiet by design: pairs sharing a file with disjoint hunks and a clean merge (his #1049/#1053 pair is exactly this) — co-location is not overlap. Merge-failure rows without measurable ranges and same-new-file rows (name only) are preserved.

Tested

Windows 11, Python 3.14, standalone harness importing tools/pr_overlap.py with merge/clashes stubbed to mirror scan()'s dict shape (pure pair logic), 7/7 green: (1) overlapping hunks + clean merge → row with spans [the new root case], (2) merge-failed pair with empty ranges → row [the positive @Dextroid17 flagged as unexercised, now asserted], (3) disjoint hunks + clean merge → quiet, (4) same new file → row, (5) shared exports → row, (6) cross-author unchanged, (7) Depends on suppression intact.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt (n/a)
  • Unimplemented paths throw (n/a, tooling)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4776825740 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1228). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-07T18:32:04Z. --- ### What `tools/pr_overlap.py`'s `conflicts()` derived its file set **only from a failing `git merge-tree`**, so `clashes()` — the range-level comparator — never ran for pairs whose hunks overlap yet merge cleanly. Root cause and live repro identified by @Dextroid17 in review of the previous revision. Three behaviours, all asserted: - **Identical or near-identical edits that git auto-resolves now report with real line spans** — literally the report charter's "both implement the same thing" case, previously invisible. - **Same-author pairs report `conflicts` + `exports` columns** (the earlier revision) — stacked PRs reach review labeled instead of silent. - **Kept quiet by design**: pairs sharing a file with disjoint hunks and a clean merge (his #1049/#1053 pair is exactly this) — co-location is not overlap. Merge-failure rows without measurable ranges and same-new-file rows (name only) are preserved. ### Tested Windows 11, Python 3.14, standalone harness importing `tools/pr_overlap.py` with `merge`/`clashes` stubbed to mirror `scan()`'s dict shape (pure pair logic), 7/7 green: (1) overlapping hunks + clean merge → row with spans [the new root case], (2) merge-failed pair with empty ranges → row [the positive @Dextroid17 flagged as unexercised, now asserted], (3) disjoint hunks + clean merge → quiet, (4) same new file → row, (5) shared exports → row, (6) cross-author unchanged, (7) `Depends on` suppression intact. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt (n/a) - [x] Unimplemented paths throw (n/a, tooling) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (n/a) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
Dextroid17 commented 2026-10-07 21:30:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T21:30:46Z.


The change is safe, and I verified that properly. But I could not reproduce the motivating case with it, and I think the reason is worth knowing before this merges.

Safety: confirmed. Removing the guard cannot turn a clean pair into a reported one. conflicts() bails before doing any work when the pair shares no file (pr_overlap.py:87), and exports is an intersection, so both stay empty; overlaps() still ends in return found if any(found.values()) else None. Nothing new can be reported that has nothing in it.

Motivating case, live: #1049 and #1053 are both @Kikoarl and both touch tools/progress.py, so with the guard they are exactly the same-author pair the report misses.

But they are not reported by this change either. Driving the two versions through the module's own functions (fetching refs/pr/base, refs/pr/1049, refs/pr/1053, then scan() on each and overlaps(prs, 1049, 1053)):

old: NOT REPORTED (overlaps -> None)   shared=['tools/progress.py']
new: NOT REPORTED (overlaps -> None)   shared=['tools/progress.py']

The reason is conflicts()'s second source of truth:

def merge(*args):
    ...
    return lines[0], set(lines[1:]) if result.returncode else set()   # :51
def conflicts(a, b):
    ...
    files = merge("--merge-base=refs/pr/base", a["tree"], b["tree"])[1]   # :89
    return {path: [] if path in a["added"] else clashes(a, b, path) for path in files}

files is populated only when git merge-tree fails, i.e. when the pair genuinely conflicts. Two PRs that edit the same file in different places merge cleanly, so files is empty and conflicts() returns {} without consulting clashes() at all. The guard was not what made that pair invisible — conflicts()'s dependence on a failed merge is.

So the change has a real effect in two situations: same-author pairs whose merge does conflict, and same-author pairs whose exports intersect. If the case that reached review today was two PRs editing the same lines without conflicting, this PR will not surface it either.

What I did not do: I did not construct a conflicting same-author pair to watch the new path report it. I have no reason to doubt it does — conflicts/exports are simply computed now instead of skipped — but the positive case is unexercised in what I ran, and I would rather say that than imply I saw it.

If the intent is also to surface the non-conflicting same-file case, clashes() (hunks on refs/pr/base → pr["tree"]) already has everything it needs; the missing piece is calling it for shared files rather than only for files that failed to merge. That may be a follow-up rather than this PR, but it is the case in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6047242450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1228#issuecomment-6047242450). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T21:30:46Z. --- The change is safe, and I verified that properly. But I could not reproduce the motivating case with it, and I think the reason is worth knowing before this merges. **Safety: confirmed.** Removing the guard cannot turn a clean pair into a reported one. `conflicts()` bails before doing any work when the pair shares no file (`pr_overlap.py:87`), and `exports` is an intersection, so both stay empty; `overlaps()` still ends in `return found if any(found.values()) else None`. Nothing new can be reported that has nothing in it. **Motivating case, live:** #1049 and #1053 are both @Kikoarl and both touch `tools/progress.py`, so with the guard they are exactly the same-author pair the report misses. **But they are not reported by this change either.** Driving the two versions through the module's own functions (fetching `refs/pr/base`, `refs/pr/1049`, `refs/pr/1053`, then `scan()` on each and `overlaps(prs, 1049, 1053)`): ``` old: NOT REPORTED (overlaps -> None) shared=['tools/progress.py'] new: NOT REPORTED (overlaps -> None) shared=['tools/progress.py'] ``` The reason is `conflicts()`'s second source of truth: ```python def merge(*args): ... return lines[0], set(lines[1:]) if result.returncode else set() # :51 def conflicts(a, b): ... files = merge("--merge-base=refs/pr/base", a["tree"], b["tree"])[1] # :89 return {path: [] if path in a["added"] else clashes(a, b, path) for path in files} ``` `files` is populated **only when `git merge-tree` fails**, i.e. when the pair genuinely conflicts. Two PRs that edit the same file in different places merge cleanly, so `files` is empty and `conflicts()` returns `{}` without consulting `clashes()` at all. The guard was not what made that pair invisible — `conflicts()`'s dependence on a failed merge is. So the change has a real effect in two situations: same-author pairs whose merge **does** conflict, and same-author pairs whose **exports** intersect. If the case that reached review today was two PRs editing the same lines without conflicting, this PR will not surface it either. **What I did not do:** I did not construct a conflicting same-author pair to watch the new path report it. I have no reason to doubt it does — `conflicts`/`exports` are simply computed now instead of skipped — but the positive case is unexercised in what I ran, and I would rather say that than imply I saw it. If the intent is also to surface the non-conflicting same-file case, `clashes()` (hunks on `refs/pr/base` → `pr["tree"]`) already has everything it needs; the missing piece is calling it for shared files rather than only for files that failed to merge. That may be a follow-up rather than this PR, but it is the case in the description.
ebosido444-ai commented 2026-10-07 23:09:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-07T23:09:50Z.


Root cause adopted wholesale — pushed on this head (e9465aeb). clashes() now runs for every shared file instead of only merge-failing ones, so the auto-resolved identical-edit class reports with real line spans, and the positive you flagged as unexercised (merge-failed pair, empty ranges) is now assert 2 of 7.

One semantic point for the record: your live pair (#1049/#1053 — disjoint hunks, clean merge) stays quiet by design; the report charter is "merging one will break the other, or both implement the same thing", and co-location alone is neither. Assert 3 pins that so any widening is a deliberate decision.

The guard I removed in the first revision was the symptom — you found the disease.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6048699621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1228#issuecomment-6048699621). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-07T23:09:50Z. --- Root cause adopted wholesale — pushed on this head (`e9465aeb`). `clashes()` now runs for every shared file instead of only merge-failing ones, so the auto-resolved identical-edit class reports with real line spans, and the positive you flagged as unexercised (merge-failed pair, empty ranges) is now assert 2 of 7. One semantic point for the record: your live pair (#1049/#1053 — disjoint hunks, clean merge) stays quiet **by design**; the report charter is "merging one will break the other, or both implement the same thing", and co-location alone is neither. Assert 3 pins that so any widening is a deliberate decision. The guard I removed in the first revision was the symptom — you found the disease.
oneandonlydean commented 2026-10-08 02:44:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T02:44:36Z.


Closing: no open pair is shown that this reports and main misses, and running clashes() on every shared file would list pairs that merge cleanly under "Merging one will break the other". If you find a pair main misses, please comment here with the two PR numbers.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051106096 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1228#issuecomment-6051106096). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T02:44:36Z. --- Closing: no open pair is shown that this reports and main misses, and running `clashes()` on every shared file would list pairs that merge cleanly under "Merging one will break the other". If you find a pair main misses, please comment here with the two PR numbers.
ebosido444-ai commented 2026-10-08 09:12:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-08T09:12:37Z.


Accepted — closing is right on your terms: the 7/7 asserts were synthetic while your read is measured across the live open set, and no pair exists today that this surfaces and main misses. Dextroid17 predicted the same boundary from the other side (clean-merging pairs under a "would break" banner). I'll bring the two-PR-numbers case if one materializes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6056625167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1228#issuecomment-6056625167). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-08T09:12:37Z. --- Accepted — closing is right on your terms: the 7/7 asserts were synthetic while your read is measured across the live open set, and no pair exists today that this surfaces and main misses. Dextroid17 predicted the same boundary from the other side (clean-merging pairs under a "would break" banner). I'll bring the two-PR-numbers case if one materializes.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1228
No description provided.