runtime: extract main(argv) and add path/key/timeout guards in mesh86_cache with CLI suite #2576

Merged
Ammmae0x merged 1 commit from upstream-pr/2584 into main 2026-11-25 22:10:11 +00:00
Ammmae0x commented 2026-11-25 21:56:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T21:56:01Z.


Summary

Extracts a testable main(argv=None) -> int entrypoint in tools/startup/mesh86_cache.py, validates 64-bit request keys and cache/shader/DXC paths upfront, bounds dxc -dumpbin invocations with timeout=30, and expands CLI error handling to catch all subprocess.SubprocessError failures without raw tracebacks, backed by a standalone pure-Python CLI test suite registered in CTest.

Changes

  • tools/startup/mesh86_cache.py:
    • Extract main(argv=None) -> int returning 0 and invoke raise SystemExit(main()) under __main__.
    • Validate 0 <= args.key < (1 << 64), verify args.cache is an existing directory, and add _require_file() checks for --mesh, --pixel, and --prove-root-srv so missing paths and directories fail cleanly before publish().
    • Add timeout=30 to subprocess.run() in publish() when proving the mesh root SRV profile, and expand the main() exception handler to (ValueError, OSError, struct.error, subprocess.SubprocessError) exiting cleanly with code 1 and zero raw tracebacks while preserving load_request(), publish(), prove_mesh_root_srv(), and atomic marker/stage publishing.
  • tests/startup_mesh86_cache_cli_check.py:
    • Add standalone pure-Python CLI, 64-bit key boundary, path guard, timeout=30 / SubprocessError / struct.error, and atomic artifact-preservation tests.
  • CMakeLists.txt:
    • Register runtime_mesh86_cache_cli_check in CTest right after startup_mesh86_srv_proof.

Verification

