tooling: validate family names in expected_values and add unit and CLI suite #2043

Merged
Ammmae0x merged 2 commits from upstream-pr/2050 into main 2026-11-25 12:34:24 +00:00
Ammmae0x commented 2026-11-24 23:39:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T23:39:09Z.


Change

Validate family and size inputs in tools/mesh_od_pipeline.py, harden cleanup and error handling, and add a pure-Python unit and CLI test suite (tests/mesh_od_pipeline_check.py) registered in CMakeLists.txt (mesh_od_pipeline_check, TIMEOUT 30):

  • expected_values() rejects unknown family names (FAMILIES = ("control", "chain", "branches", "loops")), non-int/bool/negative size, and non-zero control sizes with ValueError instead of silently returning the unmodified seed.
  • variant_info() rejects non-str inputs with ValueError.
  • run_draw() moves process monitor thread stop/join and close_process(handle) cleanup into finally.
  • main() moves TemporaryDirectory / --work-dir setup inside try/finally and catches (RuntimeError, OSError) on measure() and OSError on write_report(), printing a concise error: ... message to stderr and exiting 1 without a raw Python traceback or leftover temporary directories.
  • tests/mesh_od_pipeline_check.py covers deterministic reference math, HLSL embedding, binary fixture layout, all classify_draw() outcomes, summarize(), CSV/JSON write_report(), --list-variants direct and subprocess CLI execution, mocked --check pass and capability-skip (exit 77) paths, plus negative controls for expected_values(), variant_info(), check_failures(), CLI flag validation (exit 2), and temp-directory cleanup on failure.

Verification

Tested on commit bf9bd9a9 (rebased on upstream/main 06cdc47d, Windows x64, Python via out/pe-env):

  1. .\out\pe-env\Scripts\python.exe -B tests/mesh_od_pipeline_check.py
    • Result: Ran 13 tests in 0.383s — OK (exit 0).
  2. .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
    • Result: form coverage checks passed (exit 0).
  3. .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
    • Result: Self-test passed. Checked 18 Markdown files and 391 links. (exit 0).
  4. .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
    • Result: Self-test passed. Checked 1404 tracked source, script and build/CI files: no bidirectional controls. (exit 0).

Note: No C++ targets were modified; mesh_od_pipeline_check is pure Python and registered once under if(adapter STREQUAL "hardware") next to mesh_od_pipeline_${adapter} in CMakeLists.txt.

