buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity #1634

Merged
leonida/mandy
quietfold merged 1 commit from fix/buffer-swizzle-probe-json-and-cli into main 2026-11-28 11:43:01 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 06:36:13 +00:00

Item ID: BUFFER-SWIZZLE-PROBE-JSON-AND-CLI
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154914906

Summary

Harden CLI validation, JSON report writing, and result classification in tools/buffer_swizzle_probe.py:

  • Upfront --json validation (validate_json_path): reject empty/whitespace paths, directories, trailing path separators, non-directory parent blockers, and unwritable existing files with exit 2 before running translator or GPU sweeps (previously --json "" was silently ignored, --json " " created a literal whitespace file, and directory/parent failures only errored after running all sweeps).
  • Atomic JSON writes (write_json_report): serialize upfront with allow_nan=False and LF endings, handle non-regular targets like /dev/null directly, preserve symlink targets by resolving links before staging, apply file_mode.published_mode, and publish via replace_retry.replace.
  • CLI & classification guards: reject empty/whitespace --group and --hw-arch upfront (exit 2), deduplicate unknown group diagnostics, check string harness ERRORs before wave comparisons so a compile failure in one wave reports ERROR instead of WAVE_DIFF, and enforce wave32/64 parity (WAVE_DIFF / WAVE_SAME) in --oracle translator mode as well as hardware mode.
  • Tests (tests/test_buffer_swizzle_probe.py): added 4 test methods covering upfront --json validation, atomic/symlink/NaN//dev/null writes, empty --group/--hw-arch, translator wave parity, and error precedence.

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU unit tests + translator self-test on macOS; no GPU or game data present)
  • python3 -W error -I tests/test_buffer_swizzle_probe.py -v: 12/12 passed
  • Mutation check against unpatched main: ran=12 failures=3 errors=7
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/buffer_swizzle_probe.py tests/test_buffer_swizzle_probe.py: passed
  • python3 -m compileall -q tools/buffer_swizzle_probe.py tests/test_buffer_swizzle_probe.py: passed
Item ID: `BUFFER-SWIZZLE-PROBE-JSON-AND-CLI` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154914906 ### Summary Harden CLI validation, JSON report writing, and result classification in `tools/buffer_swizzle_probe.py`: - **Upfront `--json` validation (`validate_json_path`)**: reject empty/whitespace paths, directories, trailing path separators, non-directory parent blockers, and unwritable existing files with exit `2` *before* running translator or GPU sweeps (previously `--json ""` was silently ignored, `--json " "` created a literal whitespace file, and directory/parent failures only errored after running all sweeps). - **Atomic JSON writes (`write_json_report`)**: serialize upfront with `allow_nan=False` and LF endings, handle non-regular targets like `/dev/null` directly, preserve symlink targets by resolving links before staging, apply `file_mode.published_mode`, and publish via `replace_retry.replace`. - **CLI & classification guards**: reject empty/whitespace `--group` and `--hw-arch` upfront (exit `2`), deduplicate unknown group diagnostics, check string harness `ERROR`s before wave comparisons so a compile failure in one wave reports `ERROR` instead of `WAVE_DIFF`, and enforce wave32/64 parity (`WAVE_DIFF` / `WAVE_SAME`) in `--oracle translator` mode as well as hardware mode. - **Tests (`tests/test_buffer_swizzle_probe.py`)**: added 4 test methods covering upfront `--json` validation, atomic/symlink/NaN/`/dev/null` writes, empty `--group`/`--hw-arch`, translator wave parity, and error precedence. ### Verification - AI-assisted: yes - GPUs tested: none (CPU unit tests + translator self-test on macOS; no GPU or game data present) - `python3 -W error -I tests/test_buffer_swizzle_probe.py -v`: 12/12 passed - Mutation check against unpatched `main`: `ran=12 failures=3 errors=7` - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed - `python3 -I scripts/check_no_game_data.py tools/buffer_swizzle_probe.py tests/test_buffer_swizzle_probe.py`: passed - `python3 -m compileall -q tools/buffer_swizzle_probe.py tests/test_buffer_swizzle_probe.py`: passed
copilot-pull-request-reviewer[bot] reviewed 2026-11-25 06:36:24 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
GeorgiyDemo commented 2026-11-25 06:50:23 +00:00

Tested deae588bc on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 42537e7b6 (Python GPU probe; hardware oracle not run):

  • pytest 9.2.0 on tests/test_buffer_swizzle_probe.py: 12 passed, 10 subtests passed at this head.
  • The same file on main: 10 failed, 10 passed, 2 subtests — the upfront --json validation, CLI guards, translator wave parity and atomic-report handling are not there.
  • Not run: the hardware oracle on a real AMD GPU; only the unit tests.

AI-assisted; synthetic fixtures only, no game data.

Tested `deae588bc` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `42537e7b6` (Python GPU probe; hardware oracle not run): - pytest 9.2.0 on `tests/test_buffer_swizzle_probe.py`: **12 passed, 10 subtests passed** at this head. - The same file on `main`: **10 failed**, 10 passed, 2 subtests — the upfront `--json` validation, CLI guards, translator wave parity and atomic-report handling are not there. - Not run: the hardware oracle on a real AMD GPU; only the unit tests. AI-assisted; synthetic fixtures only, no game data.
whoalin1 commented 2026-11-25 10:01:25 +00:00

Independent verification (Windows, Python 3.11.9 -I -W error): upfront --json validation rejects bad paths pre-oracle (live-probed), atomic write via mkstemp+published_mode+replace_retry symlink-aware, CLI guards, and the "translator wave parity" claim is real — run_translator per-wave dicts get WAVE_DIFF/WAVE_SAME when hw waves absent, string harness errors take precedence, hw_ref picks the mismatched wave's result. test_buffer_swizzle_probe.py 12 OK; --self-test 22 cases ok; live --oracle translator run produced valid LF JSON; bad-CLI all exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

Independent verification (Windows, Python 3.11.9 `-I -W error`): upfront `--json` validation rejects bad paths pre-oracle (live-probed), atomic write via mkstemp+published_mode+replace_retry symlink-aware, CLI guards, and the "translator wave parity" claim is real — `run_translator` per-wave dicts get WAVE_DIFF/WAVE_SAME when hw waves absent, string harness errors take precedence, `hw_ref` picks the mismatched wave's result. `test_buffer_swizzle_probe.py` 12 OK; `--self-test` 22 cases ok; live `--oracle translator` run produced valid LF JSON; bad-CLI all exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
sodove commented 2026-11-28 11:26:56 +00:00

#1634 | head deae588bccf900026bbd7da5678eecf92c682eb0 | python3 -I tests/test_buffer_swizzle_probe.py -v | red: 12 run, 3 failures, 7 errors | green: 12 passed | Red → green

The suite reproduced validation and output/report handling failures on main, then passed all 12 tests, including the translator wave-parity case.

Copied the PR tests onto clean main 4a54aedcb6b66525e0c9f72a6ea10263337c9141 for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.

#1634 | head `deae588bccf900026bbd7da5678eecf92c682eb0` | `python3 -I tests/test_buffer_swizzle_probe.py -v` | red: 12 run, 3 failures, 7 errors | green: 12 passed | **Red → green** The suite reproduced validation and output/report handling failures on main, then passed all 12 tests, including the translator wave-parity case. Copied the PR tests onto clean main `4a54aedcb6b66525e0c9f72a6ea10263337c9141` for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238450840).
DadaCap commented 2026-11-28 11:43:03 +00:00

Merged, thank you @IlyassRS3! This PR (buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Merged, thank you @IlyassRS3! This PR (buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No description provided.