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

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

@⁠abnalstlll-byte on GitHub · 2026-11-25 22:16 UTC · original
abnalstlll-byte:feat/bvh-tri-probe-json-and-cli → main · +258 −19 · 2 files · 1 commits · open

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).

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2130) `abnalstlll-byte:feat/bvh-tri-probe-json-and-cli` → `main` · +258 −19 · 2 files · 1 commits · open ### 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).
- Validate --oracle tokens and reject empty or whitespace components upfront.
- Add --hw-arch CLI option, validating and plumbing it to runner.open_oracle().
- Validate and split --kernel arguments with comma expansion, rejecting empty tokens.
- Add validate_json_path() to reject invalid paths, directory paths, and non-directory parents upfront.
- Add write_report() to write JSON atomically with LF line endings and proper file mode.
- Robustly resolve oracle family (handling ValueError) and safely close oracle resources.
- Guard against empty or missing hardware oracle results.
- Add comprehensive test coverage in tests/test_bvh_tri_probe.py (27 tests passing).

Tested:
- python -I tests/test_bvh_tri_probe.py (27/27 passed)
- python -I tools/bvh_tri_probe.py --self-test (passed)
- python -I scripts/check_no_game_data.py tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py (clean)

AI-assisted (Claude Code, Claude Opus 5.5).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:19:14 +00:00
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 12:23 UTC · original

Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_bvh_tri_probe.py: 27 tests OK. The PR's test file against main's tool: 1 failure and 7 errors, so the new tests fail on main and pass with the change. compileall clean.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 12:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2130#issuecomment-7191949381) Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_bvh_tri_probe.py: 27 tests OK. The PR's test file against main's tool: 1 failure and 7 errors, so the new tests fail on main and pass with the change. compileall clean. AI-assisted: yes (Claude Code)
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/2130/head:github-bot/gh-2130'
git switch 'github-bot/gh-2130'

Merge

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