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

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

@⁠IlyassRS3 on GitHub · 2026-11-25 03:02 UTC · original
IlyassRS3:fix/navmesh-links-endpoint-pairing → main · +146 −25 · 2 files · 1 commits · open

Claimed in the coordination issue as: NAVMESH-LINKS-ENDPOINT-PAIRING-AND-IO (#14)

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)
**@⁠IlyassRS3** on GitHub · 2026-11-25 03:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1515) `IlyassRS3:fix/navmesh-links-endpoint-pairing` → `main` · +146 −25 · 2 files · 1 commits · open Claimed in the coordination issue as: NAVMESH-LINKS-ENDPOINT-PAIRING-AND-IO (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:02 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 03:03 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 03:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1515#pullrequestreview-6051234534) · **reviewed** 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.
Author
Owner

@⁠ytsodacan on GitHub · 2026-11-25 03:34 UTC · original · edited 2026-11-25 03:45 UTC

[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.
**@⁠ytsodacan** on GitHub · 2026-11-25 03:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1515#issuecomment-7152034625) · edited 2026-11-25 03:45 UTC **[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.
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/1515/head:github-bot/gh-1515'
git switch 'github-bot/gh-1515'

Merge

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