Commit Graph

26 Commits

Author SHA1 Message Date
6de3ecb759 navmesh_index: report missing input before mode checks, handle write OSError, separate chmod/unlink cleanup, and align pattern matching 2026-11-25 19:45:23 +08:00
103e464415 navmesh_index: count each path once for recursive globs (#6890)
Squash-merged after diff review of PR #6890 - navmesh_index: count each path once for recursive globs
2026-11-23 09:45:34 -06:00
2dd8795ad8 navmesh_index/world_lights_paths input guards; bcpack_tool in docs; design.md f16-interp row (#6916)
Squash-merged after diff review of PR #6916 - navmesh_index/world_lights_paths input guards; bcpack_tool in docs; design.md f16-interp row
2026-11-23 09:36:24 -06:00
4c4cb16bbf Merge pull request #4516 from bobcatchris
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:28 -05:00
d79bf5c500 Fix read-only temp cleanup in staged report writers
bvh_index, navmesh_index and rbf0_tree give the staging file the destination mode before os.replace. On Windows a read-only destination makes the replace fail and leaves a temp that cannot be unlinked. Restore 0600 in the failure path before unlink, and add regressions that pin the mode reset, old bytes and no leftovers.
2026-11-22 20:00:30 -06:00
fa33dd1616 Merge pull request #3647 from Kam471 2026-11-22 17:03:11 -05:00
e49775e742 Merge pull request #3099 from kapitche 2026-11-22 17:00:36 -05:00
a3f0a2bb16 Merge pull request #2930 from bobcatchris 2026-11-22 17:00:09 -05:00
d1490e359e BUILD-1046: missing inputs exit 2; image_query_probe help before oracle
Eleven tools treated a nonexistent input folder as a failed run (1). They now print one ERROR line and return 2, while real read failures keep exit 1. image_query_probe imports the hardware oracle only for a GPU run, so --help stays prompt. A table-driven subprocess test covers all eleven; existing expectations are updated.
2026-11-22 21:11:07 +00:00
e5748d7384 Merge pull request #3173 from Marco Luzzaro 2026-11-22 15:15:26 -05:00
eb1724c3e6 navmesh_index, bvh_index: a folder name with glob characters is a path, not a pattern 2026-11-22 15:10:40 -05:00
3e105eba3a navmesh_decode, navmesh_index: a --out that is a folder is a usage error
Both tools validate --out and --csv against the input (they must not overwrite
it) but never against the filesystem object itself, so pointing --out at an
existing directory opened it for writing and ended the run in a
PermissionError traceback after the scan was already done:

    Traceback (most recent call last):
      ...
    PermissionError: [Errno 13] Permission denied: '../reports'

Refuse it up front with the flag name, like the neighbouring checks do, so it
costs one line and the scan never starts.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 14:09:43 -06:00
a90f221a7d Protect navmesh inputs from external report aliases 2026-11-22 20:36:02 +01:00
50d5736032 Merge pull request #2684 from tikD1337 2026-11-22 13:17:04 -05:00
a04ae223aa fix(bvh_index, navmesh_index): stage report writes so failed runs keep existing reports
write_outputs opened the JSON and CSV reports with open(dest, "w"), which empties
the previous report before the new one is serialized: a TypeError in json.dump, a
full disk or Ctrl+C left a truncated file where an intact report used to be.

Each report is now written to a NamedTemporaryFile in the destination folder
(.bvh_index-*.tmp / .navmesh_index-*.tmp), given published_mode(dest) and swapped
in with os.replace. On any exception the staging file is removed and the
existing report is left untouched.

Tests: PublishTest in tests/test_bvh_index.py and tests/test_navmesh_index.py
(JSON serialization failure, CSV write failure, KeyboardInterrupt, published_mode
applied to the staged file, POSIX bits kept). All synthetic, no game data.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:50:54 +01:00
1badfebfd0 navmesh_index and bvh_index: scan literal carve directories 2026-11-22 18:08:48 +01:00
17996480d9 navmesh_index: refuse a report path that is a scanned file under another name
is_scanned_input matched the report path against --pattern with fnmatch,
which folds case only on Windows. On a case-insensitive macOS (or Linux)
volume, `navmesh_index.py carve --out CARVE/PAGE.BIN` found the input
folder through same_report_path but didn't match *.bin, so the report
truncated carve/page.bin and the tool exited 0. A hard link inside the
input folder did the same on any filesystem, since the report is opened
in place.

When the pattern doesn't match the spelling, ask the scan's own glob
whether any file it reads is the report path (same_report_path). The new
test uses a hard link so it runs on the Linux and Windows CI runners,
where the case test skips or already passes.

AI-assisted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 14:25:03 +01:00
751a8f166a navmesh_index: refuse a differently-cased report path inside the input folder
is_scanned_input compared the report's folder with the input folder as plain
strings, so on Windows an --out/--csv spelling that differed only in case
(C:\...\CARVE\page.bin for an input C:\...\carve) passed the guard and the
report replaced the carved file. Walk up from the report path and compare
each folder with same_report_path (normcase, realpath, samefile) instead.

BUILD-448.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:21:13 +01:00
9209eb649d navmesh_index: refuse a report path that is a scanned input
`--out`/`--csv` naming one of the carved files (or the archive) the scan
reads replaced that file with the JSON/CSV report, exit 0, no warning.
Check both report paths against the scanned set before anything is read.
2026-11-22 03:40:59 -06:00
c4d7584700 navmesh_index: reject colliding JSON and CSV output paths
Claim: https://github.com/ItsNotRexed/Leonida/issues/1218#issuecomment-7076683293

AI-assisted with GPT-6.2 Astra
2026-11-22 16:48:52 +08:00
18038667a8 navmesh_index: create the --out and --csv folders instead of losing the run
write_outputs opened both paths directly, so naming a file in a folder that
does not exist ended a completed scan in a FileNotFoundError traceback: the
index was lost after the whole archive had been walked. Create each output's
parent folder first, as the hashdict/feature_scan fixes do.

Tests: a folder with one synthetic page, with --out and --csv both under
missing nested folders, must exit 0 and write both files. Negative control on
main: that case fails; with the change 13/13 pass.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:44:11 -06:00
2e55bdc05e BUILD: bound navmesh_index decompression by the --limit window 2026-11-21 20:41:35 -06:00
05eedea4d3 navmesh_index: validate dir/archive CLI options and close mmap cleanly
Follow-up to #498 for tools/navmesh_index.py (refs #374):
- Reject --start and --limit when input is a directory (exit code 2, before scanning or writing output).
- Default --pattern to None (resolving to *.bin in scan_directory) and reject explicit --pattern in archive mode (exit code 2, before opening or scanning).
- Wrap mmap.mmap in scan_archive with a context manager so the mapping is closed on both normal return and SystemExit.
- Add unit tests covering directory/archive option validation and mmap cleanup.
2026-11-22 00:26:48 +00:00
eed95e207b navmesh_index.py: report a missing input instead of a traceback
A path that is neither a folder nor a readable file reached open() and stopped with FileNotFoundError. It now
exits 1 with "<path>: No such file or directory", like the existing "not an RPF7/8/9 archive" message.

Tests: MissingInputTest in tests/test_navmesh_index.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:36:39 +03:00
76b7b5b329 Index tools: refuse --limit/--start values that scan nothing, survive empty archives
bvh_index, page_index, story_index, navmesh_index and psin_index:

- --limit 0 meant "no limit" (0 is falsy) and a negative --limit scanned
  nothing and still exited 0 with an empty index. --limit must now be at
  least 1 and --start 0 or more; argparse rejects anything else (rc 2).
- An empty .rpf crashed in mmap ("cannot mmap an empty file") and a file
  shorter than the header word crashed in struct.unpack_from. bvh, page and
  story now treat both as an archive with no streams.
- bvh_index directory mode: one bad archive no longer aborts the scan and
  loses the results of the others; it is reported and skipped.
- A --start past the end of the archive is a one-line error (rc 2) instead
  of a traceback (bvh also checked nothing and reported a negative span).
- page_index checks the output extension before the scan, not after it.

Docs: the accepted ranges and the empty-archive behaviour are written next
to each tool's usage in docs/{bvh,navmesh,page_directory,psin,story}.md.

Tests: synthetic cases for each tool; they fail on main and pass here.
2026-11-21 23:21:29 +01:00
7f993ac8b4 docs: measured navmesh archive composition
Full RPF9 stream index of navmeshes.rpf (90,295 streams), the measured 0DRP directory-page layout, rejected AABB/NVMS pseudo-magics, and data/levels cross-check counts. Adds a stdlib navmesh_index.py and synthetic tests; no game data.
2026-11-21 19:06:01 +00:00