navmesh_links: pair cross-tile endpoint sector with polygon id and publish --out atomically (NAVMESH-LINKS-ENDPOINT-PAIRING-AND-IO) #1515

Merged
IlyassRS3 merged 1 commit from upstream-pr/1515 into main 2026-11-29 00:43:32 +00:00
IlyassRS3 commented 2026-11-25 03:02:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T03:02:47Z.


Claimed in the coordination issue as: NAVMESH-LINKS-ENDPOINT-PAIRING-AND-IO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151504645)

What and why

  1. Cross-tile special-link endpoint sector/polygon pairing (verify_tile):
    • verify_tile previously checked if not ((p0 == gpi or p1 == gpi) and (s0 == c8 or s1 == c8)), decoupling each endpoint's sector ID from its polygon ID.
    • For a cross-tile link with one local endpoint (s1 == c8, p1 == 2) and one remote endpoint (s0 == c8 + 1, p0 == 1), if both local polygon 2 and spurious local polygon 1 listed the link in +0xB0, the check falsely passed because p0 == 1 matched the remote polygon ID while s1 == c8 matched the local sector (and the follow-up by_li check also saw p1 == 2 present).
    • Paired each sector with its own polygon index: if not ((s0 == c8 and p0 == gpi) or (s1 == c8 and p1 == gpi)).
  2. Direct-caller argument validation (scan):
    • Validates start >= 0 and limit >= 1 (rejecting bool and invalid values) in scan() rather than only in main().
  3. Atomic --out publishing, strict JSON, and clean CLI error reporting (_write_json_atomic, main):
    • Publishes --out via a sibling temp file, file_mode.published_mode, and replace_retry.replace, cleaning up on failure so an existing report is never truncated on error.
    • Enforces allow_nan=False on both --out and stdout JSON, and catches OSError in main() to emit a single error: line and exit code 2 instead of a traceback.

Tested

  • python3 -I tests/test_navmesh_links.py -v: 11/11 OK (8 existing + 3 new regression tests).
  • Mutation check against unpatched main:tools/navmesh_links.py: all 3 new tests fail (FAILED (failures=9, errors=1)), including both cross-tile endpoint directions (remote_s0 and remote_s1).
  • python3 -I tests/test_text_write_line_endings.py: 3/3 OK.
  • python3 -I scripts/check_no_game_data.py tools/navmesh_links.py tests/test_navmesh_links.py: clean.
  • python3 -m compileall -q tools/navmesh_links.py tests/test_navmesh_links.py: clean.

GPUs tested: n/a (pure Python stdlib tool, synthetic navmesh tile tests only, no GPU or game data)

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. (n/a — no translator rule changes)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5484349262 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1515). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T03:02:47Z. --- Claimed in the coordination issue as: NAVMESH-LINKS-ENDPOINT-PAIRING-AND-IO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151504645) ### What and why 1. **Cross-tile special-link endpoint sector/polygon pairing (`verify_tile`)**: - `verify_tile` previously checked `if not ((p0 == gpi or p1 == gpi) and (s0 == c8 or s1 == c8))`, decoupling each endpoint's sector ID from its polygon ID. - For a cross-tile link with one local endpoint `(s1 == c8, p1 == 2)` and one remote endpoint `(s0 == c8 + 1, p0 == 1)`, if both local polygon `2` and spurious local polygon `1` listed the link in `+0xB0`, the check falsely passed because `p0 == 1` matched the remote polygon ID while `s1 == c8` matched the local sector (and the follow-up `by_li` check also saw `p1 == 2` present). - Paired each sector with its own polygon index: `if not ((s0 == c8 and p0 == gpi) or (s1 == c8 and p1 == gpi))`. 2. **Direct-caller argument validation (`scan`)**: - Validates `start >= 0` and `limit >= 1` (rejecting `bool` and invalid values) in `scan()` rather than only in `main()`. 3. **Atomic `--out` publishing, strict JSON, and clean CLI error reporting (`_write_json_atomic`, `main`)**: - Publishes `--out` via a sibling temp file, `file_mode.published_mode`, and `replace_retry.replace`, cleaning up on failure so an existing report is never truncated on error. - Enforces `allow_nan=False` on both `--out` and stdout JSON, and catches `OSError` in `main()` to emit a single `error:` line and exit code 2 instead of a traceback. ### Tested - `python3 -I tests/test_navmesh_links.py -v`: **11/11 OK** (8 existing + 3 new regression tests). - Mutation check against unpatched `main:tools/navmesh_links.py`: all 3 new tests fail (`FAILED (failures=9, errors=1)`), including both cross-tile endpoint directions (`remote_s0` and `remote_s1`). - `python3 -I tests/test_text_write_line_endings.py`: **3/3 OK**. - `python3 -I scripts/check_no_game_data.py tools/navmesh_links.py tests/test_navmesh_links.py`: clean. - `python3 -m compileall -q tools/navmesh_links.py tests/test_navmesh_links.py`: clean. GPUs tested: n/a (pure Python stdlib tool, synthetic navmesh tile tests only, no GPU or game data) 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — no translator rule changes)
copilot-pull-request-reviewer[bot] commented 2026-11-25 03:03:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:03:01Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051234534 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1515#pullrequestreview-6051234534). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T03:03:01Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
ytsodacan commented 2026-11-25 03:34:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:34:04Z.


