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

Merged
narekshaghoyandev merged 1 commit from upstream-pr/870 into main 2026-11-28 19:26:30 +00:00
narekshaghoyandev commented 2026-11-24 14:51:46 +00:00 (Migrated from github.com)

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


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474501439 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/870). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-24T14:51:46Z. --- 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 commented 2026-11-24 14:55:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:55:53Z.

Review: 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041595289 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/870#pullrequestreview-6041595289). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:55:53Z. **Review:** 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 commented 2026-11-25 03:57:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:57:11Z.

Review: APPROVED


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051647861 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/870#pullrequestreview-6051647861). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T03:57:11Z. **Review:** APPROVED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:26:27Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7244545611 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/870#issuecomment-7244545611). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T19:26:27Z. --- 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 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!870
No description provided.