meshlet_page: fix u16 running-sum wraparound, non-finite crashes, and 0-meshlet groups #331

Closed
github-bot wants to merge 1 commit from github-bot/gh-331 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 03:11 UTC · original
ubiquitarianism:old-pr/10066 → main · +141 −22 · 2 files · 1 commits · closed without merging

Carried over from old PR 10066 by ShotTechOp in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10066, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
ShotTechOp: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Summary

Clean rebase onto ProjectLeonida/Leonida main (de4c373) of formerly approved PR #8313 (closed in the bulk PR cleanup sweep):

  1. Unbounded running sums past 65,535 refs/triangles:
    • Replaces truncated 16-bit w1 offsets with accumulated running vbase/tbase sums in group_triangles(), cone_agreement(), centre_agreement(), and centre_distance(), preventing wraparound corruption on large groups.
  2. Non-finite (NaN/±inf) position, bias, and overflowing-normal guards:
    • Guards round() and distance/normal checks with math.isfinite in centre_agreement(), centre_distance(), and cone_agreement() so malformed or extreme inputs skip gracefully instead of raising ValueError/OverflowError or letting trailing NaNs slip past.
  3. Reject 0-meshlet groups in parse_group():
    • Raises PageError on empty groups (0x80000000, 0, 0) instead of accepting them.

Coordination & Prior Verification

Testing

Environment: Windows 11 x64, Python 3.12.10, CPU-only (rebased on de4c373).

  • python -I tests/test_meshlet_page.py -> 70/70 OK
  • python -m compileall -q tools/meshlet_page.py tests/test_meshlet_page.py -> exit 0
  • python -I scripts/check_no_game_data.py tools/meshlet_page.py tests/test_meshlet_page.py -> exit 0
  • git diff --check -> clean
**@⁠Andretuta** on GitHub · 2026-11-24 03:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/331) `ubiquitarianism:old-pr/10066` → `main` · +141 −22 · 2 files · 1 commits · closed without merging > Carried over from **old PR 10066** by `ShotTechOp` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10066`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `ShotTechOp`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ## Summary Clean rebase onto `ProjectLeonida/Leonida` `main` (`de4c373`) of formerly approved PR `#8313` (closed in the bulk PR cleanup sweep): 1. **Unbounded running sums past 65,535 refs/triangles**: - Replaces truncated 16-bit `w1` offsets with accumulated running `vbase`/`tbase` sums in `group_triangles()`, `cone_agreement()`, `centre_agreement()`, and `centre_distance()`, preventing wraparound corruption on large groups. 2. **Non-finite (`NaN`/`±inf`) position, bias, and overflowing-normal guards**: - Guards `round()` and distance/normal checks with `math.isfinite` in `centre_agreement()`, `centre_distance()`, and `cone_agreement()` so malformed or extreme inputs skip gracefully instead of raising `ValueError`/`OverflowError` or letting trailing `NaN`s slip past. 3. **Reject 0-meshlet groups in `parse_group()`**: - Raises `PageError` on empty groups (`0x80000000, 0, 0`) instead of accepting them. ## Coordination & Prior Verification - Claimed in `#9677`: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117121412 - Supersedes closed `#8313` (previously **APPROVED** by `@leoleahy` and independently verified by `@ne1i`, `@garuspl`, `@sergiocr06`, and `@Atomic258`). - No game files used; synthetic tests only. - AI-assisted: yes (Antigravity). ## Testing Environment: Windows 11 x64, Python 3.12.10, CPU-only (rebased on `de4c373`). - `python -I tests/test_meshlet_page.py` -> 70/70 OK - `python -m compileall -q tools/meshlet_page.py tests/test_meshlet_page.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/meshlet_page.py tests/test_meshlet_page.py` -> exit 0 - `git diff --check` -> clean
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:53:46 +00:00
Author
Owner

@⁠Len1k on GitHub · 2026-11-24 08:09 UTC · original

Ran this branch's tests, then reverted its source to the branch's base commit and ran them again — the tests pass either way, and the reason is worth knowing before review spends time on it.

tools/meshlet_page.py is byte-identical at this branch's head (bcc36841e) and at its base (1c7f5b510), and identical to main today (52,965 bytes, both contain the no meshlets rejection). So the fix this pull request describes is already on main — the branch now carries only the 94 added lines in tests/test_meshlet_page.py.

Everything I can run is green: tests/test_meshlet_page.py → OK (1 test), and the new cases (test_empty_zero_meshlet_group_rejected, test_group_running_sums_past_u16_wrap) exercise behaviour that main already has, which is why they stay green when the source is reverted.

Not a defect in your code — the fix is good, it just landed somewhere else first. Worth either closing this as redundant or retitling it to what it now is (tests only), so the reviewer does not go looking for a source change that is not in the diff.

AI-assisted. Standard library only, no game files, no GPU.

**@⁠Len1k** on GitHub · 2026-11-24 08:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/331#issuecomment-7125793035) Ran this branch's tests, then reverted its source to the branch's base commit and ran them again — **the tests pass either way**, and the reason is worth knowing before review spends time on it. `tools/meshlet_page.py` is **byte-identical** at this branch's head (`bcc36841e`) and at its base (`1c7f5b510`), and identical to `main` today (52,965 bytes, both contain the `no meshlets` rejection). So the fix this pull request describes is already on `main` — the branch now carries only the 94 added lines in `tests/test_meshlet_page.py`. Everything I can run is green: `tests/test_meshlet_page.py` → `OK` (1 test), and the new cases (`test_empty_zero_meshlet_group_rejected`, `test_group_running_sums_past_u16_wrap`) exercise behaviour that `main` already has, which is why they stay green when the source is reverted. Not a defect in your code — the fix is good, it just landed somewhere else first. Worth either closing this as redundant or retitling it to what it now is (tests only), so the reviewer does not go looking for a source change that is not in the diff. *AI-assisted.* Standard library only, no game files, no GPU.
github-bot closed this pull request 2026-11-27 04:04:22 +00:00
Author
Owner

@⁠Andretuta on GitHub · 2026-11-27 04:02 UTC · original

Closing carried-over draft: tools/meshlet_page.py fix already landed on main.

**@⁠Andretuta** on GitHub · 2026-11-27 04:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/331#issuecomment-7209467639) Closing carried-over draft: `tools/meshlet_page.py` fix already landed on `main`.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.