runtime: pin commit headroom rounding and request cap in host_commit_check #1817

Merged
Asimmimx merged 1 commit from upstream-pr/1824 into main 2026-11-24 19:25:43 +00:00
Asimmimx commented 2026-11-24 19:18:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:18:04Z.


Change

tests/host_commit_check.py did not pin two behaviors of tools/host_commit.py:

  • snapshot_from_pages computes available_mib from the free bytes, so a partial
    MiB of headroom floors to the real value. Every existing case had MiB-aligned
    limit and use, or floored both sides to the same answer, so reporting
    limit_mib - used_mib instead (which can overstate headroom by up to 1 MiB) was
    not detected.
  • require_commit_budget accepts requests up to and including 1048576 MiB. The
    existing invalid request (1 << 20) | 1 used a 3 MiB snapshot, so it was refused
    by the headroom check even when the range check was moved or made exclusive.

Mutation probe (single-point edits to tools/host_commit.py, reverted after each run):

Mutant Existing check With the new cases
available_mib = limit_bytes // MIB - used_bytes // MIB survived killed
range check minimum_mib >= 1 << 20 survived killed
range check minimum_mib > 1 << 21 survived killed
budget check < -> <= killed killed
drop the page_size guard killed killed
drop the limit_pages guard killed killed
max(limit - used, 0) -> abs(limit - used) killed killed
negative bound < 0 -> < -1 killed killed
CommitLimit -> CommitPeak killed killed
drop the isinstance(..., int) test killed killed
used_mib rounded up killed killed
report available_mib as minimum_mib killed killed
compare available_mib < minimum_mib instead of bytes survived survived (equivalent: for an integer request, floor(b / MiB) < m iff b < m * MiB)

The new cases read:

  • 384 and 192 pages of 4 KiB (1.5 MiB limit, 0.75 MiB used) give
    limit_mib=1, used_mib=0, available_mib=0, available_bytes=786432, and a 1 MiB
    request is refused with "headroom 0 MiB is below the requested 1 MiB".
  • With a snapshot of (1 << 20) + 1 MiB headroom, a 1048576 MiB request is
    accepted and a 1048577 MiB request is refused by the range check ("between 0 and
    1048576"), not by the headroom check.

Verification

Based on origin/main 813045b3. Windows 11 Pro 26300.9974, Python 3.12.10.

python -B tests/host_commit_check.py
Ran 7 tests in 0.025s
OK

python -B tests/docs_links_check.py
Checked 18 Markdown files and 369 links.

python -B tests/bidi_controls_check.py
Checked 1320 tracked source, script and build/CI files: no bidirectional controls.

Each mutant in the table was applied alone and python -B tests/host_commit_check.py
re-run; "killed" means a non-zero exit.

Evidence and follow-up

No new fixture: the cases use synthetic page counts. The live PSAPI smoke test is
unchanged. pe_run_package.py also range-checks --min-commit-mib before calling
require_commit_budget; these cases pin the function's own check, which other
callers rely on.

The tool is not changed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589524764 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1824). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T19:18:04Z. --- ## Change `tests/host_commit_check.py` did not pin two behaviors of `tools/host_commit.py`: - `snapshot_from_pages` computes `available_mib` from the free bytes, so a partial MiB of headroom floors to the real value. Every existing case had MiB-aligned limit and use, or floored both sides to the same answer, so reporting `limit_mib - used_mib` instead (which can overstate headroom by up to 1 MiB) was not detected. - `require_commit_budget` accepts requests up to and including 1048576 MiB. The existing invalid request `(1 << 20) | 1` used a 3 MiB snapshot, so it was refused by the headroom check even when the range check was moved or made exclusive. Mutation probe (single-point edits to `tools/host_commit.py`, reverted after each run): | Mutant | Existing check | With the new cases | |---|---|---| | `available_mib = limit_bytes // MIB - used_bytes // MIB` | survived | killed | | range check `minimum_mib >= 1 << 20` | survived | killed | | range check `minimum_mib > 1 << 21` | survived | killed | | budget check `<` -> `<=` | killed | killed | | drop the `page_size` guard | killed | killed | | drop the `limit_pages` guard | killed | killed | | `max(limit - used, 0)` -> `abs(limit - used)` | killed | killed | | negative bound `< 0` -> `< -1` | killed | killed | | `CommitLimit` -> `CommitPeak` | killed | killed | | drop the `isinstance(..., int)` test | killed | killed | | `used_mib` rounded up | killed | killed | | report `available_mib` as `minimum_mib` | killed | killed | | compare `available_mib < minimum_mib` instead of bytes | survived | survived (equivalent: for an integer request, `floor(b / MiB) < m` iff `b < m * MiB`) | The new cases read: - 384 and 192 pages of 4 KiB (1.5 MiB limit, 0.75 MiB used) give `limit_mib=1, used_mib=0, available_mib=0, available_bytes=786432`, and a 1 MiB request is refused with "headroom 0 MiB is below the requested 1 MiB". - With a snapshot of `(1 << 20) + 1` MiB headroom, a 1048576 MiB request is accepted and a 1048577 MiB request is refused by the range check ("between 0 and 1048576"), not by the headroom check. ## Verification Based on origin/main 813045b3. Windows 11 Pro 26300.9974, Python 3.12.10. ``` python -B tests/host_commit_check.py Ran 7 tests in 0.025s OK python -B tests/docs_links_check.py Checked 18 Markdown files and 369 links. python -B tests/bidi_controls_check.py Checked 1320 tracked source, script and build/CI files: no bidirectional controls. ``` Each mutant in the table was applied alone and `python -B tests/host_commit_check.py` re-run; "killed" means a non-zero exit. ## Evidence and follow-up No new fixture: the cases use synthetic page counts. The live PSAPI smoke test is unchanged. `pe_run_package.py` also range-checks `--min-commit-mib` before calling `require_commit_budget`; these cases pin the function's own check, which other callers rely on. The tool is not changed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 20:00:48 +00:00
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
R0Y00/Xbox2Windows!1817
No description provided.