raytracing: fix BVH index building and validation #272

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

@⁠kotekompotek on GitHub · 2026-11-24 02:56 UTC · original
kotekompotek:work/build-1533-bvh-index → main · +26 −1 · 2 files · 1 commits · open

Claimed in the coordination issue as: BUILD-1533 (#14)

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.
**@⁠kotekompotek** on GitHub · 2026-11-24 02:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/272) `kotekompotek:work/build-1533-bvh-index` → `main` · +26 −1 · 2 files · 1 commits · open Claimed in the coordination issue as: BUILD-1533 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:51:28 +00:00
Author
Owner

@⁠ubiquitarianism on GitHub · 2026-11-24 03:14 UTC · original

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.
**@⁠ubiquitarianism** on GitHub · 2026-11-24 03:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7120907760) 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.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-24 18:33 UTC · original

@⁠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** on GitHub · 2026-11-24 18:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7140808431) @⁠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).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 08:58 UTC · original

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

AI-assisted: yes

**@⁠kotekompotek** on GitHub · 2026-11-25 08:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/272#issuecomment-7157699969) Rebased on current ubi/main (3f81d46ac), no conflicts. The added tests pass locally on this base (python -I). AI-assisted: yes
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/272/head:github-bot/gh-272'
git switch 'github-bot/gh-272'

Merge

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