navmesh_decode: ask report_paths for the report-path guard (the last legacy copy) #2949

Closed
erdemcisse wants to merge 1 commit from upstream-pr/2949 into main
erdemcisse commented 2026-12-01 20:51:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by erdemcisse on 2026-12-01T20:51:52Z.


Claimed in the coordination issue as: REPORT-PATHS-NAVMESH-DECODE — https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7325381190

Depends on: #2741 (the same chore for text_tables; the two PRs touch the same two lines of tests/test_report_paths.py, so whichever lands first, the other rebases — this one does not build on its code)

Fixes:

What and why

tools/navmesh_decode.py was the last tool in LEGACY_COPIES: it carried its own same_report_path —

def same_report_path(first, second):
    if _path_key(first) == _path_key(second):     # normcase(realpath) [+ macOS case fold]
        return True
    try:
        return os.path.samefile(first, second)
    except OSError:
        return False

— which is older than tools/report_paths.py and misses both cases the shared guard grew for:

  • a case-folding mount that normcase does not fold (vfat, exFAT, CIFS on Linux/macOS): same_name_on_folding_volume asks the volume itself with one scratch folder. Without it, --out R.json against a carve manifest r.json in a carved directory on such a volume is not refused, and the run overwrites the manifest it scanned.
  • a case-sensitive directory on Windows (WSL2 folders, Dev Drive): _same_windows_folded_path probes the directory, so two genuinely distinct files r.json and R.json are not refused as one.

The comment above LEGACY_COPIES asks for exactly this import ("Do not add to this list: import report_paths instead"), and #2741 did it for text_tables.

The change: import the shared guard (from report_paths import same_report_path), delete the 37-line local copy with _PC_CASE_SENSITIVE, _case_insensitive_volume and _path_key, drop the now unused unicodedata, add navmesh_decode to SHARED, empty LEGACY_COPIES, and cover the re-exported name in test_tools_still_expose_same_report_path — the name navmesh_nodes, navmesh_links and navmesh_cell_fit import from it.

Tested

python -I for the standard-library tests, on Windows 11 (10.0.26100), Python 3.13.15. No game files and no GPU: every test builds its own temporary files, as the suite's own headers say.

