OLD-7536: navmesh_nodes: bound tally_tile grid insertion to occupied node cells #870

Merged
leonida/mandy
narekshaghoyandev merged 1 commit from ubiq-navmesh-nodes-bounded-grid-cells into main 2026-11-28 19:26:30 +00:00

Pull request successfully merged and closed

narekshaghoyandev commented 2026-11-24 14:51:46 +00:00

Reopening my original upstream PR #7536 (previously approved by @leoleahy, verified bit-exact across all 63,806 retail nodes and 27,644 retail navmesh resources by @Kev-Ball, plus 300-tile differential equivalence by @senyurah and Windows verification by @rideinstead), cleanly rebased onto main:

  • Bound tally_tile grid insertion to occupied node cells: Previously tally_tile inserted every polygon into every (gx, gy) cell across its full [floor(min_x/CELL)..floor(max_x/CELL)] x [floor(min_y/CELL)..floor(max_y/CELL)] bounding box, allowing a single crafted tile with large finite ext (e.g. 1e10) to hang/OOM Python. Since polygon_under only ever queries the cells occupied by mine nodes, inserting only into (gx, gy) cells that actually hold a node in mine produces 100% identical tallies in bounded time and memory.

Verification

  • python3 -I tests/test_navmesh_nodes.py -v: 18/18 pass in 0.66s (negative control on main hangs/OOMs on test_huge_finite_extent_does_not_exhaust_grid_memory).
  • python3 -I scripts/check_no_game_data.py tools/navmesh_nodes.py tests/test_navmesh_nodes.py: clean.
  • python3 -m compileall -q tools/navmesh_nodes.py tests/test_navmesh_nodes.py: clean.

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

Reopening my original upstream PR #7536 (previously approved by `@leoleahy`, verified bit-exact across all 63,806 retail nodes and 27,644 retail navmesh resources by `@Kev-Ball`, plus 300-tile differential equivalence by `@senyurah` and Windows verification by `@rideinstead`), cleanly rebased onto `main`: - **Bound `tally_tile` grid insertion to occupied node cells**: Previously `tally_tile` inserted every polygon into every `(gx, gy)` cell across its full `[floor(min_x/CELL)..floor(max_x/CELL)] x [floor(min_y/CELL)..floor(max_y/CELL)]` bounding box, allowing a single crafted tile with large finite `ext` (e.g. `1e10`) to hang/OOM Python. Since `polygon_under` only ever queries the cells occupied by `mine` nodes, inserting only into `(gx, gy)` cells that actually hold a node in `mine` produces 100% identical tallies in bounded time and memory. ### Verification - `python3 -I tests/test_navmesh_nodes.py -v`: 18/18 pass in 0.66s (negative control on `main` hangs/OOMs on `test_huge_finite_extent_does_not_exhaust_grid_memory`). - `python3 -I scripts/check_no_game_data.py tools/navmesh_nodes.py tests/test_navmesh_nodes.py`: clean. - `python3 -m compileall -q tools/navmesh_nodes.py tests/test_navmesh_nodes.py`: clean. Claimed in the coordination issue as: OLD-7536 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135050591) AI-assisted: yes (Gemini)
abnalstlll-byte approved these changes 2026-11-24 14:55:53 +00:00
abnalstlll-byte left a comment

Audited and verified. Bounds polygon grid insertion in ools/navmesh_nodes.py:tally_tile to
eeded_cells occupied by nodes in the tile, switching iteration strategies based on bounding box cardinality to prevent out-of-memory loops on corrupt tiles with large float extents. Unit tests in ests/test_navmesh_nodes.py pass cleanly. Approved.

Audited and verified. Bounds polygon grid insertion in ools/navmesh_nodes.py:tally_tile to eeded_cells occupied by nodes in the tile, switching iteration strategies based on bounding box cardinality to prevent out-of-memory loops on corrupt tiles with large float extents. Unit tests in ests/test_navmesh_nodes.py pass cleanly. Approved.
tiguan26 approved these changes 2026-11-25 03:57:11 +00:00
tiguan26 left a comment

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Only cells occupied by this tile's nodes are ever queried, so inserting into those alone keeps the same lookups while a damaged tile with a huge finite extent no longer tries to build billions of grid entries.

AI-assisted (Claude).

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Only cells occupied by this tile's nodes are ever queried, so inserting into those alone keeps the same lookups while a damaged tile with a huge finite extent no longer tries to build billions of grid entries. AI-assisted (Claude).
MoonEyes commented 2026-11-28 19:26:27 +00:00

Red/green: tests/test_navmesh_nodes.py is killed with rc 137 on main by the huge-extent tile and passes with the PR merged, on GitHub Actions Linux.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: tests/test_navmesh_nodes.py is killed with rc 137 on main by the huge-extent tile and passes with the PR merged, on GitHub Actions Linux. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.