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

Open
opened 2026-11-26 20:21:37 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1515
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/navmesh-links-endpoint-pairing


📝 Commits (1)

  • 369310e navmesh_links: pair cross-tile endpoint sector with polygon id and publish --out atomically

📊 Changes

2 files changed (+146 additions, -25 deletions)

View changed files

📝 tests/test_navmesh_links.py (+86 -0)
📝 tools/navmesh_links.py (+60 -25)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1515 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/navmesh-links-endpoint-pairing` --- ### 📝 Commits (1) - [`369310e`](https://github.com/ubiquitarianism/leonida/commit/369310e6eaeff6c7a03e9e0e2cb8107a788733ac) navmesh_links: pair cross-tile endpoint sector with polygon id and publish --out atomically ### 📊 Changes **2 files changed** (+146 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_navmesh_links.py` (+86 -0) 📝 `tools/navmesh_links.py` (+60 -25) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1544
No description provided.