feat(tools): add an import audit for converted games #1461

Merged
abderahmane-ai merged 1 commit from upstream-pr/1461 into main 2026-10-08 13:59:57 +00:00
abderahmane-ai commented 2026-10-08 08:02:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by abderahmane-ai on 2026-10-08T08:02:37Z.


What

Adds tools/import_audit.py, which classifies every import of a converted game in one pass instead of one failing function per launch (see #1033, #1305).

It reads the JSON from relinker --registry and the built .prx files (ELF .dynsym and PE export table, the same view the loader has), and puts each NID and library pair in one class:

  • implemented: a built library exports it
  • stub: exported, but the whole function calls NotImplemented_nid_no_patch, found through tools/progress.py
  • absent: no built library exports it, so the loader fails
  • module: the import names a file in --modules, the title's own library; not checked

It also lists needed libraries that have no file, and imports exported only by a library other than the one they name (they resolve on Linux and can fail on Windows). --names takes an aerolib.csv-style file to name absent imports and never downloads one; --json writes the full result stamped with the commit. Exit code is 1 when anything blocks loading.

Related: #552 turns a list of missing NIDs into stubs; this produces that list.

Tested

  • python3 tools/tests/test_import_audit.py (13 tests, registered in CTest as import_audit): ELF and PE libraries built byte by byte, undefined and local symbols excluded, every reference lands in exactly one class (a check that fails on the residue), invalid registry entries, truncated libraries, a UTF-8 BOM, a missing names file that must not download, and the NID of sceMsgDialogProgressBarSetValue (wTpfglkmv34, from #906) as an outside anchor.
  • Broke the tool eight ways in a throwaway copy (stub class dropped, undefined or local symbols counted, # suffix kept, duplicate references collapsed, postfix kept, module check removed, a done twin not winning over a stub); the tests caught all eight.
  • macOS 26.5 arm64: ran the audit on the output of relinker --registry from a relinker built from this branch.
  • On the real source tree, stub detection gives 435 stub NIDs from 439 pending names; the 4 missing are implemented in another library.
  • python3 tools/check_conventions.py --base origin/main passes.
  • Not tested: against built libraries on Linux or Windows (libs does not build on this host; the readers mirror nid_patcher's), and on a real title.

The code, tests and docs were written with AI assistance. I read every line and ran the checks above.

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 in TechnicalDebt
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4783764539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1461). Originally posted by [abderahmane-ai](https://github.com/abderahmane-ai) on 2026-10-08T08:02:37Z. --- ### What Adds `tools/import_audit.py`, which classifies every import of a converted game in one pass instead of one failing function per launch (see #1033, #1305). It reads the JSON from `relinker --registry` and the built `.prx` files (ELF `.dynsym` and PE export table, the same view the loader has), and puts each NID and library pair in one class: - `implemented`: a built library exports it - `stub`: exported, but the whole function calls `NotImplemented_nid_no_patch`, found through `tools/progress.py` - `absent`: no built library exports it, so the loader fails - `module`: the import names a file in `--modules`, the title's own library; not checked It also lists needed libraries that have no file, and imports exported only by a library other than the one they name (they resolve on Linux and can fail on Windows). `--names` takes an `aerolib.csv`-style file to name absent imports and never downloads one; `--json` writes the full result stamped with the commit. Exit code is 1 when anything blocks loading. Related: #552 turns a list of missing NIDs into stubs; this produces that list. ### Tested - `python3 tools/tests/test_import_audit.py` (13 tests, registered in CTest as `import_audit`): ELF and PE libraries built byte by byte, undefined and local symbols excluded, every reference lands in exactly one class (a check that fails on the residue), invalid registry entries, truncated libraries, a UTF-8 BOM, a missing names file that must not download, and the NID of `sceMsgDialogProgressBarSetValue` (`wTpfglkmv34`, from #906) as an outside anchor. - Broke the tool eight ways in a throwaway copy (stub class dropped, undefined or local symbols counted, `#` suffix kept, duplicate references collapsed, postfix kept, module check removed, a done twin not winning over a stub); the tests caught all eight. - macOS 26.5 arm64: ran the audit on the output of `relinker --registry` from a relinker built from this branch. - On the real source tree, stub detection gives 435 stub NIDs from 439 pending names; the 4 missing are implemented in another library. - `python3 tools/check_conventions.py --base origin/main` passes. - Not tested: against built libraries on Linux or Windows (`libs` does not build on this host; the readers mirror `nid_patcher`'s), and on a real title. The code, tests and docs were written with AI assistance. I read every line and ran the checks above. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-08 13:59:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T13:59:21Z.


Rebased on current main (only CMakeLists.txt conflicted: the Python test block moved; import_audit is registered next to progress_report).

Checked: build + ctest green (460/460), tools/check_conventions.py passes, import_audit fails when tools/import_audit.py is reverted, registry fields match what relinker --registry writes on main, and the audit runs against the Linux-built .prx files. Not run here: PE libraries from a real Windows build. Merging once CI is green.

#1462 is stacked on this one and will need a rebase after the merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6061513943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1461#issuecomment-6061513943). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T13:59:21Z. --- Rebased on current `main` (only `CMakeLists.txt` conflicted: the Python test block moved; `import_audit` is registered next to `progress_report`). Checked: build + ctest green (460/460), `tools/check_conventions.py` passes, `import_audit` fails when `tools/import_audit.py` is reverted, registry fields match what `relinker --registry` writes on main, and the audit runs against the Linux-built `.prx` files. Not run here: PE libraries from a real Windows build. Merging once CI is green. #1462 is stacked on this one and will need a rebase after the merge.
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!1461
No description provided.