fix(tools): detect exports already present on main #8970
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8970"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-21T07:54:28Z.
What
Extends the PR overlap checker to compare each PR's newly added export NIDs against the target base branch. The comparison recognizes
APS5_VABIdefinitions,APS5_ASM_FUNCTIONandAPS5_SIGNAL_ASM_FUNCTIONexports, and literal NIDs fromAPS5_EXPORT. It reports matching export names already present onmain, including when a plain-name export maps to an implementation with a_nid_postfixsuffix. NIDs removed by the same diff are subtracted so in-place replacements are not reported as duplicates.This is the follow-up suggested by Dean in #8961. It is based on current upstream
mainand does not depend on #8961.Tested
python -m unittest discover -s tools/tests -p 'test_pr_overlap*.py'— 69 tests passed; 4 platform-specific tests skipped.python -I tools/check_conventions.py --base upstream/main --head HEAD— passed.git diff --check— passed.python tools/pr_overlap.py --repo boykopovar/AnyPS5 --base main --branch HEAD— no overlap with currently open PRs.main: 9,128 distinct export NIDs recognized.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-21T07:56:25Z.
Credit for the idea: @oneandonlydean
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T07:59:54Z.
@xdCloudy thanks, this catches the right thing. I ran
source_added_exportsandbase_exportsfrom this head against currentmainon a few PRs. It flags exactly the duplicates found by hand earlier: the plain-name stubs over_nid_postfiximplementations on the earlier heads of #8944 and #8951, all four in #8946, and a plaingetcontextstub over libkernel'sAPS5_ASM_FUNCTIONone. Clean stub PRs come back empty.One problem before it's useful: a PR that replaces an existing stub in place is flagged too, because "added" counts every
+definition line and nothing subtracts what the same diff removes. #8805 replaces 18 throwing stubs with implementations and gets all 18 reported as "already onmain". The same happens whenever a PR edits an existing export's signature line. Since most libs PRs look like that, the column would mostly be noise.Could you drop NIDs whose definition the same diff removes (run
source_exportsover the-lines as well), or count definitions per NID on the merged tree and report only those defined more than once? A test with a stub replaced in place would pin it.Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-21T08:02:45Z.
Fixed in f23c960f. The checker now derives export NIDs from both added and removed lines and subtracts NIDs removed by the same diff before comparing with base main, so replacing an existing export in place no longer reports it as a duplicate. Added a regression test for a _nid_postfix stub replaced by its plain-name implementation. The overlap test suite passes: 69 tests, 4 platform-specific skips; the conventions check passes locally.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:45Z.
Linux data point for
f23c960f38: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), Python 3.12, PR head alone (not merged ontomain),python3 -I -m unittest discover -s tools/tests -p test_pr_overlap_exports.py.tools/pr_overlap.pyrestored to the merge-base (the PR's tests kept): 1 failure and 5 errors (e.g. test_report_includes_exports_already_on_main, test_added_raw_export_matches_base_definition).Not tested: macOS, Windows, a merge onto current
main.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T14:09:46Z.
Review: COMMENTED
Verified on Windows 11, Python 3.14, merged onto main
80565c594:python -I -m unittest discover -s tools/tests -p "test_pr_overlap*.py": 71 tests OK, 4 skipped (69 OK at the head alone).check_conventions.pyagainst the merge base passes.tools/pr_overlap.py: the new tests give 1 failure and 5 errors, the same as the Linux run above.source_changed_exports(diff, "-")in f23c960f.base_exportstakes about 19 s here and runs a singlegit archive, so no long command line on Windows.Two problems with the new column:
The finding is stored under key
0(rows[number][0] = {"added": set(), "main_exports": names},tools/pr_overlap.py:344), andreport()turns every key into a PR link (:285).pr_overlap.report({0: {"added": set(), "main_exports": {"sceKernelRead"}}}, blob)renders| [PR 0](https://www.github.com/boykopovar/AnyPS5/pull/0) | | |sceKernelRead| |under "Other open pull requests touch the same code".test_report_includes_exports_already_on_mainuses key9, so it does not catch this. Could the names already onmainget their own section instead of a PR row, with a test that goes through the__main__row construction?Matching is by NID alone, across libraries. Running the PR's own
source_exportsovercore/libs/prxon main finds 44 NIDs exported by more than one library, e.g.0hlfW1O4Aa4(libclocaleconv,libSceAmprsceAmprLocaleconv),-vXEQdRADLI(strtok_s/sceAmprStrtokS),2UFh+YKfuzk(ctime_s/sceAmprCtimeS). A PR adding a correct export of such a NID to a second library would be listed as "already onmain". Keying both sides by(core/libs/prx/<library>, NID)would keep the same-library duplicates and drop these.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-21T17:00:05Z.
Following up on the review:
d9aa2c2889. “Already on main” matches now render in a dedicated section with no synthetic PR 0 row, and export keys use(core/libs/prx/<library>, NID)on both the PR diff and base tree. Added tests cover report construction and cross-library NID matches._nid_postfixstub with its plain-name definition.mainand reran the overlap suite on Windows: 72 tests passed, 4 platform-specific skips.tools/pr_overlap.pyhunk. It adds end-of-run workflow summary logging after report generation; it does not change export matching or report construction. The final overlap scan reports only #988 as uncomparable because its branch conflicts with base, so that result is recorded here as a manual review.check_conventions.pyandgit diff --checkalso pass. No merge performed.Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T17:56:46Z.
Review: APPROVED
Rechecked d9aa2c288 merged onto main
950388bfd: names already onmainnow render in their own "Exports introduced here that are already present inmain" section with no PR 0 row,base_exportskeys exports by library vialibrary_for_path, andtest_pr_overlap*.pypasses (4 platform skips).Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-21T18:49:22Z.
Thanks for rechecking the updated head against main and confirming the dedicated main-export section, per-library NID matching, and the overlap test results. I appreciate the approval and the careful follow-up.
Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-22T01:33:56Z.
Relevant: GitHub could not compare #988 because its branch conflicts with base. I’ll manually review the shared tools/pr_overlap.py changes and update this PR if coordination is needed. This warning does not itself identify an export overlap.
Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-22T02:17:21Z.
The Ubuntu relinker check on this PR was cancelled. I tried to rerun it, but GitHub requires repository admin rights. Locally, the current head passes the merge-tree check against current main,
python -I -m unittest discover -s tools/tests -p test_pr_overlap*.py(72 passed, 4 skipped),python -I tools/check_conventions.py --base upstream/main, andgit diff --check. Could someone with the required permission rerun the cancelled hosted job?Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-22T04:57:27Z.
Follow-up on the overlap bot warning: I reviewed #988's exact
tools/pr_overlap.pyhunk. It only adds end-of-run workflow summary logging afterwrite_reports; it does not change export extraction, matching, or report construction. I found no functional overlap with this PR. The warning is relevant as a shared-file/manual-review notice, not as a duplicate-export finding. This is the completed result of my earlier manual check.