Evidence and follow-up

  • All test cases in tests/mesh_od_pipeline_check.py are synthetic, self-contained, and run without external binaries or GPU hardware (the GPU/DXC end-to-end tests remain in mesh_od_pipeline_hardware / mesh_od_pipeline_warp).
  • Negative controls pin exact exception types (ValueError) and CLI exit codes (2 for argument errors, 1 for runtime/IO errors, 77 for capability skip), verify zero raw Python tracebacks, and confirm temporary directories are cleaned up on both success and failure.

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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593659818 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2050). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-24T23:39:09Z. --- ## Change Validate family and size inputs in `tools/mesh_od_pipeline.py`, harden cleanup and error handling, and add a pure-Python unit and CLI test suite (`tests/mesh_od_pipeline_check.py`) registered in `CMakeLists.txt` (`mesh_od_pipeline_check`, `TIMEOUT 30`): - `expected_values()` rejects unknown family names (`FAMILIES = ("control", "chain", "branches", "loops")`), non-int/bool/negative `size`, and non-zero `control` sizes with `ValueError` instead of silently returning the unmodified seed. - `variant_info()` rejects non-`str` inputs with `ValueError`. - `run_draw()` moves process monitor thread stop/join and `close_process(handle)` cleanup into `finally`. - `main()` moves `TemporaryDirectory` / `--work-dir` setup inside `try`/`finally` and catches `(RuntimeError, OSError)` on `measure()` and `OSError` on `write_report()`, printing a concise `error: ...` message to stderr and exiting `1` without a raw Python traceback or leftover temporary directories. - `tests/mesh_od_pipeline_check.py` covers deterministic reference math, HLSL embedding, binary fixture layout, all `classify_draw()` outcomes, `summarize()`, CSV/JSON `write_report()`, `--list-variants` direct and subprocess CLI execution, mocked `--check` pass and capability-skip (exit `77`) paths, plus negative controls for `expected_values()`, `variant_info()`, `check_failures()`, CLI flag validation (exit `2`), and temp-directory cleanup on failure. ## Verification Tested on commit `bf9bd9a9` (rebased on `upstream/main` `06cdc47d`, Windows x64, Python via `out/pe-env`): 1. `.\out\pe-env\Scripts\python.exe -B tests/mesh_od_pipeline_check.py` - Result: `Ran 13 tests in 0.383s` — `OK` (exit 0). 2. `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py` - Result: `form coverage checks passed` (exit 0). 3. `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py` - Result: `Self-test passed. Checked 18 Markdown files and 391 links.` (exit 0). 4. `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py` - Result: `Self-test passed. Checked 1404 tracked source, script and build/CI files: no bidirectional controls.` (exit 0). Note: No C++ targets were modified; `mesh_od_pipeline_check` is pure Python and registered once under `if(adapter STREQUAL "hardware")` next to `mesh_od_pipeline_${adapter}` in `CMakeLists.txt`. ## Evidence and follow-up - All test cases in `tests/mesh_od_pipeline_check.py` are synthetic, self-contained, and run without external binaries or GPU hardware (the GPU/DXC end-to-end tests remain in `mesh_od_pipeline_hardware` / `mesh_od_pipeline_warp`). - Negative controls pin exact exception types (`ValueError`) and CLI exit codes (`2` for argument errors, `1` for runtime/IO errors, `77` for capability skip), verify zero raw Python tracebacks, and confirm temporary directories are cleaned up on both success and failure. ## 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. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
ChazY11 commented 2026-11-25 01:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:49:26Z.


Ran it, broke the validator seven ways — all caught, including the two I expected to slip

out/pe-env/Scripts/python.exe -B tests/mesh_od_pipeline_check.py
Ran 13 tests in 0.622s
OK      exit 0
mutation in tools/mesh_od_pipeline.py result
family whitelist removed caught
isinstance(size, bool) term dropped (so True passes as 1) caught
size < 0 term dropped caught
the control requires size == 0 rule dropped caught
size > MAX_SIZE upper bound dropped caught
size < 1 lower bound dropped (allowing chain_0) caught
VARIANT_RE.fullmatch → match caught

The two I expected to survive were isinstance(size, bool) and the fullmatch change:

  • a boolean is an int in Python, so dropping the bool term makes chain_True behave as chain_1 — and there must be a fixture that passes True;
  • match instead of fullmatch accepts chain_64xyz, which is the classic validator hole, and it is also covered.

The validator, checked by hand against the table

expected_values refuses family outside FAMILIES, a non-int or negative size, a bool, and control with a non-zero size; variant_info adds
the 1..MAX_SIZE range, the string type check and the exact-match name. Reading the seven mutations against that list, every clause now has a test
that fails when it is deleted, which is the property that matters for a validator — the failure mode of a validator is silence, not a wrong answer.

The one thing I would add

variant_info computes expected and then formats it into the generated source. Nothing checks that the generated HLSL body corresponds to the
same family/size that produced expected: _body(family, size) and expected_values(family, size) are two independent implementations, which is
the right design, but a fixture that only calls variant_info cannot tell if _body was passed a different size. If one of the 13 tests compares the
emitted static const uint expected[3] table against expected_values for a range of sizes, ignore this — I could not tell from the run output.

What I did not run

