shader: extract main(argv) and add manifest/pipelines schema and LLVM path guards in pso_readiness with CLI suite #2575

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

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


Summary

Extracts a testable main(argv=None) -> int entrypoint in tools/pso_readiness.py, hardens manifest/pipelines JSON schema validation in report(), and adds CLI path validation for manifest, pipelines, and --llvm, backed by a standalone pure-Python CLI test suite registered in CTest.

Changes

  • tools/pso_readiness.py:
    • Extract main(argv=None) -> int returning 0 and invoke raise SystemExit(main()) under __main__.
    • Validate top-level and item schemas in report(): require isinstance(manifest, dict), isinstance(manifest.get("shaders"), list), isinstance(record, dict) for shader entries, isinstance(pipelines, dict), and isinstance(pipelines.get("pipelines"), list), raising ValueError on malformed inputs.
    • Add _validate_cli_paths() in main() to reject existing directory paths for manifest and pipelines and require --llvm (when passed on CLI) to exist as a regular file, while preserving direct report(..., llvm="test-llvm") string acceptance and the exact PSO report: <exc>\n stderr prefix with exit status 1 (zero raw tracebacks).
  • tests/pso_readiness_cli_check.py:
    • Add standalone pure-Python CLI, schema guard, path validation, sys.argv/__main__ forwarding, error-handling, and mutation-killing tests.
  • CMakeLists.txt:
    • Register shader_pso_readiness_cli_check in CTest right after pso_readiness_check.

Verification

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

  • out/pe-env/Scripts/python.exe -B tests/pso_readiness_cli_check.py -v
    • Observed: Ran 7 tests in 1.232s / OK (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/pso_readiness_check.py
    • Observed: PSO mesh probe passed (1 lowered, 2 lowering rejections, 2 disassembly failures), PSO compute probe passed (1 recognized, 1 unsupported opcode, 2 disassembly failures, 1 scan failure), PSO input validation passed (15 rejected inputs, 2 CLI exits, 1 valid control), PSO census, evidence states, and native hash control passed (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 (15 adversarial mutations across manifest/pipelines/item schema guards, directory/--llvm path guards, argv forwarding, return code, __main__ SystemExit, and all 4 caught exception classes): 15/15 killed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6614544296 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2583). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T21:55:29Z. --- ## Summary Extracts a testable `main(argv=None) -> int` entrypoint in `tools/pso_readiness.py`, hardens manifest/pipelines JSON schema validation in `report()`, and adds CLI path validation for `manifest`, `pipelines`, and `--llvm`, backed by a standalone pure-Python CLI test suite registered in CTest. ### Changes - **`tools/pso_readiness.py`**: - Extract `main(argv=None) -> int` returning `0` and invoke `raise SystemExit(main())` under `__main__`. - Validate top-level and item schemas in `report()`: require `isinstance(manifest, dict)`, `isinstance(manifest.get("shaders"), list)`, `isinstance(record, dict)` for shader entries, `isinstance(pipelines, dict)`, and `isinstance(pipelines.get("pipelines"), list)`, raising `ValueError` on malformed inputs. - Add `_validate_cli_paths()` in `main()` to reject existing directory paths for `manifest` and `pipelines` and require `--llvm` (when passed on CLI) to exist as a regular file, while preserving direct `report(..., llvm="test-llvm")` string acceptance and the exact `PSO report: <exc>\n` stderr prefix with exit status `1` (zero raw tracebacks). - **`tests/pso_readiness_cli_check.py`**: - Add standalone pure-Python CLI, schema guard, path validation, `sys.argv`/`__main__` forwarding, error-handling, and mutation-killing tests. - **`CMakeLists.txt`**: - Register `shader_pso_readiness_cli_check` in CTest right after `pso_readiness_check`. ## Verification All commands executed after rebasing onto `upstream/main` (`fc97ade7`): - `out/pe-env/Scripts/python.exe -B tests/pso_readiness_cli_check.py -v` - Observed: `Ran 7 tests in 1.232s` / `OK` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/pso_readiness_check.py` - Observed: `PSO mesh probe passed (1 lowered, 2 lowering rejections, 2 disassembly failures)`, `PSO compute probe passed (1 recognized, 1 unsupported opcode, 2 disassembly failures, 1 scan failure)`, `PSO input validation passed (15 rejected inputs, 2 CLI exits, 1 valid control)`, `PSO census, evidence states, and native hash control passed` (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 (15 adversarial mutations across manifest/pipelines/item schema guards, directory/`--llvm` path guards, `argv` forwarding, return code, `__main__` `SystemExit`, and all 4 caught exception classes): 15/15 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-25T21:56:35Z.

Review: COMMENTED


Review of head e94e82fc (0 commits behind main). Verdict: sound, no blocking findings.

Checked:

  • main(argv=None) -> int and _validate_cli_paths() keep the PSO report: <exc> stderr prefix and exit 1; report() schema guards raise ValueError instead of raw tracebacks.
  • shader_pso_readiness_cli_check is registered in CTest next to pso_readiness_check.
  • The new test guards the behavior. Mutations of the code under test make it fail:
    • Removing the shader-entry isinstance(record, dict) guard: 1 failure + 1 error.
    • Removing the --llvm path check: 1 error.

Commands run (Linux):

  • python3 -B tests/pso_readiness_cli_check.py -> Ran 7 tests, OK
  • python3 -B tests/pso_readiness_check.py -> passed
  • python3 tests/docs_links_check.py -> 19 files, 495 links ok
  • python3 tests/bidi_controls_check.py -> no bidi controls
  • git diff --check origin/main...HEAD -> clean

Not verified here: Windows run and required CI were still pending at review time.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065536003 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2583#pullrequestreview-6065536003). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:56:35Z. **Review:** COMMENTED --- Review of head e94e82fc (0 commits behind main). Verdict: sound, no blocking findings. Checked: - `main(argv=None) -> int` and `_validate_cli_paths()` keep the `PSO report: <exc>` stderr prefix and exit 1; `report()` schema guards raise ValueError instead of raw tracebacks. - `shader_pso_readiness_cli_check` is registered in CTest next to `pso_readiness_check`. - The new test guards the behavior. Mutations of the code under test make it fail: - Removing the shader-entry `isinstance(record, dict)` guard: 1 failure + 1 error. - Removing the `--llvm` path check: 1 error. Commands run (Linux): - `python3 -B tests/pso_readiness_cli_check.py` -> Ran 7 tests, OK - `python3 -B tests/pso_readiness_check.py` -> passed - `python3 tests/docs_links_check.py` -> 19 files, 495 links ok - `python3 tests/bidi_controls_check.py` -> no bidi controls - `git diff --check origin/main...HEAD` -> clean Not verified here: Windows run and required CI were still pending at review time. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 23:01:53 +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!2575
No description provided.