[KEEP]

  • Fix is plausible and tested: verify_tile in tools/navmesh_links.py now pairs each endpoint sector with its own polygon id, closing the false pass described in the PR, with three new regression tests in tests/test_navmesh_links.py.
  • CI is not finished (change-scope, no-game-data pending), so the 11/11 local result is not yet confirmed.
  • Scope is wide for one PR: the endpoint-pairing fix is combined with scan() argument validation and an atomic --out writer with strict JSON and new CLI error handling. Maintainers may want these split or confirmed as acceptable together.
  • scan() now raises ValueError for start/limit from direct callers; worth checking no other caller relies on the old behavior.
  • No overlapping open PR found. Re-triage once CI is green.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7152034625 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1515#issuecomment-7152034625). Originally posted by [ytsodacan](https://github.com/ytsodacan) on 2026-11-25T03:34:04Z. --- **[KEEP]** - Fix is plausible and tested: `verify_tile` in `tools/navmesh_links.py` now pairs each endpoint sector with its own polygon id, closing the false pass described in the PR, with three new regression tests in `tests/test_navmesh_links.py`. - CI is not finished (`change-scope`, `no-game-data` pending), so the 11/11 local result is not yet confirmed. - Scope is wide for one PR: the endpoint-pairing fix is combined with `scan()` argument validation and an atomic `--out` writer with strict JSON and new CLI error handling. Maintainers may want these split or confirmed as acceptable together. - `scan()` now raises `ValueError` for `start`/`limit` from direct callers; worth checking no other caller relies on the old behavior. - No overlapping open PR found. Re-triage once CI is green.
zmasi commented 2026-11-28 20:43:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T20:43:29Z.


#1515 | head 369310e6ea (merged cleanly with main 1bc055e6c2) | python -I tests/test_navmesh_links.py | red on main: FAILED (failures=9, errors=1) (verify_tile accepted cross-tile link endpoint IDs on the wrong sector, scan accepted negative/bool start and non-positive/bool limit, and --out lacked replace_retry atomic publication) | green on PR+main: 11 tests OK | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/navmesh_links.py and tests/test_navmesh_links.py on Windows 11 NTFS, verifying paired (s0 == c8 and p0 == gpi) or (s1 == c8 and p1 == gpi) endpoint checks in verify_tile, strict integer/non-bool start and limit bounds in scan, _write_json_atomic (allow_nan=False + tempfile.mkstemp + replace_retry preserving existing reports and leaving zero .tmp files on failure), clean exit-2 OSError reporting, tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245493818 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1515#issuecomment-7245493818). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T20:43:29Z. --- #1515 | head 369310e6eaeff6c7a03e9e0e2cb8107a788733ac (merged cleanly with main 1bc055e6c2) | `python -I tests/test_navmesh_links.py` | red on main: `FAILED (failures=9, errors=1)` (`verify_tile` accepted cross-tile link endpoint IDs on the wrong sector, `scan` accepted negative/bool `start` and non-positive/bool `limit`, and `--out` lacked `replace_retry` atomic publication) | green on PR+main: `11 tests OK` | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/navmesh_links.py` and `tests/test_navmesh_links.py` on Windows 11 NTFS, verifying paired `(s0 == c8 and p0 == gpi) or (s1 == c8 and p1 == gpi)` endpoint checks in `verify_tile`, strict integer/non-bool `start` and `limit` bounds in `scan`, `_write_json_atomic` (`allow_nan=False` + `tempfile.mkstemp` + `replace_retry` preserving existing reports and leaving zero `.tmp` files on failure), clean exit-2 `OSError` reporting, `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-29 00:17:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:16Z.


Tested 369310e6e merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_navmesh_links.py, 11 tests pass.
  • Red: with tools/navmesh_links.py back to main, 9 failures and 1 error (ValueError not raised).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248007360 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1515#issuecomment-7248007360). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:16Z. --- Tested `369310e6e` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_navmesh_links.py`, 11 tests pass. - Red: with `tools/navmesh_links.py` back to `main`, 9 failures and 1 error (`ValueError not raised`). No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 00:43:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:43:34Z.


Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto main e66c65b95 without conflict, and its test file(s) (tests/test_navmesh_links.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:7248308885 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1515#issuecomment-7248308885). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T00:43:34Z. --- Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1515#issuecomment-7248007360)) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto `main` e66c65b95 without conflict, and its test file(s) (`tests/test_navmesh_links.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!1515
No description provided.