fix: preserve strong references when grouping duplicate imports #6432

Merged
MrMha merged 1 commit from upstream-pr/6432 into main 2026-10-17 13:14:34 +00:00
MrMha commented 2026-10-15 15:00:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MrMha on 2026-10-15T15:00:55Z.


What

Duplicate references to the same NID/library currently inherit the last reference's weak flag. A strong reference followed by a weak one is therefore reported as weak, including in the current-stop record. Mark a grouped import weak only when every reference is weak. The regression verifies both mixed-reference orders, all-strong/all-weak cases, reference conservation, and stop consistency.

Tested

macOS 27.0.1 arm64, Python 3.12.14; tooling fixtures only, no title.

The new regression failed on main ff23657 before the fix. This branch was tested independently from that base.

python3 -m unittest tools.tests.test_import_audit
Ran 85 tests in 1.134s
OK (skipped=1)
python3 tools/check_conventions.py --base ff23657f3437427fc5421857a6f9545e41806f2c --head HEAD
All conventions checks passed.

The combined local validation checkout containing all ten independent tooling fixes also built with ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON and passed all 172 CTest tests. Full Windows/Linux runtime and GPU tests were not run.

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
  • Unimplemented paths throw; silent stubs are listed in technical debt (not applicable to this tooling change)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4875332801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6432). Originally posted by [MrMha](https://github.com/MrMha) on 2026-10-15T15:00:55Z. --- ### What Duplicate references to the same NID/library currently inherit the last reference's weak flag. A strong reference followed by a weak one is therefore reported as weak, including in the current-stop record. Mark a grouped import weak only when every reference is weak. The regression verifies both mixed-reference orders, all-strong/all-weak cases, reference conservation, and stop consistency. ### Tested macOS 27.0.1 arm64, Python 3.12.14; tooling fixtures only, no title. The new regression failed on main `ff23657` before the fix. This branch was tested independently from that base. ```text python3 -m unittest tools.tests.test_import_audit Ran 85 tests in 1.134s OK (skipped=1) python3 tools/check_conventions.py --base ff23657f3437427fc5421857a6f9545e41806f2c --head HEAD All conventions checks passed. ``` The combined local validation checkout containing all ten independent tooling fixes also built with `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON` and passed all 172 CTest tests. Full Windows/Linux runtime and GPU tests were not run. ### 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 - [x] Unimplemented paths throw; silent stubs are listed in technical debt (not applicable to this tooling change) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Dextroid17 commented 2026-10-15 15:39:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T15:39:47Z.


I ran the test this PR adds, on Linux.

Setup: head 8f8949676 merged into main at 92e50418f (no conflicts; the PR's base is 53 commits behind), Linux, Python 3.14.8, clean environment (env -i, only HOME and PATH set). python3 -m unittest -v test_import_audit from tools/tests, 3 runs each.

  • with this PR: 3 of 3 runs pass (85 tests, 1 Windows-only test skipped).
  • with tools/import_audit.py put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each time only at test_duplicate_import_strength_is_order_independent.

With the change, a strong import is kept whichever order the duplicates come in. This PR and #6113 both edit tools/import_audit.py; I checked that they merge together without conflicts.
I did not check Windows or macOS.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6196021267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6432#issuecomment-6196021267). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-15T15:39:47Z. --- I ran the test this PR adds, on Linux. Setup: head 8f8949676 merged into main at 92e50418f (no conflicts; the PR's base is 53 commits behind), Linux, Python 3.14.8, clean environment (`env -i`, only HOME and PATH set). `python3 -m unittest -v test_import_audit` from tools/tests, 3 runs each. - with this PR: 3 of 3 runs pass (85 tests, 1 Windows-only test skipped). - with tools/import_audit.py put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each time only at `test_duplicate_import_strength_is_order_independent`. With the change, a strong import is kept whichever order the duplicates come in. This PR and #6113 both edit tools/import_audit.py; I checked that they merge together without conflicts. I did not check Windows or macOS. AI-assisted: yes
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!6432
No description provided.