Red on main (50e97c1's parent), the test change kept, the tool restored:

FAIL: test_tools_still_expose_same_report_path (…) navmesh_decode
AssertionError: <function same_report_path at 0x…8D620> is not <function same_report_path at 0x…7B240>
FAIL: test_no_tool_keeps_its_own_copy   (navmesh_decode is now in SHARED)
Ran 26 tests — FAILED (failures=3)

Green with the PR:

python -I tests/test_report_paths.py        Ran 26 tests  OK
python -I tests/test_navmesh_decode.py      Ran 17 tests  OK
python -I tests/test_navmesh_nodes.py       Ran 18 tests  OK
python -I tests/test_navmesh_links.py       Ran 11 tests  OK
python -I tests/test_navmesh_cell_fit.py    Ran  7 tests  OK
python -m unittest discover -s tests -p "test_docs_*.py"   Ran 57 tests  OK
python -m compileall -q tools/navmesh_decode.py tests/test_report_paths.py   OK
python -I scripts/check_no_game_data.py tools/navmesh_decode.py tests/test_report_paths.py   clean

navmesh_decode.same_report_path is report_paths.same_report_path is True after the change (checked directly), and the tool's own CLI guard tests (test_cli_refuses_to_overwrite_its_input) still pass unchanged.

GPUs tested: n/a (a Python report-path guard; nothing here runs on a GPU)

AI-assisted: yes — DeepSeek Harness (lead agent). No separate reviewer model was run, which the contributor guide asks for; the tests above are the check I ran.

Checklist

  • Based on current main and merges cleanly (one textual overlap with #2741, named above).
  • One topic: the report-path guard of one tool.
  • No game data, keys or decryption — check_no_game_data.py on both files.
  • A new translator rule is in the contract table of docs/design.md — n/a, no translator change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5594321692 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949). Originally posted by [erdemcisse](https://github.com/erdemcisse) on 2026-12-01T20:51:52Z. --- Claimed in the coordination issue as: REPORT-PATHS-NAVMESH-DECODE — https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7325381190 Depends on: #2741 (the same chore for `text_tables`; the two PRs touch the same two lines of `tests/test_report_paths.py`, so whichever lands first, the other rebases — this one does not build on its code) Fixes: ### What and why `tools/navmesh_decode.py` was the last tool in `LEGACY_COPIES`: it carried its own `same_report_path` — ```python def same_report_path(first, second): if _path_key(first) == _path_key(second): # normcase(realpath) [+ macOS case fold] return True try: return os.path.samefile(first, second) except OSError: return False ``` — which is older than `tools/report_paths.py` and misses both cases the shared guard grew for: - **a case-folding mount that `normcase` does not fold** (vfat, exFAT, CIFS on Linux/macOS): `same_name_on_folding_volume` asks the volume itself with one scratch folder. Without it, `--out R.json` against a carve manifest `r.json` in a carved directory on such a volume is not refused, and the run overwrites the manifest it scanned. - **a case-sensitive directory on Windows** (WSL2 folders, Dev Drive): `_same_windows_folded_path` probes the directory, so two genuinely distinct files `r.json` and `R.json` are not refused as one. The comment above `LEGACY_COPIES` asks for exactly this import ("Do not add to this list: import report_paths instead"), and #2741 did it for `text_tables`. The change: import the shared guard (`from report_paths import same_report_path`), delete the 37-line local copy with `_PC_CASE_SENSITIVE`, `_case_insensitive_volume` and `_path_key`, drop the now unused `unicodedata`, add `navmesh_decode` to `SHARED`, empty `LEGACY_COPIES`, and cover the re-exported name in `test_tools_still_expose_same_report_path` — the name `navmesh_nodes`, `navmesh_links` and `navmesh_cell_fit` import from it. ### Tested `python -I` for the standard-library tests, on Windows 11 (10.0.26100), Python 3.13.15. No game files and no GPU: every test builds its own temporary files, as the suite's own headers say. Red on `main` (`50e97c1`'s parent), the test change kept, the tool restored: ``` FAIL: test_tools_still_expose_same_report_path (…) navmesh_decode AssertionError: <function same_report_path at 0x…8D620> is not <function same_report_path at 0x…7B240> FAIL: test_no_tool_keeps_its_own_copy (navmesh_decode is now in SHARED) Ran 26 tests — FAILED (failures=3) ``` Green with the PR: ``` python -I tests/test_report_paths.py Ran 26 tests OK python -I tests/test_navmesh_decode.py Ran 17 tests OK python -I tests/test_navmesh_nodes.py Ran 18 tests OK python -I tests/test_navmesh_links.py Ran 11 tests OK python -I tests/test_navmesh_cell_fit.py Ran 7 tests OK python -m unittest discover -s tests -p "test_docs_*.py" Ran 57 tests OK python -m compileall -q tools/navmesh_decode.py tests/test_report_paths.py OK python -I scripts/check_no_game_data.py tools/navmesh_decode.py tests/test_report_paths.py clean ``` `navmesh_decode.same_report_path is report_paths.same_report_path` is `True` after the change (checked directly), and the tool's own CLI guard tests (`test_cli_refuses_to_overwrite_its_input`) still pass unchanged. GPUs tested: n/a (a Python report-path guard; nothing here runs on a GPU) AI-assisted: yes — DeepSeek Harness (lead agent). No separate reviewer model was run, which the contributor guide asks for; the tests above are the check I ran. ### Checklist - [x] Based on current `main` and merges cleanly (one textual overlap with #2741, named above). - [x] One topic: the report-path guard of one tool. - [x] No game data, keys or decryption — `check_no_game_data.py` on both files. - [ ] A new translator rule is in the contract table of `docs/design.md` — n/a, no translator change.
merzleckeier commented 2026-12-01 21:01:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T21:01:47Z.


Independent decoder entry-point check for the shared path guard on 50e97c19 merged into bc332322e. The report-path, decoder and index suites passed 79 executed tests on each tree under Linux, with two skips. Windows CPython 3.12.10 under Wine passed 42 executed report-path and decoder tests on each tree, with one skip. The decoder now exposes the shared same_report_path function.

I called the real decoder entry point with synthetic temporary paths. Both trees accepted distinct Linux output files and kept the bytes of a real hardlinked input unchanged when its alias was rejected. With folding normalized keys injected for two existing files whose real identities differ, main refused the outputs and the PR wrote separate JSON and CSV reports. With case-folding lookup simulated for the volume probe and nested output paths that do not yet exist, main accepted the pair and the PR rejected it before creating either output. These last two cases simulate the relevant filesystem rules.

MEASURED with OpenAI Codex and a separate read-only review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7325635193 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949#issuecomment-7325635193). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T21:01:47Z. --- Independent decoder entry-point check for the shared path guard on `50e97c19` merged into `bc332322e`. The report-path, decoder and index suites passed 79 executed tests on each tree under Linux, with two skips. Windows CPython 3.12.10 under Wine passed 42 executed report-path and decoder tests on each tree, with one skip. The decoder now exposes the shared `same_report_path` function. I called the real decoder entry point with synthetic temporary paths. Both trees accepted distinct Linux output files and kept the bytes of a real hardlinked input unchanged when its alias was rejected. With folding normalized keys injected for two existing files whose real identities differ, main refused the outputs and the PR wrote separate JSON and CSV reports. With case-folding lookup simulated for the volume probe and nested output paths that do not yet exist, main accepted the pair and the PR rejected it before creating either output. These last two cases simulate the relevant filesystem rules. MEASURED with OpenAI Codex and a separate read-only review.
andrew-ai commented 2026-12-01 21:24:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T21:24:15Z.


Native Windows 11 / NTFS, CPython 3.14.0, base 1e3e316c5 versus PR 50e97c193. I ran the actual decoder CLI against an empty synthetic input directory with two report destinations. I checked filesystem identity separately by creating the first spelling and looking up the second. No path functions were mocked.

The Deseret pair U+10400 / U+10428 (each followed by .txt) demonstrates the improvement on this volume. Python's normcase maps the names together, but NTFS lets both exist as distinct files.

Destination state Base PR
Both distinct Deseret files already exist Refuses the pair Writes both reports; JSON parses
Neither Deseret file exists yet Refuses the pair Still refuses the pair
Actual NTFS aliases, ASCII A/a or U+2C62/U+026B Refuses Refuses
Output is a hard link to the input Refuses and preserves input bytes Same

The remaining refusal for new Deseret files is a conservative false positive shared with base. The change fixes the existing-file case on a real volume. Coordination claim. AI-assisted with OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326200481 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949#issuecomment-7326200481). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T21:24:15Z. --- Native Windows 11 / NTFS, CPython 3.14.0, base `1e3e316c5` versus PR `50e97c193`. I ran the actual decoder CLI against an empty synthetic input directory with two report destinations. I checked filesystem identity separately by creating the first spelling and looking up the second. No path functions were mocked. The Deseret pair **U+10400 / U+10428** (each followed by `.txt`) demonstrates the improvement on this volume. Python's `normcase` maps the names together, but NTFS lets both exist as distinct files. | Destination state | Base | PR | | --- | --- | --- | | Both distinct Deseret files already exist | Refuses the pair | Writes both reports; JSON parses | | Neither Deseret file exists yet | Refuses the pair | Still refuses the pair | | Actual NTFS aliases, ASCII A/a or U+2C62/U+026B | Refuses | Refuses | | Output is a hard link to the input | Refuses and preserves input bytes | Same | The remaining refusal for new Deseret files is a conservative false positive shared with base. The change fixes the existing-file case on a real volume. [Coordination claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7326157303). AI-assisted with OpenAI Codex (GPT-6).
KelboLive commented 2026-12-01 21:38:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T21:38:06Z.

Review: COMMENTED


LGTM on the code: navmesh_decode now re-exports the shared guard (tools/navmesh_decode.py:59), and the shared implementation preserves the old macOS _PC_CASE_SENSITIVE/NFD behaviour while adding the folding-volume probe and the case-sensitive-Windows handling. I found no case where the removed guard returned True and the shared one returns False; the only divergence is two distinct files in a case-sensitive Windows directory, which are now correctly allowed, not an overwrite risk.

Tests are effective: test_report_paths 26/0, test_report_path_case, and all the navmesh suites pass; reverting the tool fails 3 tests, and stubbing the shared guard to plain realpath equality fails 6.

One wording issue: this is the last entry in LEGACY_COPIES, but not the last legacy copy repo-wide — tools/bvh_index.py:476-509 still has the identical _case_insensitive_volume/_path_key/same_output_path guard (same macOS logic, same gap on a Linux case-folding mount), and tools/text_tables.py:466-472 is the open #2741. The body is correctly scoped ("the last tool in LEGACY_COPIES"), but the title and the comment at tests/test_report_paths.py:27 ("No tool carries its own copy any more") overstate it.

Please scope those two to same_report_path-named copies, or file a bvh_index follow-up. Merge is clean against current main; the textual overlap with #2741 means whichever lands second should rebase.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6140607667 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949#pullrequestreview-6140607667). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T21:38:06Z. **Review:** COMMENTED --- LGTM on the code: `navmesh_decode` now re-exports the shared guard (`tools/navmesh_decode.py:59`), and the shared implementation preserves the old macOS `_PC_CASE_SENSITIVE`/NFD behaviour while adding the folding-volume probe and the case-sensitive-Windows handling. I found no case where the removed guard returned True and the shared one returns False; the only divergence is two distinct files in a case-sensitive Windows directory, which are now correctly allowed, not an overwrite risk. Tests are effective: `test_report_paths` 26/0, `test_report_path_case`, and all the navmesh suites pass; reverting the tool fails 3 tests, and stubbing the shared guard to plain `realpath` equality fails 6. One wording issue: this is the last entry in `LEGACY_COPIES`, but **not the last legacy copy repo-wide** — `tools/bvh_index.py:476-509` still has the identical `_case_insensitive_volume`/`_path_key`/`same_output_path` guard (same macOS logic, same gap on a Linux case-folding mount), and `tools/text_tables.py:466-472` is the open #2741. The body is correctly scoped ("the last tool in `LEGACY_COPIES`"), but the title and the comment at `tests/test_report_paths.py:27` ("No tool carries its own copy any more") overstate it. Please scope those two to `same_report_path`-named copies, or file a `bvh_index` follow-up. Merge is clean against current main; the textual overlap with #2741 means whichever lands second should rebase.
aslan2142 commented 2026-12-02 05:10:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-02T05:10:49Z.


Thank you for putting this together @erdemcisse! navmesh_decode was already covered by earlier PR #1243 (by @breachato), which just landed on main as part of batch PR #3024 (commit 4dfd90c35), clearing LEGACY_COPIES to set(). Closing this as superseded — really appreciate the help keeping tests/test_report_paths.py clean!

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7335663817 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949#issuecomment-7335663817). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-02T05:10:49Z. --- Thank you for putting this together @erdemcisse! `navmesh_decode` was already covered by earlier PR #1243 (by @breachato), which just landed on `main` as part of batch PR #3024 (commit `4dfd90c35`), clearing `LEGACY_COPIES` to `set()`. Closing this as superseded — really appreciate the help keeping `tests/test_report_paths.py` clean!
erdemcisse commented 2026-12-02 18:19:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by erdemcisse on 2026-12-02T18:19:57Z.


Main has since settled the point the review raised. Batch #3024 (4dfd90c35) converted both tools named there: on main, tools/bvh_index.py:477-481 keeps the name same_output_path but delegates to same_report_path, and tools/text_tables.py:64 imports the shared guard directly. tests/test_report_paths.py now carries LEGACY_COPIES = set() with both tools in SHARED, so the sentence the review called overstated ("No tool carries its own copy any more") holds as written and there is no bvh_index follow-up to file. Nothing further is needed from this branch; thank you for the review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354387821 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2949#issuecomment-7354387821). Originally posted by [erdemcisse](https://github.com/erdemcisse) on 2026-12-02T18:19:57Z. --- Main has since settled the point the review raised. Batch #3024 (`4dfd90c35`) converted both tools named there: on `main`, `tools/bvh_index.py:477-481` keeps the name `same_output_path` but delegates to `same_report_path`, and `tools/text_tables.py:64` imports the shared guard directly. `tests/test_report_paths.py` now carries `LEGACY_COPIES = set()` with both tools in `SHARED`, so the sentence the review called overstated ("No tool carries its own copy any more") holds as written and there is no `bvh_index` follow-up to file. Nothing further is needed from this branch; thank you for the review.

Pull request closed

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!2949
No description provided.