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

Merged
abnalstlll-byte merged 1 commit from upstream-pr/2130 into main 2026-11-30 13:53:41 +00:00
abnalstlll-byte commented 2026-11-25 22:16:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T22:16:38Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5500119084 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2130). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T22:16:38Z. --- ### 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).
real-rusher commented 2026-11-26 12:23:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T12:23:55Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7191949381 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2130#issuecomment-7191949381). Originally posted by [real-rusher](https://github.com/real-rusher) on 2026-11-26T12:23:55Z. --- 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)
enlight3d commented 2026-11-29 04:37:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T04:37:54Z.


RUN: #2130 (tests only, python -I, no build, no game, GPU not used)

Tested heads: PR head 6d2b62628, main b6bf3aa0b (fetched 2026-11-29).

Commands (from each worktree root, CPython 3.13.12):

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

Red: PR head with tools/bvh_tri_probe.py reverted to its merge-base version (tests kept): 27 tests, FAILED (failures=1, errors=7). Same kind of red as the PR describes (new CLI/JSON validation paths missing). The PR's test file on plain main also fails (failures=1, errors=6).
Green at head: 27 tests OK; --self-test OK.
Green merged into main: NOT RUNNABLE. git merge pr-2130 into main b6bf3aa0b conflicts in tools/bvh_tri_probe.py (3 hunks). Main already has 0a2e5d92c (#1546) touching the same file after the PR's merge base; GitHub also reports the PR as CONFLICTING. Plain main: tests/test_bvh_tri_probe.py 22 tests OK, --self-test OK.

So: green at head, red verified, needs a rebase on main before it can be green merged.

Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250768052 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2130#issuecomment-7250768052). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T04:37:54Z. --- RUN: #2130 (tests only, python -I, no build, no game, GPU not used) Tested heads: PR head 6d2b62628, main b6bf3aa0b (fetched 2026-11-29). Commands (from each worktree root, CPython 3.13.12): - python -I tests/test_bvh_tri_probe.py - python -I tools/bvh_tri_probe.py --self-test Red: PR head with tools/bvh_tri_probe.py reverted to its merge-base version (tests kept): 27 tests, FAILED (failures=1, errors=7). Same kind of red as the PR describes (new CLI/JSON validation paths missing). The PR's test file on plain main also fails (failures=1, errors=6). Green at head: 27 tests OK; --self-test OK. Green merged into main: NOT RUNNABLE. `git merge pr-2130` into main b6bf3aa0b conflicts in tools/bvh_tri_probe.py (3 hunks). Main already has 0a2e5d92c (#1546) touching the same file after the PR's merge base; GitHub also reports the PR as CONFLICTING. Plain main: tests/test_bvh_tri_probe.py 22 tests OK, --self-test OK. So: green at head, red verified, needs a rebase on main before it can be green merged. Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.
OreoFR commented 2026-11-29 08:33:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:33:47Z.


@abnalstlll-byte this PR now conflicts with main (tools/bvh_tri_probe.py). Could you merge main into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/2130#issuecomment-7250768052. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253185011 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2130#issuecomment-7253185011). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:33:47Z. --- @abnalstlll-byte this PR now conflicts with `main` (`tools/bvh_tri_probe.py`). Could you merge `main` into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/2130#issuecomment-7250768052. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
OreoFR commented 2026-11-30 13:24:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:24:50Z.


Carried as #2717 because of the conflict with main after #2566; @abnalstlll-byte, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7279808875 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2130#issuecomment-7279808875). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:24:50Z. --- Carried as #2717 because of the conflict with main after #2566; @abnalstlll-byte, if you come back, say so and the carry is dropped.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2130
No description provided.