OLD-7594: bvh_packing_check: fix bvh4-chunk continuation joining and NaN/Inf root checks #879

Merged
narekshaghoyandev merged 1 commit from upstream-pr/879 into main 2026-11-28 13:06:18 +00:00
narekshaghoyandev commented 2026-11-24 14:54:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-24T14:54:37Z.


Reopening my original upstream PR #7594 (refined per @Envyre and @kapitche's reviews), cleanly rebased onto main:

  1. Harden bvh4-chunk continuation joining (scan_window):
    • Skips false-positive ZHDR bytes in padding only within a bounded 16-byte slop (prev_end + 16) after a failed _inflate, so a damaged continuation stops cleanly as short_input instead of skipping ahead to glue an unrelated later raw stream.
    • Stops continuation joining on any non-raw stream (more_kind != "raw", including XML streams).
    • Defers recording continuation counts and consumed offsets until the joined stream actually reaches declared_bytes, so failed joins do not steal unrelated streams.
  2. Catch NaN/Inf in root bounds comparisons (_root_equal, union check): Rejects NaN anywhere in root bounds or child union (min([0.0, nan]) silently returned 0.0) and rejects infinite vs finite BOX32 bounds.

Verification

  • python3 -I tests/test_bvh_packing_check.py -v: 33/33 pass (both new tests fail against main).
  • python3 -I scripts/check_no_game_data.py tools/bvh_packing_check.py tests/test_bvh_packing_check.py: clean.
  • python3 -m compileall -q tools/bvh_packing_check.py tests/test_bvh_packing_check.py: clean.

Claimed in the coordination issue as: OLD-7594 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135123647)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474550420 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/879). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-24T14:54:37Z. --- Reopening my original upstream PR #7594 (refined per `@Envyre` and `@kapitche`'s reviews), cleanly rebased onto `main`: 1. **Harden `bvh4-chunk` continuation joining (`scan_window`)**: - Skips false-positive `ZHDR` bytes in padding only within a bounded 16-byte slop (`prev_end + 16`) after a failed `_inflate`, so a damaged continuation stops cleanly as `short_input` instead of skipping ahead to glue an unrelated later `raw` stream. - Stops continuation joining on any non-`raw` stream (`more_kind != "raw"`, including XML streams). - Defers recording `continuation` counts and `consumed` offsets until the joined stream actually reaches `declared_bytes`, so failed joins do not steal unrelated streams. 2. **Catch NaN/Inf in root bounds comparisons (`_root_equal`, union check)**: Rejects NaN anywhere in root bounds or child union (`min([0.0, nan])` silently returned `0.0`) and rejects infinite vs finite BOX32 bounds. ### Verification - `python3 -I tests/test_bvh_packing_check.py -v`: 33/33 pass (both new tests fail against `main`). - `python3 -I scripts/check_no_game_data.py tools/bvh_packing_check.py tests/test_bvh_packing_check.py`: clean. - `python3 -m compileall -q tools/bvh_packing_check.py tests/test_bvh_packing_check.py`: clean. Claimed in the coordination issue as: OLD-7594 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135123647) AI-assisted: yes (Gemini)
PierreEbele commented 2026-11-24 19:34:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T19:34:38Z.


Reviewed 4b32bdc: ran tests/test_bvh_packing_check.py (33 OK here, 31 on main) plus a probe script on both main and this head (NaN/Inf root unions, the _root_equal matrix, eight join inputs, a 2-worker/64-byte-window run, a 25-archive fuzz; no crashes on either side). Reproduced on main, all fixed here: wide (1.0, inf) / (inf, -inf) and narrow nan/nan equalities returned True; a NaN root-union override was order-dependent and could count as equal with no failure; a false 78 9c in chunk padding broke a good join and misreported the continuation as raw; a following bvh4/xml stream could be glued into the join and vanish from the report; failed joins recorded bogus continuation counts. Legal BOX16 +/-inf unions still pass, so no regressions found. gh is disabled for me, so I could not check the coordination-issue claim. AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142295887 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/879#issuecomment-7142295887). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-24T19:34:38Z. --- Reviewed 4b32bdc: ran tests/test_bvh_packing_check.py (33 OK here, 31 on main) plus a probe script on both main and this head (NaN/Inf root unions, the `_root_equal` matrix, eight join inputs, a 2-worker/64-byte-window run, a 25-archive fuzz; no crashes on either side). Reproduced on main, all fixed here: wide `(1.0, inf)` / `(inf, -inf)` and narrow nan/nan equalities returned True; a NaN root-union override was order-dependent and could count as equal with no failure; a false `78 9c` in chunk padding broke a good join and misreported the continuation as raw; a following bvh4/xml stream could be glued into the join and vanish from the report; failed joins recorded bogus continuation counts. Legal BOX16 +/-inf unions still pass, so no regressions found. gh is disabled for me, so I could not check the coordination-issue claim. AI-assisted review.
MoonEyes commented 2026-11-28 13:06:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:06:13Z.


Red/green: tests/test_bvh_packing_check.py 16 failed on main, 39 passed with the PR.
Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main a997a3c: no new failure, Windows 11 / Python.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239692347 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/879#issuecomment-7239692347). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T13:06:13Z. --- Red/green: tests/test_bvh_packing_check.py 16 failed on main, 39 passed with the PR. Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main a997a3c: no new failure, Windows 11 / Python. AI-assisted (Claude Code, Claude Opus 5.5)
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!879
No description provided.