runtime: harden bool/integer and page bounds in host_commit with pure-Python unit suite #2885
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2885
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2885"
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?
@Ammmae0x on GitHub · 2026-11-26 16:23 UTC · original
Ammmae0x:runtime/host-commit-check→main· +266 −4 · 3 files · 1 commits · merged 2026-11-27 03:15 UTCChange
Harden boolean, integer, and snapshot-schema bounds validation in
tools/host_commit.pyand add a pure-Python unit, mocked WinAPI, and temp-copy mutation test suite (tests/host_commit_unit_check.py, registered viatests/cmake/runtime_host_commit_unit.cmake).booland non-intinputs withValueErrorinsnapshot_from_pages()(page_size > 0,limit_pages > 0,used_pages >= 0) andrequire_commit_budget()(0 <= minimum_mib <= 1 << 20).snapshotinrequire_commit_budget()is aMappingcontaining non-negative non-bool integer fields (available_bytes,limit_mib,used_mib,available_mib).free_bytes = max(limit_bytes - used_bytes, 0)whenused_pages > limit_pages) and System32-onlyWinDLL("psapi.dll", winmode=0x800, use_last_error=True).Verification
Commit:
b0fc3111(Windows 11 x64,out\pe-env\Scripts\python.exe -B):out\pe-env\Scripts\python.exe -B tests\host_commit_unit_check.py -v-> 2/2 tests OK (exact MiB math, clamping, bool/non-int/negative/zero refusals, budget boundaries, snapshot Mapping/field checks, mockedread_host_commitsuccess/GetPerformanceInfo==0/non-win32OSError, and 6 temp-copy mutations).out\pe-env\Scripts\python.exe -B tests\host_commit_check.py-> 7/7 tests OK.out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py-> passed (exit 0).out\pe-env\Scripts\python.exe -B tests\docs_links_check.py-> passed (29 Markdown files, 545 links, exit 0).out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py-> passed (2048 files, exit 0).boolcheck in_is_int, disabling theMappingcheck inrequire_commit_budget, and droppingmax(..., 0)clamping insnapshot_from_pagesone-by-one each causedtests\host_commit_unit_check.pyto fail (exit 1).Evidence and follow-up
All tests use synthetic page counts and mocked
psapi.dll/GetPerformanceInfocalls; zero external or game files are used.Checklist
AI-assisted.
@KelboLive on GitHub · 2026-11-27 02:14 UTC · original · reviewed
Hardening commit budget validation is a smart addition. The new _is_int() helper correctly excludes bool (a common Python gotcha since bool is a subclass of int), and it's used consistently across snapshot_from_pages() and require_commit_budget().
Key improvements:
The bool exclusion (_is_int) is the most critical: without it, True (==1) or False (==0) would silently pass numeric checks, potentially allowing a budget of 0 MiB or a true budget to be treated as 1 MiB.
The test cases are thorough — every edge case (None, bool, float, str, negative, zero, >1MiB caps) is covered. No concerns.
@R0Y00 on GitHub · 2026-11-27 03:14 UTC · original · approved these changes
Reviewed the exact head
b0fc3111da330da0634dbbd18647894c41b24ffc. Checked the package-launch caller and theGetPerformanceInfoconversion. The page arithmetic still floors available bytes at zero, and the budget check rejects booleans and malformed snapshots. I ranpython -B tests/host_commit_unit_check.pyagainst the exact-head module in isolation; both tests passed, including mocked API and mutation checks. Verified that main includes the test fragment and the required Windows check passed.