[PR #1644] frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, and result count guard #1658

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

📋 Pull Request Information

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

Base: main ← Head: fix/frexp-ldexp-f16-mods-probe-json-and-cli


📝 Commits (1)

  • 7e2c52a frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, and result count guard

📊 Changes

2 files changed (+211 additions, -16 deletions)

View changed files

📝 tests/test_frexp_ldexp_f16_mods_probe.py (+74 -0)
📝 tools/frexp_ldexp_f16_mods_probe.py (+137 -16)

📄 Description

Item ID: FREXP-LDEXP-F16-MODS-PROBE-JSON-AND-CLI
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155228780

Summary

Harden CLI argument parsing, JSON report writing, and harness error handling in tools/frexp_ldexp_f16_mods_probe.py:

  • --ops / --waves / --hw-arch guards: reject empty/trailing comma tokens (32,, ,v_frexp_mant_f16, 32,,64) while preserving whitespace-trimmed first-seen deduplication, and reject empty/whitespace --hw-arch.
  • Upfront --json validation: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets before opening hw_oracle.
  • Atomic write_report(): serialize upfront with allow_nan=False and LF endings, handle non-regular targets like /dev/null directly, resolve symlinks before staging to preserve symlink targets, apply file_mode.published_mode, and publish via replace_retry.replace.
  • Harness guards: return a harness_errors entry when len(raw_results) != len(meta) in evaluate_results() (preventing KeyError after zip() truncation), and catch ValueError from asm.family(oracle.arch) cleanly (exit 77).
  • Tests (tests/test_frexp_ldexp_f16_mods_probe.py): added 3 test methods covering malformed comma tokens, empty --hw-arch/--json, upfront blocker/trailing-sep rejection, atomic/symlink/NaN//dev/null writes, result count mismatch, and unknown arch family.

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present)
  • python3 -W error -I tests/test_frexp_ldexp_f16_mods_probe.py -v: 21 passed, 1 skipped (AMD clang absent)
  • Mutation check against unpatched main: ran=22 failures=0 errors=11 (skipped=1)
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py: passed
  • python3 -m compileall -q tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_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/1644 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/frexp-ldexp-f16-mods-probe-json-and-cli` --- ### 📝 Commits (1) - [`7e2c52a`](https://github.com/ubiquitarianism/leonida/commit/7e2c52a9ccc2a4752560acb4251369a06baec76f) frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, and result count guard ### 📊 Changes **2 files changed** (+211 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_frexp_ldexp_f16_mods_probe.py` (+74 -0) 📝 `tools/frexp_ldexp_f16_mods_probe.py` (+137 -16) </details> ### 📄 Description Item ID: `FREXP-LDEXP-F16-MODS-PROBE-JSON-AND-CLI` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155228780 ### Summary Harden CLI argument parsing, JSON report writing, and harness error handling in `tools/frexp_ldexp_f16_mods_probe.py`: - **`--ops` / `--waves` / `--hw-arch` guards**: reject empty/trailing comma tokens (`32,`, `,v_frexp_mant_f16`, `32,,64`) while preserving whitespace-trimmed first-seen deduplication, and reject empty/whitespace `--hw-arch`. - **Upfront `--json` validation**: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets *before* opening `hw_oracle`. - **Atomic `write_report()`**: serialize upfront with `allow_nan=False` and LF endings, handle non-regular targets like `/dev/null` directly, resolve symlinks before staging to preserve symlink targets, apply `file_mode.published_mode`, and publish via `replace_retry.replace`. - **Harness guards**: return a `harness_errors` entry when `len(raw_results) != len(meta)` in `evaluate_results()` (preventing `KeyError` after `zip()` truncation), and catch `ValueError` from `asm.family(oracle.arch)` cleanly (exit `77`). - **Tests (`tests/test_frexp_ldexp_f16_mods_probe.py`)**: added 3 test methods covering malformed comma tokens, empty `--hw-arch`/`--json`, upfront blocker/trailing-sep rejection, atomic/symlink/NaN/`/dev/null` writes, result count mismatch, and unknown arch family. ### Verification - AI-assisted: yes - GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present) - `python3 -W error -I tests/test_frexp_ldexp_f16_mods_probe.py -v`: 21 passed, 1 skipped (AMD clang absent) - Mutation check against unpatched `main`: `ran=22 failures=0 errors=11 (skipped=1)` - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed - `python3 -I scripts/check_no_game_data.py tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py`: passed - `python3 -m compileall -q tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_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#1658
No description provided.