feat(tools): recommend verified local game patches #8900

Merged
WhiteAssassins merged 6 commits from upstream-pr/8900 into main 2026-10-24 14:51:48 +00:00
WhiteAssassins commented 2026-10-21 05:07:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by WhiteAssassins on 2026-10-21T05:07:58Z.


What

Add an opt-in, offline advisor for user-supplied patch catalogs. It reads titleId and contentVersion from an explicit param.json, checks the SHA-256 of every target named by the patch, then asks the specified relinker to run --verify-patches. A repeatable --executable option covers patches that target other executables of the title. It recommends a patch file only when the metadata and hashes match and the relinker confirms every patch. The tool neither downloads nor applies patches; the catalog and patch files stay outside this repository.

This implements the offline advisor proposed in Ideas discussion #8893, building on the patch support in #6314. Please also review the discussion: it explains the motivation, community catalog proposal, and possible future web or GUI patch selection. Applying patches after conversion is only an idea for separate design work; this PR does not implement it. Feedback on whether discovery belongs in this repository and on the catalog format is welcome.

No game files or title-specific patch files are included in this PR.

Known limits

  • If more than one catalog entry verifies for the same title and version, the advisor recommends none. A single TOML file can contain multiple [[patch]] entries, but choosing or combining separate patch files needs a follow-up design.
  • SHA-256 is checked against the unwrapped target files. Different dump tools could produce different bytes for the same title version, causing an otherwise applicable patch to be rejected; identical output across dump tools has not been established.

Tested

  • CachyOS Linux: 24 unit tests cover catalog validation, entry isolation, relinker errors, multiple verified entries, option forwarding, and recommendation logic with a mocked relinker.
  • CachyOS Linux: game_patches, patch_advisor_unit, and patch_advisor_integration passed through CTest with a newly built relinker. The integration test exercises --relinker ./relinker, a valid synthetic ELF patch, a relinker byte mismatch, a hash mismatch, and a patch TOML with an escaped string that the relinker rejects. A valid second catalog entry is still recommended; a catalog with only the invalid entry exits 2.
  • CachyOS Linux: a separate manual synthetic test of --executable passed verification with the real relinker.
  • CachyOS Linux: the advisor recommended the DREDGE PPSA09076 01.011.000 patch after the relinker verified the local unwrapped input and module. The title owner reports that the game fails to launch without the patch and launches and plays normally with it; gameplay was not part of the automated tests.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • python3 tools/check_test_registration.py --scripts: passed; both advisor tests are registered with CTest for Python 3.11+.
  • python3 tools/pr_overlap.py --branch feat/patch-advisor: no code overlap reported; comparisons involving docs/user/USAGE.md were inconclusive for several PRs.
  • git diff --check: passed.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (n/a: no unimplemented paths in this Python tool)
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (n/a: no new third-party code)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4946705213 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8900). Originally posted by [WhiteAssassins](https://github.com/WhiteAssassins) on 2026-10-21T05:07:58Z. --- ### What Add an opt-in, offline advisor for user-supplied patch catalogs. It reads `titleId` and `contentVersion` from an explicit `param.json`, checks the SHA-256 of every target named by the patch, then asks the specified relinker to run `--verify-patches`. A repeatable `--executable` option covers patches that target other executables of the title. It recommends a patch file only when the metadata and hashes match and the relinker confirms every patch. The tool neither downloads nor applies patches; the catalog and patch files stay outside this repository. This implements the offline advisor proposed in [Ideas discussion #8893](https://github.com/boykopovar/AnyPS5/discussions/8893), building on the patch support in #6314. Please also review the discussion: it explains the motivation, community catalog proposal, and possible future web or GUI patch selection. Applying patches after conversion is only an idea for separate design work; this PR does not implement it. Feedback on whether discovery belongs in this repository and on the catalog format is welcome. No game files or title-specific patch files are included in this PR. ### Known limits - If more than one catalog entry verifies for the same title and version, the advisor recommends none. A single TOML file can contain multiple `[[patch]]` entries, but choosing or combining separate patch files needs a follow-up design. - SHA-256 is checked against the unwrapped target files. Different dump tools could produce different bytes for the same title version, causing an otherwise applicable patch to be rejected; identical output across dump tools has not been established. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - CachyOS Linux: 24 unit tests cover catalog validation, entry isolation, relinker errors, multiple verified entries, option forwarding, and recommendation logic with a mocked relinker. - CachyOS Linux: `game_patches`, `patch_advisor_unit`, and `patch_advisor_integration` passed through CTest with a newly built relinker. The integration test exercises `--relinker ./relinker`, a valid synthetic ELF patch, a relinker byte mismatch, a hash mismatch, and a patch TOML with an escaped string that the relinker rejects. A valid second catalog entry is still recommended; a catalog with only the invalid entry exits 2. - CachyOS Linux: a separate manual synthetic test of `--executable` passed verification with the real relinker. - CachyOS Linux: the advisor recommended the DREDGE `PPSA09076` `01.011.000` patch after the relinker verified the local unwrapped input and module. The title owner reports that the game fails to launch without the patch and launches and plays normally with it; gameplay was not part of the automated tests. - `python3 tools/check_conventions.py --base origin/main`: passed. - `python3 tools/check_test_registration.py --scripts`: passed; both advisor tests are registered with CTest for Python 3.11+. - `python3 tools/pr_overlap.py --branch feat/patch-advisor`: no code overlap reported; comparisons involving `docs/user/USAGE.md` were inconclusive for several PRs. - `git diff --check`: passed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file (n/a: no unimplemented paths in this Python tool) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (n/a: no new third-party code) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 05:19:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:19:26Z.


I ran the exact PR head 04ec954284 locally on Linux: python3 tools/tests/test_suggest_patches.py passed all 5 tests; python3 tools/check_conventions.py --base upstream/main passed; git diff --check passed. This is synthetic/tooling validation only, not a title or GPU test.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308684529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8900#issuecomment-6308684529). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T05:19:26Z. --- I ran the exact PR head `04ec954284` locally on Linux: `python3 tools/tests/test_suggest_patches.py` passed all 5 tests; `python3 tools/check_conventions.py --base upstream/main` passed; `git diff --check` passed. This is synthetic/tooling validation only, not a title or GPU test.
MarcZX10 commented 2026-10-21 05:36:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:36:57Z.


I ran the PR revision test file on Linux with Python 3.11: all 5 patch-advisor tests pass. The CLI help also runs, and git diff --check against upstream/main passes. The suite mocks the relinker subprocess, so this verifies the catalog validation and recommendation flow, not an end-to-end relinker invocation or full project build.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308910780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8900#issuecomment-6308910780). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T05:36:57Z. --- I ran the PR revision test file on Linux with Python 3.11: all 5 patch-advisor tests pass. The CLI help also runs, and git diff --check against upstream/main passes. The suite mocks the relinker subprocess, so this verifies the catalog validation and recommendation flow, not an end-to-end relinker invocation or full project build.
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!8900
No description provided.