pe: harden atomic report writes and path/XML/mmap error guards in resource_inventory with CLI suite #2574
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2582"
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 R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T21:45:47Z.
Summary
Hardens
tools/resource_inventory.pywith atomic report staging, cleanmain(argv=None) -> intreturn semantics, and explicit path/XML/mmap/validator error guards without raw tracebacks, backed by a standalone pure-Python CLI test suite registered in CTest.Changes
tools/resource_inventory.py:main(argv=None) -> intto return0and invokeraise SystemExit(main())under__main__.NamedTemporaryFile(delete=False)write with_write_atomic_json()usingtempfile.TemporaryDirectory(dir=output.parent)+os.replace(), rejecting existing directory targets, leaving zero temporary artifacts on failure, and preserving any pre-existing report ifjson.dump()oros.replace()fails.args.directory.resolve(strict=True)androot.is_dir(), wrapread_layout(layout)against(OSError, ET.ParseError, KeyError), guard--shader-control(missing/directory/ValueError), guardprobe_archive()(OSError,ValueErroron empty RPF9), and guard--scene-records/--scene-validator(missing/directoryshaders.rpf, missing/directory validator, and(OSError, ValueError, KeyError, struct.error, subprocess.SubprocessError, json.JSONDecodeError)).1viaparser.exit(1, f"resource_inventory: {exc}\n")(zero raw tracebacks) while preservingparser.error(...)exit2forlayout*.xmlcount != 1 tested bytests/layout_chunks_check.py.tests/resource_inventory_cli_check.py:CMakeLists.txt:pe_resource_inventory_cli_checkin CTest right afterrange_manifest_check.Verification
All commands executed after rebasing onto
upstream/main(8f045aee):out/pe-env/Scripts/python.exe -B tests/resource_inventory_cli_check.py -vRan 7 tests in 0.895s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/layout_chunks_check.pylayout chunk summary ok(exit 0)out/pe-env/Scripts/python.exe -B tests/scene_records_check.py out/build/dev/DualUav.cso out/build/dev/triangle_ps.cso out/build/dev/root_probe.exeout/pe-env/Scripts/python.exe -B tests/form_coverage_check.pyform coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.pySelf-test passed. Checked 19 Markdown files and 493 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1809 tracked source, script and build/CI files: no bidirectional controls.(exit 0)main()return code): 14/14 killed.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:51:41Z.
Review: COMMENTED
Review of head
2bd359dc(comment only).Code:
tools/resource_inventory.pylooks correct.main()returns 0, and every new guard exits 1 with a one-line message. Thelayout*.xmlcount check still usesparser.error(exit 2)._write_atomic_jsonstages the report in a temp dir next to the output, so a failed write leaves the old report and no temp files. No other open or merged PR covers this slice (#644 only added the single-layout check).Test:
tests/resource_inventory_cli_check.py(7 tests) is registered in CTest aspe_resource_inventory_cli_check. It checks the real CLI result and the exit codes.Commands run on this head:
python3 tests/resource_inventory_cli_check.py-> 7 tests OKpython3 tests/layout_chunks_check.py-> okpython3 tests/docs_links_check.py-> okpython3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> cleanos.replacewith a raise -> 2 failuresroot.is_dir()guard -> 1 failureread_layoutexcept clause -> 4 errorsNo blocking findings. This does not claim any startup change. Windows runs follow separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:02:25Z.
Win2025 WARP receipt for head
cb0e5577after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
cb0e5577fe037a5f2dd9df4c1d791280f126d514:--preset dev):cmake --build --preset dev -- -j 2):150.91s(configure2.69s)ctest --preset dev -R 'resource_inventory' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.88s:pe_resource_inventory_cli_check1.70s)/O2(--preset release):cmake --build --preset release -- -j 2):192.80s(configure3.28s)ctest --preset release -R 'resource_inventory' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.85s:pe_resource_inventory_cli_check1.64s)tests/dxcontainer_part_offsets_check.pyok (0.4s),tests/dxil_retarget_check.pyok (0.7s),tests/layout_chunks_check.pyok (0.8s)sccache: 30/1550 hits; wall360.9sAI-assisted; commands listed were executed locally.