Skip to content

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

Open
erdemcisse wants to merge 1 commit into
ProjectLeonida:mainfrom
erdemcisse:chore/navmesh-decode-report-paths
Open

erdemcisse wants to merge 1 commit into
ProjectLeonida:mainfrom
erdemcisse:chore/navmesh-decode-report-paths

Conversation

@erdemcisse

Copy link
Copy Markdown

Claimed in the coordination issue as: REPORT-PATHS-NAVMESH-DECODE — #2570 (comment)

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 text_tables: ask report_paths for the report-path guard #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.

…legacy copy)

The tool carried its own `same_report_path`: normcase(realpath) plus samefile.
That copy is older than the shared one and misses both cases the shared one
grew for -- the volume probe for a case-folding Linux mount (vfat, exFAT, CIFS)
and the case-sensitive-directory check on Windows -- so "--out R.json" and a
carve manifest "r.json" on such a volume went unnoticed and the run overwrote
the manifest. tests/test_report_paths.py named it the one remaining legacy copy
and asked for the import instead.

LEGACY_COPIES is now empty: every tool takes the guard from tools/report_paths.py,
and the identity test covers the re-exported name the siblings import.

Verified: python -I tests/test_report_paths.py (fails on main: navmesh_decode's
same_report_path is not the shared one, and the SHARED scan finds a copy),
tests/test_navmesh_decode.py, test_navmesh_nodes.py, test_navmesh_links.py,
test_navmesh_cell_fit.py, scripts/check_no_game_data.py on both files, and the
docs/hygiene suite (57 tests). No game files, no GPU.
@merzleckeier

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants