[PR #2130] bvh_tri_probe: harden --oracle/--kernel, upfront atomic JSON writes, and oracle error handling (BVH-TRI-PROBE-JSON-AND-CLI) #2135

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2130
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/bvh-tri-probe-json-and-cli


📝 Commits (1)

  • 6d2b626 bvh_tri_probe: harden --oracle/--kernel, upfront atomic JSON writes, and oracle error handling (BVH-TRI-PROBE-JSON-AND-CLI)

📊 Changes

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

View changed files

📝 tests/test_bvh_tri_probe.py (+142 -0)
📝 tools/bvh_tri_probe.py (+116 -19)

📄 Description

Summary

Hardens tools/bvh_tri_probe.py argument handling, JSON reporting, and hardware oracle execution:

  • --oracle validation: Rejects empty strings, whitespace, and malformed comma-separated tokens (e.g. translator, or ,hw) upfront with clear diagnostic exit code 2.
  • --hw-arch plumbing: Adds --hw-arch CLI parameter, validates against empty/whitespace values, and passes arch to runner.open_oracle(arch=...).
  • --kernel token sanitation: Validates repeatable --kernel options and comma-separated kernel lists, rejecting empty/whitespace tokens upfront and deduplicating kernel selection.
  • Upfront JSON path validation & atomic reporting: Validates destination path upfront (validate_json_path()) to catch non-file destinations, trailing slashes, or missing/non-directory parents before running kernels. Implements write_report() to write JSON atomically via tempfile replacement with consistent LF line endings and proper file modes.
  • Hardware oracle safety & error handling: Defensively resolves architecture family (gracefully skipping non-GFX10 devices or unsupported architectures with exit code 77), guards against empty or truncated oracle runs with RuntimeError, and ensures oracle resources are closed via finally.
  • Test coverage: Adds unit tests in tests/test_bvh_tri_probe.py covering all new CLI validation paths, atomic JSON writing, and oracle error/skip paths (27/27 tests pass).

Verification

python -I tests/test_bvh_tri_probe.py
python -I tools/bvh_tri_probe.py --self-test
python -I scripts/check_no_game_data.py tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py

Claimed in #1608 (BVH-TRI-PROBE-JSON-AND-CLI).

AI-assisted (Claude Code, Claude Opus 5.5).


🔄 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/2130 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/bvh-tri-probe-json-and-cli` --- ### 📝 Commits (1) - [`6d2b626`](https://github.com/ubiquitarianism/leonida/commit/6d2b626281e27a3946fef2d4c828af476d83784e) bvh_tri_probe: harden --oracle/--kernel, upfront atomic JSON writes, and oracle error handling (BVH-TRI-PROBE-JSON-AND-CLI) ### 📊 Changes **2 files changed** (+258 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_bvh_tri_probe.py` (+142 -0) 📝 `tools/bvh_tri_probe.py` (+116 -19) </details> ### 📄 Description ### Summary Hardens `tools/bvh_tri_probe.py` argument handling, JSON reporting, and hardware oracle execution: - **`--oracle` validation**: Rejects empty strings, whitespace, and malformed comma-separated tokens (e.g. `translator,` or `,hw`) upfront with clear diagnostic exit code 2. - **`--hw-arch` plumbing**: Adds `--hw-arch` CLI parameter, validates against empty/whitespace values, and passes `arch` to `runner.open_oracle(arch=...)`. - **`--kernel` token sanitation**: Validates repeatable `--kernel` options and comma-separated kernel lists, rejecting empty/whitespace tokens upfront and deduplicating kernel selection. - **Upfront JSON path validation & atomic reporting**: Validates destination path upfront (`validate_json_path()`) to catch non-file destinations, trailing slashes, or missing/non-directory parents before running kernels. Implements `write_report()` to write JSON atomically via tempfile replacement with consistent LF line endings and proper file modes. - **Hardware oracle safety & error handling**: Defensively resolves architecture family (gracefully skipping non-GFX10 devices or unsupported architectures with exit code 77), guards against empty or truncated oracle runs with `RuntimeError`, and ensures oracle resources are closed via `finally`. - **Test coverage**: Adds unit tests in `tests/test_bvh_tri_probe.py` covering all new CLI validation paths, atomic JSON writing, and oracle error/skip paths (27/27 tests pass). ### Verification ```powershell python -I tests/test_bvh_tri_probe.py python -I tools/bvh_tri_probe.py --self-test python -I scripts/check_no_game_data.py tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py ``` Claimed in #1608 (`BVH-TRI-PROBE-JSON-AND-CLI`). AI-assisted (Claude Code, Claude Opus 5.5). --- <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#2135
No description provided.