scripts: pr_overlap.py lists the open pull requests that change the same files (PR-OVERLAP-CHECK) #2349

Closed
syfyra wants to merge 1 commit from upstream-pr/2349 into main
syfyra commented 2026-11-26 14:33:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T14:33:31Z.


Claimed in the coordination issue as: PR-OVERLAP-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194375468)

Depends on: none. It merges cleanly with the two open pull requests that change the same files (#2103 in AGENTS.md, #2151 in AGENTS.md and CONTRIBUTING.md), as the script itself reports.

What and why

There is no working way to find the open pull requests that touch a file. GitHub's search does not match pull requests by path: the VIEWER-HUNT finding in the coordination issue records gh search prs 'path:viewer/' returning nothing while four open pull requests changed those files. With about 1,490 pull requests open, reading them is not an option, so work gets written twice, and the template's Depends on: line (every pull request this one builds on or conflicts with) is filled in from memory.

scripts/pr_overlap.py asks git instead, with no API call and no token:

  • The open pull requests are the ones the remote has a refs/pull/N/merge for. GitHub keeps that ref while a pull request is open: git ls-remote showed 1,485 of them today (of 2,283 pull request heads), against 1,484 open pull requests in the search API, 317 of them labeled needs rebase.
  • Their heads are fetched into refs/pr-overlap/N, a namespace of the tool. Refs of pull requests that are no longer open are deleted, so the namespace is the open set as of the last run and --no-fetch works offline.
  • A pull request's files are those that differ between its head and its merge base with --base (default origin/main), so what main changed since it branched is not counted as its own. A rename counts as both paths.

python -I scripts/pr_overlap.py <file or folder>... lists the open pull requests that change those paths: the check to run before starting on a file. With no argument it takes the branch's own files (committed against the merge base, plus what is modified or untracked in the working tree) and says how the branch stands to each pull request that changes one of them: clean or conflict from git merge-tree, with the conflicting files, same for the branch's own pull request, included for one the branch is built on. --json gives the same as one object.

It writes refs under refs/pr-overlap/ and nothing else: no tags, no FETCH_HEAD, and no pull request code is checked out or run. AGENTS.md and CONTRIBUTING.md name it where they ask to check the open pull requests.

What it found on real branches here:

  • On #2114 (scripts/run_semantic_tests.py), whose description names one conflicting pull request, it lists 21 open pull requests on the same three files, 8 of which conflict with that branch.
  • On this branch it first reported a conflict with #2151 in AGENTS.md. I moved my paragraph to the end of that section, and it now reports both pull requests as clean.
  • For viewer/serve.py it lists none, which is what the VIEWER-HUNT finding concluded by hand.

Tested

Windows 11, Python 3.14.7, git 2.55.0:

  • python -I tests/test_pr_overlap.py: 19 tests on throwaway repositories, an "upstream" with refs/pull/N/head and refs/pull/N/merge laid out as GitHub does and a clone of it. They cover paths and folders, closed pull requests left out, files measured from the merge base, renames, paths relative to the current folder and with spaces and non-ASCII names, the branch mode with committed, modified and untracked files, the four standings, the kept refs following the open set, --no-fetch with the remote gone, a fork as origin, a shallow clone, and the errors.
  • The test file fails on main, where the script does not exist.
  • 43 one-line changes to the script (heads taken from the merge refs, a two-dot diff, a prefix match without the slash, kept tags, and so on) each make at least one test fail.
  • On this repository: a run takes about 5 s for 1,492 open pull requests with 16 git processes at a time, --no-fetch about 4.6 s. The first run fetched 1,487 heads and took 12 s, in a clone that already had most of their objects from an earlier fetch of the pull request refs; a clone without them will take longer.
  • python -I on tests/test_tool_stdout_encoding.py, tests/test_text_write_line_endings.py, tests/test_ci_registration.py, the 13 tests/test_docs_*.py and tests/test_i18n_index.py; python -I scripts/check_no_game_data.py on the four changed files.
  • Not tested: Linux and macOS (the script and its tests use only git and the standard library, but I ran them on Windows), Python 3.12, which CI runs (contextlib.chdir in the test needs 3.11), a git older than 2.55 (2.29 for fetch --stdin and 2.38 for merge-tree --write-tree are from git's release notes, not from a run), and a host other than GitHub (the merge-ref rule is GitHub's).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule in this change.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5511914067 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T14:33:31Z. --- Claimed in the coordination issue as: PR-OVERLAP-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194375468) Depends on: none. It merges cleanly with the two open pull requests that change the same files (#2103 in `AGENTS.md`, #2151 in `AGENTS.md` and `CONTRIBUTING.md`), as the script itself reports. ### What and why There is no working way to find the open pull requests that touch a file. GitHub's search does not match pull requests by path: the VIEWER-HUNT finding in the coordination issue records `gh search prs 'path:viewer/'` returning nothing while four open pull requests changed those files. With about 1,490 pull requests open, reading them is not an option, so work gets written twice, and the template's `Depends on:` line (every pull request this one builds on or conflicts with) is filled in from memory. `scripts/pr_overlap.py` asks git instead, with no API call and no token: - The open pull requests are the ones the remote has a `refs/pull/N/merge` for. GitHub keeps that ref while a pull request is open: `git ls-remote` showed 1,485 of them today (of 2,283 pull request heads), against 1,484 open pull requests in the search API, 317 of them labeled `needs rebase`. - Their heads are fetched into `refs/pr-overlap/N`, a namespace of the tool. Refs of pull requests that are no longer open are deleted, so the namespace is the open set as of the last run and `--no-fetch` works offline. - A pull request's files are those that differ between its head and its merge base with `--base` (default `origin/main`), so what `main` changed since it branched is not counted as its own. A rename counts as both paths. `python -I scripts/pr_overlap.py <file or folder>...` lists the open pull requests that change those paths: the check to run before starting on a file. With no argument it takes the branch's own files (committed against the merge base, plus what is modified or untracked in the working tree) and says how the branch stands to each pull request that changes one of them: `clean` or `conflict` from `git merge-tree`, with the conflicting files, `same` for the branch's own pull request, `included` for one the branch is built on. `--json` gives the same as one object. It writes refs under `refs/pr-overlap/` and nothing else: no tags, no `FETCH_HEAD`, and no pull request code is checked out or run. `AGENTS.md` and `CONTRIBUTING.md` name it where they ask to check the open pull requests. What it found on real branches here: - On #2114 (`scripts/run_semantic_tests.py`), whose description names one conflicting pull request, it lists 21 open pull requests on the same three files, 8 of which conflict with that branch. - On this branch it first reported a conflict with #2151 in `AGENTS.md`. I moved my paragraph to the end of that section, and it now reports both pull requests as clean. - For `viewer/serve.py` it lists none, which is what the VIEWER-HUNT finding concluded by hand. ### Tested Windows 11, Python 3.14.7, git 2.55.0: - `python -I tests/test_pr_overlap.py`: 19 tests on throwaway repositories, an "upstream" with `refs/pull/N/head` and `refs/pull/N/merge` laid out as GitHub does and a clone of it. They cover paths and folders, closed pull requests left out, files measured from the merge base, renames, paths relative to the current folder and with spaces and non-ASCII names, the branch mode with committed, modified and untracked files, the four standings, the kept refs following the open set, `--no-fetch` with the remote gone, a fork as `origin`, a shallow clone, and the errors. - The test file fails on `main`, where the script does not exist. - 43 one-line changes to the script (heads taken from the merge refs, a two-dot diff, a prefix match without the slash, kept tags, and so on) each make at least one test fail. - On this repository: a run takes about 5 s for 1,492 open pull requests with 16 git processes at a time, `--no-fetch` about 4.6 s. The first run fetched 1,487 heads and took 12 s, in a clone that already had most of their objects from an earlier fetch of the pull request refs; a clone without them will take longer. - `python -I` on `tests/test_tool_stdout_encoding.py`, `tests/test_text_write_line_endings.py`, `tests/test_ci_registration.py`, the 13 `tests/test_docs_*.py` and `tests/test_i18n_index.py`; `python -I scripts/check_no_game_data.py` on the four changed files. - Not tested: Linux and macOS (the script and its tests use only git and the standard library, but I ran them on Windows), Python 3.12, which CI runs (`contextlib.chdir` in the test needs 3.11), a git older than 2.55 (2.29 for `fetch --stdin` and 2.38 for `merge-tree --write-tree` are from git's release notes, not from a run), and a host other than GitHub (the merge-ref rule is GitHub's). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule in this change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-26 15:43:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:43:54Z.

Review: COMMENTED


Windows 11: 19/19 overlap tests passed. The suite used disposable local Git repos for ref discovery, dirty path handling, overlap and ref cleanup. No findings from these checks.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6076962924 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#pullrequestreview-6076962924). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T15:43:54Z. **Review:** COMMENTED --- Windows 11: 19/19 overlap tests passed. The suite used disposable local Git repos for ref discovery, dirty path handling, overlap and ref cleanup. No findings from these checks. AI-assisted.
aslan2142 commented 2026-12-01 11:51:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:51:08Z.

Review: COMMENTED


Draft review note: PR-OVERLAP-CHECK (scripts/pr_overlap.py, tests/test_pr_overlap.py, AGENTS.md, CONTRIBUTING.md) is cleanly scoped, mergeable on main, and passed independent unit tests, but remains a draft with no CI run. Please run CI to green and mark ready for review when ready.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130678909 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#pullrequestreview-6130678909). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:51:08Z. **Review:** COMMENTED --- Draft review note: `PR-OVERLAP-CHECK` (`scripts/pr_overlap.py`, `tests/test_pr_overlap.py`, `AGENTS.md`, `CONTRIBUTING.md`) is cleanly scoped, mergeable on `main`, and passed independent unit tests, but remains a draft with no CI run. Please run CI to green and mark ready for review when ready. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:31:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:31:46Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311262038 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#issuecomment-7311262038). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:31:46Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 13:06:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T13:06:08Z.

Review: APPROVED


Now ready for review and MERGEABLE. Clean-room verified: scripts/pr_overlap.py, doc notes in AGENTS.md/CONTRIBUTING.md, and 19/19 disposable-repo tests are clean and verified (@lixonik).

Approving — ready to merge once CI runs green on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131826864 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#pullrequestreview-6131826864). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T13:06:08Z. **Review:** APPROVED --- Now ready for review and `MERGEABLE`. Clean-room verified: `scripts/pr_overlap.py`, doc notes in `AGENTS.md`/`CONTRIBUTING.md`, and 19/19 disposable-repo tests are clean and verified (`@lixonik`). Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
merzleckeier commented 2026-12-01 13:33:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:33:35Z.


Checked a working-tree-only overlap and the current documentation conflict at a3184a475 + e04721c7. The only merge conflict was AGENTS.md following #2871. I kept main’s current guidance and added the new command note locally for the test. The 19 stock tests passed. An extra disposable local Git test added an untracked filename containing a space and a non-ASCII character. The CLI listed the open PR and its exact head, omitted the closed PR on the same path, and reported the path in uncommitted. A cached --no-fetch run produced the same matches. The clean merge status in that case describes the committed heads, while the path overlap still appears.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312815855 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#issuecomment-7312815855). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T13:33:35Z. --- Checked a working-tree-only overlap and the current documentation conflict at `a3184a475` + `e04721c7`. The only merge conflict was `AGENTS.md` following #2871. I kept main’s current guidance and added the new command note locally for the test. The 19 stock tests passed. An extra disposable local Git test added an untracked filename containing a space and a non-ASCII character. The CLI listed the open PR and its exact head, omitted the closed PR on the same path, and reported the path in `uncommitted`. A cached `--no-fetch` run produced the same matches. The `clean` merge status in that case describes the committed heads, while the path overlap still appears. AI-assisted with OpenAI Codex.
andrew-ai commented 2026-12-02 00:45:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-02T00:45:47Z.


Checked rename handling at a3184a475 on Windows using the actual #2903 head (4afb71316) as the sole cached PR. Looking up either exact Git path found #2903, looking up tests/ listed both sides, and tests/semantic/test_address_guard.py correctly found nothing. One caveat for planned paths: uppercase TESTS/TEST_ADDRESS_GUARD.PY also found the existing source file, but TESTS/TEST_ADDRESS_GUARD_ORACLE.PY missed the pending destination. The parent normalized to tests/ while the missing basename retained its uppercase spelling. On a case-insensitive checkout this can hide overlapping claims. Documenting that a not-yet-created filename needs its exact Git casing would clarify the behavior without folding names for case-sensitive trees. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7330929445 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#issuecomment-7330929445). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-02T00:45:47Z. --- Checked rename handling at a3184a475 on Windows using the actual #2903 head (4afb71316) as the sole cached PR. Looking up either exact Git path found #2903, looking up tests/ listed both sides, and tests/semantic/test_address_guard.py correctly found nothing. One caveat for planned paths: uppercase TESTS/TEST_ADDRESS_GUARD.PY also found the existing source file, but TESTS/TEST_ADDRESS_GUARD_ORACLE.PY missed the pending destination. The parent normalized to tests/ while the missing basename retained its uppercase spelling. On a case-insensitive checkout this can hide overlapping claims. Documenting that a not-yet-created filename needs its exact Git casing would clarify the behavior without folding names for case-sensitive trees. Codex-assisted.
MoonEyes commented 2026-12-02 11:49:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:49:54Z.


Closing: this pull request no longer applies to current main (merge conflict in AGENTS.md), and open pull requests that have fallen out of step with main are being closed so the list stays workable. If you still want this change, rebase it on current main and reopen it (or open a new pull request); it will be looked at again.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344466667 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2349#issuecomment-7344466667). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:49:54Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `AGENTS.md`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. If you still want this change, rebase it on current `main` and reopen it (or open a new pull request); it will be looked at again. AI-assisted (Claude Code).

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
ProjectLeonida/mandy!2349
No description provided.