The parts that need dxc and a renderer (measure, run_draw, classify_draw). Everything above is the pure-Python validation path, which is what
the PR changes.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147834240 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2050#issuecomment-7147834240). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T23:49:26Z. --- ## Ran it, broke the validator seven ways — all caught, including the two I expected to slip ```powershell out/pe-env/Scripts/python.exe -B tests/mesh_od_pipeline_check.py Ran 13 tests in 0.622s OK exit 0 ``` | mutation in `tools/mesh_od_pipeline.py` | result | |---|---| | `family` whitelist removed | **caught** | | `isinstance(size, bool)` term dropped (so `True` passes as 1) | **caught** | | `size < 0` term dropped | **caught** | | the `control` requires `size == 0` rule dropped | **caught** | | `size > MAX_SIZE` upper bound dropped | **caught** | | `size < 1` lower bound dropped (allowing `chain_0`) | **caught** | | `VARIANT_RE.fullmatch` → `match` | **caught** | The two I expected to survive were `isinstance(size, bool)` and the `fullmatch` change: - a boolean is an `int` in Python, so dropping the `bool` term makes `chain_True` behave as `chain_1` — and there must be a fixture that passes `True`; - `match` instead of `fullmatch` accepts `chain_64xyz`, which is the classic validator hole, and it is also covered. ## The validator, checked by hand against the table `expected_values` refuses `family` outside `FAMILIES`, a non-int or negative `size`, a `bool`, and `control` with a non-zero size; `variant_info` adds the `1..MAX_SIZE` range, the string type check and the exact-match name. Reading the seven mutations against that list, every clause now has a test that fails when it is deleted, which is the property that matters for a validator — the failure mode of a validator is *silence*, not a wrong answer. ## The one thing I would add `variant_info` computes `expected` and then formats it into the generated source. Nothing checks that the **generated HLSL body** corresponds to the same `family`/`size` that produced `expected`: `_body(family, size)` and `expected_values(family, size)` are two independent implementations, which is the right design, but a fixture that only calls `variant_info` cannot tell if `_body` was passed a different size. If one of the 13 tests compares the emitted `static const uint expected[3]` table against `expected_values` for a range of sizes, ignore this — I could not tell from the run output. ## What I did not run The parts that need `dxc` and a renderer (`measure`, `run_draw`, `classify_draw`). Everything above is the pure-Python validation path, which is what the PR changes. ## Notes - AI-assisted review.
Ammmae0x commented 2026-11-25 01:02:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T23:56:59Z.


Updated PR #2050 (commit 478e48cb) to address the review suggestion: added test_variant_info_hlsl_body_matches_expected_and_size in tests/mesh_od_pipeline_check.py, which parses every generated HLSL body line for control, chain_{1,4}, branches_{1,5}, and loops_{1,3}, checks exact step indices/count, and simulates the emitted HLSL body for threads 0..2 against expected_values(). Spot-checked by mutating _body(family, size) to _body(family, max(0, size - 1)) (all 6 non-control subtests failed; restored). Re-verified tests/mesh_od_pipeline_check.py (14 tests OK), ctest --preset dev and ctest --preset release -R '^mesh_od_pipeline_check$' (1/1 Passed in both), plus form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147971694 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2050#issuecomment-7147971694). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-24T23:56:59Z. --- Updated PR #2050 (commit `478e48cb`) to address the review suggestion: added `test_variant_info_hlsl_body_matches_expected_and_size` in `tests/mesh_od_pipeline_check.py`, which parses every generated HLSL body line for `control`, `chain_{1,4}`, `branches_{1,5}`, and `loops_{1,3}`, checks exact step indices/count, and simulates the emitted HLSL body for threads 0..2 against `expected_values()`. Spot-checked by mutating `_body(family, size)` to `_body(family, max(0, size - 1))` (all 6 non-control subtests failed; restored). Re-verified `tests/mesh_od_pipeline_check.py` (14 tests OK), `ctest --preset dev` and `ctest --preset release` `-R '^mesh_od_pipeline_check$'` (1/1 Passed in both), plus `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py`. AI-assisted.
tedin7 commented 2026-11-25 03:00:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:55Z.

Review: COMMENTED


Review of head 478e48cb3cc9081701f7c4f6d8c2a5e64413416b.

Scope: tools/mesh_od_pipeline.py input validation and cleanup hardening, new tests/mesh_od_pipeline_check.py, one CMake registration. No GPU/shader change, so no Windows GPU run was needed. CI on this head: Linux checks, gfx1013 fixtures and Windows build/test are green. The PR is mergeable. The title is neutral.

