bvh_groups: validate scan bounds and --json upfront, use same_report_path, catch write OSError (BVH-GROUPS-GUARDS-AND-IO) #1599

Merged
IlyassRS3 merged 4 commits from upstream-pr/1599 into main 2026-11-29 00:37:40 +00:00
IlyassRS3 commented 2026-11-25 05:32:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T05:32:18Z.


Item: BVH-GROUPS-GUARDS-AND-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/bvh_groups.py).

Summary

  • Validate start, limit, and max_inflate in scan() before the empty-archive fast path so out-of-range start on empty files, limit <= 0, max_inflate <= 0, and bool values raise ValueError (previously limit=0 scanned the whole archive and max_inflate=0/True crashed with struct.error in bvh_index.classify).
  • Validate archive and --json before scanning (reject empty/whitespace strings, directories, trailing separators, and missing parent directories) and use the shared report_paths.same_report_path() guard instead of raw os.path.samefile().
  • Catch OSError from write_json_report() in main() and publish --json before printing stdout (exiting with code 2 and one stderr line instead of a traceback), and enforce allow_nan=False in write_json_report().

Verification

  • python3 -W error -I tests/test_bvh_groups.py -v: 16/16 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py: passed.
  • python3 -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py: passed.
  • Mutation check (running tests/test_bvh_groups.py against unpatched main:tools/bvh_groups.py): failures=11, errors=3 across all new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python BVH descriptor tool; synthetic streams only, no game data)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485772964 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T05:32:18Z. --- Item: `BVH-GROUPS-GUARDS-AND-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/bvh_groups.py`). ### Summary - Validate `start`, `limit`, and `max_inflate` in `scan()` before the empty-archive fast path so out-of-range `start` on empty files, `limit <= 0`, `max_inflate <= 0`, and `bool` values raise `ValueError` (previously `limit=0` scanned the whole archive and `max_inflate=0`/`True` crashed with `struct.error` in `bvh_index.classify`). - Validate `archive` and `--json` before scanning (reject empty/whitespace strings, directories, trailing separators, and missing parent directories) and use the shared `report_paths.same_report_path()` guard instead of raw `os.path.samefile()`. - Catch `OSError` from `write_json_report()` in `main()` and publish `--json` before printing stdout (exiting with code 2 and one stderr line instead of a traceback), and enforce `allow_nan=False` in `write_json_report()`. ### Verification - `python3 -W error -I tests/test_bvh_groups.py -v`: 16/16 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py`: passed. - `python3 -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py`: passed. - Mutation check (running `tests/test_bvh_groups.py` against unpatched `main:tools/bvh_groups.py`): `failures=11, errors=3` across all new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python BVH descriptor tool; synthetic streams only, no game data)
copilot-pull-request-reviewer[bot] commented 2026-11-25 05:32:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T05:32:31Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052331827 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#pullrequestreview-6052331827). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T05:32:31Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-27 23:36:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:36:14Z.


Hi @IlyassRS3, thanks for this (claimed in #1608 as BVH-GROUPS-GUARDS-AND-IO). It overlaps with #931: #931 (claimed as DRAFT-274, carrying EspadaHD's commit) already makes two of this pull request's three changes: it uses the shared report_paths.same_report_path and turns an OSError from write_json_report into exit status 2 with one stderr line. If #931 lands first, please rebase this one so only the scan() argument checks, the up-front --json validation and allow_nan=False remain. If this one lands first, please keep #931's test that a ./ alias of the archive is refused, so #931 can then be closed.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230267206 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7230267206). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:36:14Z. --- Hi @IlyassRS3, thanks for this (claimed in #1608 as BVH-GROUPS-GUARDS-AND-IO). It overlaps with #931: #931 (claimed as DRAFT-274, carrying `EspadaHD`'s commit) already makes two of this pull request's three changes: it uses the shared `report_paths.same_report_path` and turns an `OSError` from `write_json_report` into exit status 2 with one stderr line. If #931 lands first, please rebase this one so only the `scan()` argument checks, the up-front `--json` validation and `allow_nan=False` remain. If this one lands first, please keep #931's test that a `./` alias of the archive is refused, so #931 can then be closed. AI-assisted (Claude Code, Claude Opus 5.5)
MoonEyes commented 2026-11-28 18:01:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:01:31Z.


Hi @IlyassRS3, thanks for this pull request. It currently conflicts with main (conflicting file(s): tests/test_bvh_groups.py, tools/bvh_groups.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243470038 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7243470038). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:01:31Z. --- Hi @IlyassRS3, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tests/test_bvh_groups.py`, `tools/bvh_groups.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 22:01:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:01:53Z.


#1599 | head 38f9a734b9 (merged cleanly with main a8465211fb) | python -I tests/test_bvh_groups.py + python -I tests/test_bcpack_tool.py | red on main: FAILED (failures=12, errors=2) (bvh_groups.scan accepted negative/zero/boolean start, limit, and max_inflate inputs — raising struct.error on max_inflate=0|True — main ran scan() before validating --json, printed summary lines before --json write failures, and allowed NaN in write_json_report) | green on PR+main: 18 ran, OK (test_bvh_groups.py) + test_bcpack_tool.py OK | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited the rebased 38f9a734b9 diff (tools/bvh_groups.py and tests/test_bvh_groups.py after #931 landed on main) on Windows 11, verifying upfront start/limit/max_inflate integer guards (type(...) is not int rejecting bool), pre-scan --json directory/parent/empty-path validation, allow_nan=False in write_json_report, and stdout suppression when write_json_report fails. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246446566 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7246446566). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:01:53Z. --- #1599 | head 38f9a734b93e28e5d9562237716c6ff8920f8116 (merged cleanly with main a8465211fb) | `python -I tests/test_bvh_groups.py` + `python -I tests/test_bcpack_tool.py` | red on main: `FAILED (failures=12, errors=2)` (`bvh_groups.scan` accepted negative/zero/boolean `start`, `limit`, and `max_inflate` inputs — raising `struct.error` on `max_inflate=0|True` — `main` ran `scan()` before validating `--json`, printed summary lines before `--json` write failures, and allowed `NaN` in `write_json_report`) | green on PR+main: `18 ran, OK` (`test_bvh_groups.py`) + `test_bcpack_tool.py` `OK` | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited the rebased `38f9a734b9` diff (`tools/bvh_groups.py` and `tests/test_bvh_groups.py` after `#931` landed on `main`) on Windows 11, verifying upfront `start`/`limit`/`max_inflate` integer guards (`type(...) is not int` rejecting `bool`), pre-scan `--json` directory/parent/empty-path validation, `allow_nan=False` in `write_json_report`, and stdout suppression when `write_json_report` fails. Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-29 00:17:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:10Z.


Tested 38f9a734b merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_bvh_groups.py, 18 tests pass.
  • Red: with tools/bvh_groups.py back to main, 14 failures (ValueError not raised).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248006205 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7248006205). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:10Z. --- Tested `38f9a734b` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_bvh_groups.py`, 18 tests pass. - Red: with `tools/bvh_groups.py` back to `main`, 14 failures (`ValueError not raised`). No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 00:37:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:37:42Z.


Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto main e6546fe78 without conflict, and its test file(s) (tests/test_bcpack_tool.py, tests/test_bvh_groups.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248243607 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7248243607). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T00:37:42Z. --- Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1599#issuecomment-7248006205)) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto `main` e6546fe78 without conflict, and its test file(s) (`tests/test_bcpack_tool.py`, `tests/test_bvh_groups.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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!1599
No description provided.