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

Open
github-bot wants to merge 1 commit from github-bot/gh-1634 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 06:36 UTC · original
IlyassRS3:fix/buffer-swizzle-probe-json-and-cli → main · +221 −19 · 2 files · 1 commits · open

Item ID: BUFFER-SWIZZLE-PROBE-JSON-AND-CLI
Claim: #1608

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
**@⁠IlyassRS3** on GitHub · 2026-11-25 06:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1634) `IlyassRS3:fix/buffer-swizzle-probe-json-and-cli` → `main` · +221 −19 · 2 files · 1 commits · open Item ID: `BUFFER-SWIZZLE-PROBE-JSON-AND-CLI` Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:55 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 06:36 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 06:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1634#pullrequestreview-6052935238) · **reviewed** 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.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 06:50 UTC · original

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.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 06:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1634#issuecomment-7155212230) 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.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 10:01 UTC · original

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.

**@⁠whoalin1** on GitHub · 2026-11-25 10:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1634#issuecomment-7159118272) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1634/head:github-bot/gh-1634'
git switch 'github-bot/gh-1634'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1634'
git switch 'github-bot/gh-1634'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1634'
git switch 'github-bot/gh-1634'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1634'
git switch 'main'
git merge --squash 'github-bot/gh-1634'
git switch 'main'
git merge --ff-only 'github-bot/gh-1634'
git switch 'main'
git merge 'github-bot/gh-1634'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.