All commands executed after rebasing onto upstream/main (fc97ade7):

  • out/pe-env/Scripts/python.exe -B tests/startup_mesh86_cache_cli_check.py -v
    • Observed: Ran 4 tests in 1.760s / OK (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/startup_mesh86_srv_proof_check.py <dxc.exe> out/build/dev
    • Observed: accepted one DWORD load and rejected two loads from the same SRV handle and verified one DWORD at t0 space0 and refused PS access, shifted, dynamic, wide and wrong-space loads (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/startup_indirect_mesh_cache_check.py <dxc.exe> out/build/dev/startup_indirect_draw_indexed.exe warp
    • Observed: mesh cache padding replay reused the PSO; sample-mask change generated a new key (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/startup_tools_lint_check.py
    • Observed: PASS: 11 files under tools/startup parse; control snippet rejected and valid snippet accepted (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py
    • Observed: form coverage checks passed (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/docs_links_check.py
    • Observed: Self-test passed. Checked 19 Markdown files and 495 links. (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py
    • Observed: Self-test passed. Checked 1815 tracked source, script and build/CI files: no bidirectional controls. (exit 0)
  • Minimal temp-copy mutation testing (13 adversarial mutations across timeout=30, 64-bit key lower/upper/off-by-one bounds, cache.is_dir(), _require_file for --mesh/--pixel/--prove-root-srv, --mesh-required guard, SubprocessError/struct.error catches, argv forwarding, and main() return code): 13/13 killed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6614553009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2584). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T21:56:01Z. --- ## Summary Extracts a testable `main(argv=None) -> int` entrypoint in `tools/startup/mesh86_cache.py`, validates 64-bit request keys and cache/shader/DXC paths upfront, bounds `dxc -dumpbin` invocations with `timeout=30`, and expands CLI error handling to catch all `subprocess.SubprocessError` failures without raw tracebacks, backed by a standalone pure-Python CLI test suite registered in CTest. ### Changes - **`tools/startup/mesh86_cache.py`**: - Extract `main(argv=None) -> int` returning `0` and invoke `raise SystemExit(main())` under `__main__`. - Validate `0 <= args.key < (1 << 64)`, verify `args.cache` is an existing directory, and add `_require_file()` checks for `--mesh`, `--pixel`, and `--prove-root-srv` so missing paths and directories fail cleanly before `publish()`. - Add `timeout=30` to `subprocess.run()` in `publish()` when proving the mesh root SRV profile, and expand the `main()` exception handler to `(ValueError, OSError, struct.error, subprocess.SubprocessError)` exiting cleanly with code `1` and zero raw tracebacks while preserving `load_request()`, `publish()`, `prove_mesh_root_srv()`, and atomic marker/stage publishing. - **`tests/startup_mesh86_cache_cli_check.py`**: - Add standalone pure-Python CLI, 64-bit key boundary, path guard, `timeout=30` / `SubprocessError` / `struct.error`, and atomic artifact-preservation tests. - **`CMakeLists.txt`**: - Register `runtime_mesh86_cache_cli_check` in CTest right after `startup_mesh86_srv_proof`. ## Verification All commands executed after rebasing onto `upstream/main` (`fc97ade7`): - `out/pe-env/Scripts/python.exe -B tests/startup_mesh86_cache_cli_check.py -v` - Observed: `Ran 4 tests in 1.760s` / `OK` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/startup_mesh86_srv_proof_check.py <dxc.exe> out/build/dev` - Observed: `accepted one DWORD load and rejected two loads from the same SRV handle` and `verified one DWORD at t0 space0 and refused PS access, shifted, dynamic, wide and wrong-space loads` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/startup_indirect_mesh_cache_check.py <dxc.exe> out/build/dev/startup_indirect_draw_indexed.exe warp` - Observed: `mesh cache padding replay reused the PSO; sample-mask change generated a new key` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/startup_tools_lint_check.py` - Observed: `PASS: 11 files under tools/startup parse; control snippet rejected and valid snippet accepted` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py` - Observed: `form coverage checks passed` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/docs_links_check.py` - Observed: `Self-test passed. Checked 19 Markdown files and 495 links.` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py` - Observed: `Self-test passed. Checked 1815 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) - Minimal temp-copy mutation testing (13 adversarial mutations across `timeout=30`, 64-bit key lower/upper/off-by-one bounds, `cache.is_dir()`, `_require_file` for `--mesh`/`--pixel`/`--prove-root-srv`, `--mesh`-required guard, `SubprocessError`/`struct.error` catches, `argv` forwarding, and `main()` return code): 13/13 killed. AI-assisted.
tedin7 commented 2026-11-25 22:02:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:01:37Z.

Review: COMMENTED


Review of head 8226d96c (comment only, no approval).

Checked:

  • main(argv=None) -> int extraction, 64-bit key range check, cache dir check, _require_file for --mesh/--pixel/--prove-root-srv: logic is correct; the is not None change also fixes the case of an empty-looking Path.
  • timeout=30 on the dxc -dumpbin call, and subprocess.SubprocessError now caught (TimeoutExpired is covered, CalledProcessError is a subclass).
  • New CTest runtime_mesh86_cache_cli_check sits next to the sibling startup_mesh86_srv_proof test inside the same INTAKE_PYTHON block. No other open or merged PR touches mesh86_cache CLI.
  • Scope is tooling only, no startup claim.

Commands run locally:

  • python3 -B tests/startup_mesh86_cache_cli_check.py: 4 tests OK
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean
  • Mutation 1, remove timeout=30: test fails
  • Mutation 2, widen key range to 70 bits: 3 failures
  • Mutation 3, catch only CalledProcessError: test errors

Result: sound. Win2025 run is next.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065591794 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2584#pullrequestreview-6065591794). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T22:01:37Z. **Review:** COMMENTED --- Review of head 8226d96c (comment only, no approval). Checked: - `main(argv=None) -> int` extraction, 64-bit key range check, cache dir check, `_require_file` for `--mesh/--pixel/--prove-root-srv`: logic is correct; the `is not None` change also fixes the case of an empty-looking Path. - `timeout=30` on the dxc `-dumpbin` call, and `subprocess.SubprocessError` now caught (TimeoutExpired is covered, CalledProcessError is a subclass). - New CTest `runtime_mesh86_cache_cli_check` sits next to the sibling `startup_mesh86_srv_proof` test inside the same `INTAKE_PYTHON` block. No other open or merged PR touches mesh86_cache CLI. - Scope is tooling only, no startup claim. Commands run locally: - `python3 -B tests/startup_mesh86_cache_cli_check.py`: 4 tests OK - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean - Mutation 1, remove `timeout=30`: test fails - Mutation 2, widen key range to 70 bits: 3 failures - Mutation 3, catch only `CalledProcessError`: test errors Result: sound. Win2025 run is next. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 23:01:54 +00:00
tedin7 commented 2026-11-25 23:02:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:10:00Z.


Win2025 WARP receipt for head 8226d96c.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 8226d96c37be5627937a3a490d40d87eabc27e1a:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 156.44s (configure 3.08s)
    • Test (ctest --preset dev -R 'mesh86' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (1.83s: startup_mesh86_srv_proof 0.97s, runtime_mesh86_cache_cli_check 1.62s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 282.59s (configure 3.25s)
    • Test (ctest --preset release -R 'mesh86' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (2.14s: startup_mesh86_srv_proof 1.15s, runtime_mesh86_cache_cli_check 1.87s)
  • sccache: 40/1265 hits; wall 454.7s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176019648 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2584#issuecomment-7176019648). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T22:10:00Z. --- Win2025 WARP receipt for head 8226d96c. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `8226d96c37be5627937a3a490d40d87eabc27e1a`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `156.44s` (configure `3.08s`) - Test (`ctest --preset dev -R 'mesh86' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`1.83s`: `startup_mesh86_srv_proof` `0.97s`, `runtime_mesh86_cache_cli_check` `1.62s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `282.59s` (configure `3.25s`) - Test (`ctest --preset release -R 'mesh86' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`2.14s`: `startup_mesh86_srv_proof` `1.15s`, `runtime_mesh86_cache_cli_check` `1.87s`) - `sccache`: 40/1265 hits; wall `454.7s` AI-assisted; commands listed were executed locally.
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!2576
No description provided.