raytracing: fix BVH index building and validation #272

Merged
kotekompotek merged 1 commit from upstream-pr/272 into main 2026-11-28 21:52:16 +00:00
kotekompotek commented 2026-11-24 02:56:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T02:56:55Z.


Claimed in the coordination issue as: BUILD-1533 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149)

What and why

  • Rebased onto current main (commit ccafaeeaa).
  • Guards classify() in tools/bvh_index.py on < 208-byte payloads so instance208 does not crash with struct.error, falling back to descriptor when >= 0x30 descriptor header bytes are available, and marks raw < min(size, HEAD) heads with signature="truncated-head" and truncated_head=True.
  • Added regression coverage (test_truncated_head_on_208_byte_payload_does_not_crash and CLI --max-inflate 128 checks on instance_payload and bvh_payload) in tests/test_bvh_index.py.

Tested

  • python -I tests/test_bvh_index.py (45 tests OK, 1 skipped without game archive) on commit ccafaeeaa.
  • All 12 tests/test_docs_*.py (OK) on commit ccafaeeaa.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465220546 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/272). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T02:56:55Z. --- Claimed in the coordination issue as: BUILD-1533 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149) ### What and why - Rebased onto current `main` (commit `ccafaeeaa`). - Guards `classify()` in `tools/bvh_index.py` on `< 208`-byte payloads so `instance208` does not crash with `struct.error`, falling back to `descriptor` when `>= 0x30` descriptor header bytes are available, and marks raw `< min(size, HEAD)` heads with `signature="truncated-head"` and `truncated_head=True`. - Added regression coverage (`test_truncated_head_on_208_byte_payload_does_not_crash` and CLI `--max-inflate 128` checks on `instance_payload` and `bvh_payload`) in `tests/test_bvh_index.py`. ### Tested - `python -I tests/test_bvh_index.py` (`45 tests OK, 1 skipped` without game archive) on commit `ccafaeeaa`. - All 12 `tests/test_docs_*.py` (`OK`) on commit `ccafaeeaa`. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
ubiquitarianism commented 2026-11-24 03:14:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-11-24T03:14:44Z.


Not merging yet. The crash does reproduce: bvh_index.classify(b'\0'*10, 208) raises struct.error, which --max-inflate below 208 can reach. Please:

  • add a regression test to tests/test_bvh_index.py;
  • fix the description, which mentions test coverage the diff doesn't have;
  • consider reporting a truncated head instead of silently misclassifying it.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7120907760 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7120907760). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-11-24T03:14:44Z. --- Not merging yet. The crash does reproduce: `bvh_index.classify(b'\0'*10, 208)` raises `struct.error`, which `--max-inflate` below 208 can reach. Please: - add a regression test to `tests/test_bvh_index.py`; - fix the description, which mentions test coverage the diff doesn't have; - consider reporting a truncated head instead of silently misclassifying it.
kotekompotek commented 2026-11-24 18:33:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T18:33:20Z.


@ubiquitarianism Updated in commit ccafaeeaa:

  • Added regression coverage (test_truncated_head_on_208_byte_payload_does_not_crash and CLI --max-inflate 128 checks on instance_payload and bvh_payload) in tests/test_bvh_index.py.
  • Marked truncated raw payloads (len(head) < min(size, HEAD)) with signature="truncated-head" and truncated_head=True in tools/bvh_index.py.
  • Updated the PR description accordingly.

Verified: python -I tests/test_bvh_index.py (45 tests OK, 1 skipped) and all 12 tests/test_docs_*.py (OK).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7140808431 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7140808431). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T18:33:20Z. --- @ubiquitarianism Updated in commit `ccafaeeaa`: - Added regression coverage (`test_truncated_head_on_208_byte_payload_does_not_crash` and CLI `--max-inflate 128` checks on `instance_payload` and `bvh_payload`) in `tests/test_bvh_index.py`. - Marked truncated raw payloads (`len(head) < min(size, HEAD)`) with `signature="truncated-head"` and `truncated_head=True` in `tools/bvh_index.py`. - Updated the PR description accordingly. Verified: `python -I tests/test_bvh_index.py` (45 tests OK, 1 skipped) and all 12 `tests/test_docs_*.py` (OK).
kotekompotek commented 2026-11-25 08:58:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-25T08:58:02Z.


Rebased on current ubi/main (3f81d46ac), no conflicts. The added tests pass locally on this base (python -I).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7157699969 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7157699969). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T08:58:02Z. --- Rebased on current ubi/main (3f81d46ac), no conflicts. The added tests pass locally on this base (python -I). AI-assisted: yes
OreoFR commented 2026-11-28 21:41:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:41:50Z.


Verified by OreoFR

Run 1 (win02)

  • Base: main 5cb45921e + PR head 070f9521b
  • Test: python -I tests/test_bvh_index.py
  • Red on main: 1 FAIL + 1 ERROR (truncated-head signature missing on a 208-byte head; --max-inflate not honoured when scanning a folder): the missing function itself
  • Green with the PR: 45 OK (1 skipped)
  • Verdict: READY (same result as lot O, redone on a newer main)

Run 2 (lot O)

  • Base: main 4a54aedcb + PR head 070f9521b
  • Test: python -I tests/test_bvh_index.py
  • Red on main: 1 error + 1 failure (truncated 208-byte head, truncated-head signature missing)
  • Green with the PR: OK (1 skipped)
  • Verdict: READY

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246205179 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/272#issuecomment-7246205179). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:41:50Z. --- **Verified by OreoFR** **Run 1 (win02)** - Base: main `5cb45921e` + PR head `070f9521b` - Test: `python -I tests/test_bvh_index.py` - Red on main: 1 FAIL + 1 ERROR (truncated-head signature missing on a 208-byte head; --max-inflate not honoured when scanning a folder): the missing function itself - Green with the PR: 45 OK (1 skipped) - Verdict: READY (same result as lot O, redone on a newer main) **Run 2 (lot O)** - Base: main `4a54aedcb` + PR head `070f9521b` - Test: `python -I tests/test_bvh_index.py` - Red on main: 1 error + 1 failure (truncated 208-byte head, truncated-head signature missing) - Green with the PR: OK (1 skipped) - Verdict: READY **All runs** - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-28 21:52:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T21:52:19Z.


Merged after OreoFR's red/green check (check) (RTX 4070 Laptop, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto main 7ef2a485e without conflict, and its test file(s) (tests/test_bvh_index.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:7246333900 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/272#issuecomment-7246333900). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T21:52:19Z. --- Merged after **OreoFR**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/272#issuecomment-7246205179)) (RTX 4070 Laptop, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 7ef2a485e without conflict, and its test file(s) (`tests/test_bvh_index.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!272
No description provided.