Commands run locally (Linux)

  • git diff --stat origin/main...HEAD: 3 files, +787/-21.
  • python3 tests/mesh_od_pipeline_check.py: Ran 14 tests, OK.
  • python3 tests/docs_links_check.py: 391 links OK.
  • python3 tests/bidi_controls_check.py: OK.
  • git diff --check origin/main...HEAD: clean.

Mutation checks (each reverted with git checkout -- .)

  • Disable the unknown-family check in expected_values(): 6 failures.
  • Drop the size < 0 rejection: 2 failures.
  • Narrow the main() except (RuntimeError, OSError) to KeyError: 1 error.

All three were caught.

Findings

  • P1: none.
  • P2: none.
  • nit (CMakeLists.txt, new add_test): the pure-Python suite is registered inside the per-adapter loop behind if(adapter STREQUAL "hardware"). It works and avoids a duplicate test name. It would be cleaner outside the loop, so the test does not look tied to an adapter.
  • nit (tools/mesh_od_pipeline.py, main()): except (RuntimeError, OSError) returns 1 for any such error, including a skip-worthy capability case. The mocked capability-skip (exit 77) test covers the intended path, so this is fine as is.

The validation is correct and the finally cleanup in run_draw() is sound. The tests guard real behavior.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050793219 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2050#pullrequestreview-6050793219). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:24:55Z. **Review:** COMMENTED --- Review of head `478e48cb3cc9081701f7c4f6d8c2a5e64413416b`. **Scope**: `tools/mesh_od_pipeline.py` input validation and cleanup hardening, new `tests/mesh_od_pipeline_check.py`, one CMake registration. No GPU/shader change, so no Windows GPU run was needed. CI on this head: Linux checks, gfx1013 fixtures and Windows build/test are green. The PR is mergeable. The title is neutral. **Commands run locally (Linux)** - `git diff --stat origin/main...HEAD`: 3 files, +787/-21. - `python3 tests/mesh_od_pipeline_check.py`: Ran 14 tests, OK. - `python3 tests/docs_links_check.py`: 391 links OK. - `python3 tests/bidi_controls_check.py`: OK. - `git diff --check origin/main...HEAD`: clean. **Mutation checks** (each reverted with `git checkout -- .`) - Disable the unknown-family check in `expected_values()`: 6 failures. - Drop the `size < 0` rejection: 2 failures. - Narrow the `main()` `except (RuntimeError, OSError)` to `KeyError`: 1 error. All three were caught. **Findings** - P1: none. - P2: none. - nit (`CMakeLists.txt`, new `add_test`): the pure-Python suite is registered inside the per-adapter loop behind `if(adapter STREQUAL "hardware")`. It works and avoids a duplicate test name. It would be cleaner outside the loop, so the test does not look tied to an adapter. - nit (`tools/mesh_od_pipeline.py`, `main()`): `except (RuntimeError, OSError)` returns 1 for any such error, including a skip-worthy capability case. The mocked capability-skip (exit 77) test covers the intended path, so this is fine as is. The validation is correct and the `finally` cleanup in `run_draw()` is sound. The tests guard real behavior. AI-assisted; commands listed were executed locally.
stan495 commented 2026-11-25 06:01:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:42:14Z.

Review: APPROVED


Verified head 478e48cb on Windows x64 (dev preset, MSVC 19.44.35228.0, Python 3.12).

  • ctest --preset dev --no-tests=error -R '^mesh_od_pipeline_check$' -V -> 1/1 passed (Ran 14 tests in 0.231s, OK)

Verdict: Approved at 478e48cb.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052425733 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2050#pullrequestreview-6052425733). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T05:42:14Z. **Review:** APPROVED --- Verified head `478e48cb` on Windows x64 (`dev` preset, MSVC `19.44.35228.0`, Python 3.12). - `ctest --preset dev --no-tests=error -R '^mesh_od_pipeline_check$' -V` -> 1/1 passed (`Ran 14 tests in 0.231s`, `OK`) Verdict: Approved at `478e48cb`.
upstream-sync closed this pull request 2026-11-25 13:00:30 +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!2043
No description provided.