feat(tools): split guarded exports into a partial import_audit class #9372
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9372"
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 mehmetbayoglu on 2026-10-21T19:32:17Z.
What
import_auditcounted every export whose source reachesNotImplemented_nid_no_patchas a stub, so an implemented export that throws only for an unknown input (as CONTRIBUTING asks) looked the same as one that does nothing. Exports are now split:NotImplemented_nid_no_patchon every path, directly or through a helper that always reaches it.if,else, a loop,switch, a ternary, a short-circuit or a lambda). Preprocessor branches inside the body are expanded: each combination of#if,#elifand#elsealternatives is checked on its own (an#ifwithout#elsehas an empty alternative), and the export is partial when at least one combination does not reach the throw, stub when all do. An export wrapped in a preprocessor block from outside its body keeps its class.The JSON and text reports gain a
partialclass next toimplemented,stub,absentandmodule.source_stubskeeps its result for other callers;progress.pyand the progress page are unchanged.Tested
python -m unittest tools/tests/test_import_audit.pyruns 124 tests, all pass (3 skipped, as onmain). New cases cover a direct throw, a throw through a helper, and a throw under each kind of condition.test_unscoped_registry_imports_use_guest_module_exports, added onmainafter this change was written, now expects"partial": 0inunique_by_class.tools/import_audit.py(weak imports, Windows suffixes, NID-only exports); none classifies stubs, so whichever merges second only needs a rebase.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 xXPBSXx on 2026-10-22T03:14:21Z.
Linux data point for
7052d21d53(WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; Python 3.12.3), this head merged ontomaina6dcea927(clean merge),python3 -I tools/tests/test_import_audit.py:test_import_audit.pyon top ofmainwithout the PR's source change): FAILED (16 failures, 2 errors).Not tested: macOS, Windows.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T05:33:14Z.
Windows data point on real titles, given as data only. I took 22 PS5 titles whose
eboot.binand bundled modules (sce_module, UnityMedia/ModulesandMedia/Plugins) I'd unwrapped and converted withrelinker --windows --registry.For each title I ran both
tools/import_audit.pyversions on the same registries, against the same built libraries and each version's own--sourcetree:mainatd9c99c9ba4main(4952ee563a, clean merge)The setup was Windows 11 22621 with Python 3.15. I didn't pass
--modules, so both versions count the titles' own module imports as absent in the same way; only the stub and partial columns are compared here.Totals across the 22 titles:
stubtopartial, and 904 staystub.implementedandabsentare identical in every title.The most common moves to
partial:sceSystemServiceParamGetInt(22 of 22 titles): it returns the language, date and time formats, time zone and so on, and throws only for the registry-backed IDs.sceAjmBatchStart,sceAjmInstanceCreateandsceAjmBatchJobInitialize(20 titles each).sceSystemServiceLoadExec.sce::Np::CppWebApicontainer members.Those that stay
stub:__tls_get_addr.sceAgcDriverRequestCaptureStart/Stop/TriggerCapture: for example,sceAgcDriverTriggerCaptureis justNotImplemented_nid_no_patch(__func__); return 0;.sceAgcAcbSetWorkload*.sceNpTrophy2GetRewardIcon.I read the source of
sceAjmBatchStart(partial) andsceAgcDriverTriggerCapture(stub), and both match the new classes. Onmain, every title's report listedsceSystemServiceParamGetIntas a stub that "throws when called", which is wrong for the common parameter IDs.Not checked: the other 356 moved entries one by one, or macOS.
Imported from boykopovar/AnyPS5. Originally posted by mehmetbayoglu on 2026-10-22T05:48:27Z.
Thanks @xXPBSXx and @JJenkx for the independent runs. The 22-title comparison is exactly the effect intended: 358 guarded exports move from stub to partial, and implemented and absent stay identical.
__tls_get_addrstaying a stub is expected here; #9059 implements it.Imported from boykopovar/AnyPS5. Originally posted by mehmetbayoglu on 2026-10-22T06:47:01Z.
Pushed 3d9fbbf7ad after @JJenkx's note on #9059: a
NotImplemented_nid_no_patchcall inside an#if,#ifdefor#ifndefblock opened in the export's own body now makes it partial (it throws on some hosts only), while an export wrapped in a preprocessor block from outside its body keeps its class.__tls_get_addrfrom #9059 now classifies as partial. The test gains three cases (a throw in the#elsebranch, a throwing helper under#ifdef, and an always-throwing export wrapped from outside), and the 124 tool tests pass on Windows. The 22-title comparison above predates this commit, so exports with host branches may now also move from stub to partial.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T06:51:47Z.
Review: CHANGES_REQUESTED
I ran the exact head
3d9fbbf7adf554a53a32951771f21f2b0efabdc2locally: -python3 -I tools/tests/test_import_audit.py: 124 tests passed, 1 skipped. -python3 tools/check_conventions.py --base upstream/main --head refs/review/9372: passed. -git diff --check: passed. - Current-main merge-tree check: clean. I found a classification edge case not covered by the suite. For an export whose body is:cpp #if defined(_WIN32) NotImplemented_nid_no_patch(__func__); #else NotImplemented_nid_no_patch(__func__); #endifunconditional_calls()returns no stub call and the export becomespartial. Both preprocessor alternatives throw unconditionally, so this should remainstub. I reproduced this against the exact head. Please add a regression covering all mutually exclusive branches and classify the export asstubwhen every viable branch reaches the throwing call. The current line-based depth check sees a guarded call but does not account for#else/#elifalternatives. I withdraw the queue-based title-evidence hold. It is fine to keep submitting PRs; maintainers will handle them in due course. The current hosted Ubuntu and ASan relinker checks pass; macOS and Windows relinker checks remain pending, and product builds are skipped. The remaining implementation concern is the preprocessor-classification regression described above.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by mehmetbayoglu on 2026-10-22T06:57:08Z.
@MarcZX10 Thanks, you were right. Pushed 72664d1ef9: preprocessor branches in the body are now expanded, each combination of
#if/#elif/#elsealternatives is checked on its own (an#ifwithout#elsegets an empty alternative), and the export is a stub when every combination reaches the throw. New regressions cover all branches throwing (#if/#elseand#if/#elif/#else), a nested case where one combination returns (partial), and an export wrapped from outside (stub). All 124 tests pass, and overcore/libs/prxthe classification moves by 2 exports compared with the first version.On intake: this is a tooling change and no title stops on it, so it does not meet the named-title rule. The use case is bring-up triage; JJenkx's 22-title comparison above shows 358 imports that audits currently report as throwing on every call. I'll leave it to the maintainers whether that is worth an exception; otherwise I'm happy to hold it as a draft until the queue is below the threshold.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T13:21:36Z.
Windows rerun on head 72664d1ef9, as data only. I used the same 22 titles' relinker registries as my earlier comment. The head was merged onto
main8b3a6ba88d, with libraries built frommain8b3a6ba88d+ #9628 and--sourceset to the merged tree'score/libs/prx(main's own tree for themainside). Python 3.15 on Windows 11.mainPer title, the only change is stub to partial: 1 to 30 imports per title (27 for seven titles, 30 for PPSA16064). No import changes any other class. Raw outputs are
<title>.main.txtand<title>.pr.txt, available on request.My earlier figure of 358 came from an older
mainand is not comparable. The previous head (da54c652e3) classifies 0 imports as partial against today'smainsources, so I could not separate the effect of the preprocessor-branch commits frommain's movement since then.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by mehmetbayoglu on 2026-10-22T13:25:04Z.
Thanks @JJenkx for the rerun on 72664d1ef9. That is the expected shape: 267 imports move from stub to partial against today's
main, and implemented, absent and the other stubs stay identical across the 22 titles. I'll treat 267 as the current figure in place of the earlier 358.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T22:39:07Z.
Review: APPROVED
I rechecked the exact current head
72664d1ef99aca45fc3b6f17ddbd0653e4eae2eb. The branch-variant expansion now treats each mutually exclusive#if/#elif/#elsechoice separately and correctly keeps an export classified as a stub when every combination reaches the throwing call; the regression covers all-throw alternatives, a mixed nested case, and an export wrapped from outside its body. I ranpython3 -I tools/tests/test_import_audit.pyon the exact PR head: 124 tests passed, 2 skipped. I also generated a clean synthetic merge with currentupstream/main853baf3bb95e3a6fb8f1b58d0f7b5bd4cba2d306and reran the suite: 124 passed, 2 skipped. Current-head hosted eligibility, conventions, relinker matrix and ASan checks are green; product build jobs are skipped by the repository path policy. I found no remaining blocker in the requested fix.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T23:38:05Z.
Review: CHANGES_REQUESTED
Reviewed 075bb421b82e against 495b7c10abc2. Changes requested for an unconditional stub incorrectly classified as partial, allowing a strict audit to succeed.
tools/import_audit.py:545–549— Preserve unconditional throws inside ordinary blocksThe brace-depth test in
unconditional_callsignoresNotImplemented_nid_no_patchinside a plain compound statement. Forint APS5_VABI sceAlways(int value) { { NotImplemented_nid_no_patch(__func__); } return 0; }, there is no conditional path: every invocation reaches the throw. Nevertheless, the submitted code classifies the export aspartial. Using the actual CLI audit path with a synthetic ELF provider, registry and source tree,--strict-stubsreturns 0 for this form. Removing only the inner braces yieldsstuband exit 1. On the pristine baseline both forms arestuband exit 1. This directly reproduces an author-introduced regression without changing production source.Please inspect ordinary unconditional compound statements while retaining the distinction from conditional or deferred lambda bodies. Add a regression requiring both direct and plain-block throws to remain stubs and fail strict audits; retain genuinely conditional successful paths as partial.
Validation: Windows x64 / CPython 3.11: full import-audit suite 126 passed, 3 skipped; 129 total. Baseline: 124 passed, 3 skipped; 127 total. New-tests/old-code control has 16 schema-expectation failures and two missing-new-API errors; those are not the evidence for this finding. The independent two-form head/baseline reproduction above is decisive. Conventions, whitespace and registration pass. Effective hosted relinker matrix/ASan and conventions succeed; an earlier cancelled conventions run is superseded. Product jobs are skipped.
Scope: This finding concerns static classification and strict CLI status. Fixtures use real audit/report code and synthetic source/ELF files; no full application or title execution is claimed.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T00:06:02Z.
Review: APPROVED
Re-reviewed
1ee2fe9ff97fa6a09f24622a3e65fbeb2342a09cagainst38d463a6cfd2bbddc147a34e8b14f5b6f661607a. The blocking finding in my previous review is resolved; no further actionable findings in this focused re-review.Source review:
unconditional_callsnow recursively inspects ordinary compound statements while preserving conditional/deferred-body exclusions. Inspected the updated author diff and surrounding classification flow. The strict-stub test now covers the plain-block case for both weak and strong imports. Rebase changes were compared against the new merge base rather than treated as new author changes.Validation: Windows x64 / Python 3.11:
tools/tests/test_import_audit.py -v, 135 passed, 3 skipped; 138 total. New merge-base suite: 133 passed, 3 skipped; 136 total. Independently reran the actual CLI with synthetic provider/registry/source fixtures: direct, plain-block and nested-block throws arestubwith strict exit 1; conditional and deferred-lambda throws arepartialwith strict exit 0. This directly checks the prior reproduced defect without editing production code. Grafted baseline tests have schema/API incompatibilities and are not the evidence for resolution. Conventions, whitespace and script registration passed. Current hosted relinker matrix, ASan and conventions succeeded; full-product jobs were skipped.Scope: Static classification and Python audit behavior; no full application or title execution.