Repository navigation
fix(tools): read preprocessor branch combinations lazily in import_audit - #11622
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
I found one issue in the lazy expansion path. In branch_variants.expand, each conditional group eagerly materializes choices with a list comprehension before the outer iterator can yield (tools/import_audit.py, around lines 542–544). With nine nested two-way #ifdef groups inside the first branch of an outer conditional, next(branch_variants(body)) raises AuditError: more than 256 preprocessor branch combinations before yielding even the first variant. I reproduced this against the PR head. That first branch can already let conditional_stubs stop as soon as it sees a variant without a stub call, so the current implementation still rejects some functions that need only one combination to classify. Please keep nested choices lazy as well, with a regression test where an early branch is enough to classify the function and a later nested branch contains more than 256 combinations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@MarcZX10 Thanks, you're right: each group's alternatives were still built in full before the first combination came out. The test now includes your layout: an outer |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 3d2aebfa0313a518a43530f2a9da777f196cb330. choices() now expands nested alternatives lazily, and limited() counts complete variants only as the consumer requests them. The regression test covers both early classification without exhausting nested branches and the case where all combinations must be read and the 256 limit still applies. The author also reports randomized equivalence checks against main. I independently ran python3 -m unittest tools.tests.test_import_audit in a detached checkout: 154 tests passed, 1 skipped; tools/check_conventions.py --base upstream/main --head 3d2aebfa0313a518a43530f2a9da777f196cb330 and git diff --check upstream/main...upstream/pr/11622 pass. No remaining actionable finding.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed 3d2aebfa0313a518a43530f2a9da777f196cb330. Approve: branch combinations are generated lazily, including nested alternatives, while the 256-result limit still applies when all combinations must be consumed.
Windows/Python 3.11.9: 151 import-audit tests passed, 3 skipped, 154 total. An independent control against author base 74acfad6 produced identical ordered output for all 256 eight-branch combinations. For nine branches, including a nested case, the old code fails before yielding the first combination; this head yields the first and still raises when asked for the 257th. This establishes both the lazy behavior and the retained limit.
Hosted Windows, Linux and both macOS relinker jobs ran the registered import-audit suite on merges containing this head. Product jobs were skipped. The focused validation covers the Python audit, not a full application or game run.
|
A real-world check of Setup: converted import registries (
I did not compare classifications line by line with an older AI-assisted: yes (Claude Code). |
|
Independent Linux confirmation of your Ubuntu 26.04.1 x86-64, Python 3.14.4:
These are fresh Linux Python/static-audit checks using archived converted assets, not new title, native-game, Windows or console execution. The runtime libraries retain their original October 17/23 build pins; no PR branch has been changed. AI-assisted validation and reporting: OpenAI Codex. |
|
@BunnyFl Independent Windows confirmation of
Reproduction script, test logs, negative control and exact pins. These are public-source and synthetic-fixture checks, not fresh game execution, a full import-registry audit, or a claim that classifications were compared with an older main. No branch limit was raised. I encountered the same AI-assisted validation and reporting: OpenAI Codex. |
|
Checked the lazy expansion (nested alternatives and the complete-combination limit), that |
What
Since #9509,
pollincore/libs/prx/libkernel/Socket/src/Udp.cpphas more than 256 preprocessor branch combinations.branch_variantsbuilds every combination of every function up front, so eachtools/import_audit.pyrun onmainstops withFAIL: more than 256 preprocessor branch combinations in one functionbefore it audits anything.pollis the only function incore/libs/prxover the limit.branch_variantsnow produces the combinations one at a time, in the same order as before. The alternatives of nested#ifgroups are also produced only when needed, and the limit counts only complete combinations.conditional_stubsstops at the first combination that does not reach a stub call, so a function fails only when the audit has to read more than 256 of its combinations.always_stub_callsstill reads all of them.Tested
Windows 11, Python 3.14.7.
python -m unittest test_import_auditintools/tests: 154 tests OK (3 skipped). The new test uses nine independent#ifdefblocks (512 combinations). It covers a function without a stub call; a function whose stub call sits in the last#ifdefand is reported as partial; a function whose first branch of an outer#ifdefholds the nine blocks, with the stub call in#else, also reported as partial; and two functions that reach a stub in every combination (flat and nested), which still fail. The test fails onmainwith the error above, and its nested case also fails on this PR's first head 94d991e.#if/#ifdef/#ifndef/#elif/#else(three seeds): every body gives the same combinations in the same order asmain'sbranch_variants, or fails the limit in both. In a fourth set of 20,000, all 2,087 bodies with 257 to 4,096 combinations givemain's first 256 combinations inmain's order (with its limit raised to 4,096), and the 257th fails.core/libs/prx(28,805 on 74acfad; 28,498 on c8809e8,mainjust before fix(libkernel): report urgent data in poll on macOS #9509): the newbranch_variantsreturns the same strings in the same order asmain's. The only body that fails onmainispoll.source_stub_classes: identical tomain's on c8809e8 (6,337 stubs, 451 partial). On 74acfad it is identical tomain's code withBRANCH_VARIANT_LIMITraised to 4096 (6,349 stubs, 470 partial).main's tool on 74acfad exits 2 with the error above, and this PR's tool completes the audit. With--sourceset to c8809e8, both tools write identical text and identical--jsonoutput.Because of this error, the audits in #11607, #11608 and #11609 were run with
--sourceset to c8809e8.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)🤖 Generated with Claude Code