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