[PR #1634] buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity #1648

Open
opened 2026-11-26 20:21:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1634
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/buffer-swizzle-probe-json-and-cli


📝 Commits (1)

  • deae588 buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity

📊 Changes

2 files changed (+221 additions, -19 deletions)

View changed files

📝 tests/test_buffer_swizzle_probe.py (+102 -0)
📝 tools/buffer_swizzle_probe.py (+119 -19)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1634 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/buffer-swizzle-probe-json-and-cli` --- ### 📝 Commits (1) - [`deae588`](https://github.com/ubiquitarianism/leonida/commit/deae588bccf900026bbd7da5678eecf92c682eb0) buffer_swizzle_probe: upfront atomic JSON validation, CLI guards, and translator wave parity ### 📊 Changes **2 files changed** (+221 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_buffer_swizzle_probe.py` (+102 -0) 📝 `tools/buffer_swizzle_probe.py` (+119 -19) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1648
No description provided.