Commit Graph

34 Commits

Author SHA1 Message Date
070f9521bd bvh_index: require 208-byte head and mark truncated heads (BUILD-1533) 2026-11-25 13:56:02 +05:00
e6686e012c bvh_index: refuse only a report inside the folder the check cannot list
Any other unlistable folder is left to the scan, which names it and exits 1
with an incomplete report, so a second run is no longer refused just because
the first one wrote the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:35:54 -03:00
721341dc53 Merge main into fix/walk-bvh_index
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:35:34 -03:00
7f2f626ed0 bvh_index: name an unreadable target once, not through the OSError text (EGEN-BVHINDEX-MISSING-NAME) (#6699)
Squash-merged after diff review of PR #6699 - bvh_index: name an unreadable target once, not through the OSError text (EGEN-BVHINDEX-MISSING-NAME)
2026-11-23 10:03:59 -06:00
c8f2639171 bvh_index: a sub-folder the report check cannot list is an error, not a silent skip (BUILD-1374)
When --out or --csv names an existing file and the target is a folder,
main() walks the folder to make sure the report would not overwrite an
input. That os.walk had no onerror, so a sub-folder it could not list
was skipped and the check passed without having looked inside it: a
report file in that folder could be overwritten.

This is a safety check, so a folder it cannot list is an error: the
walk's onerror calls ap.error, which names the flag and the folder and
exits 2 before anything is written, like the other "would overwrite"
refusals. The scan itself (scan_dir, glob on main) is left to #4431,
which turns it into an os.walk whose unlistable folders are logged and
make the run exit 1 as incomplete.

The test forces os.scandir to raise PermissionError for one sub-folder
(chmod cannot lock a folder on Windows) and checks the exit code, the
folder in the message and that the existing report is untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:33:00 -03:00
923c3a8714 Merge pull request #4556 from sh1shu1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:53 -05: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
54b42ee3e0 Merge pull request #4431 from tedin7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:40 -05:00
4b865804d6 bvh_index: check the report paths before the scan and turn write errors into exit 2 (BUILD-454)
The overwrite refusals (source archive, carve manifest, input files, a folder as destination, --out equal to --csv)
were already in place. What remained of BUILD-454: a report path under a file or in a folder that can't be written
ended the run in a NotADirectoryError or PermissionError traceback, after the whole scan. report_path_problem()
now creates and probes each report's folder before scanning and argparse refuses the path with the reason; an
OSError while writing after the scan (a full disk, a folder removed since) is one stderr line and exit 2, and the
atomic publish still leaves no partial file. Two tests: a destination under a file is refused before scan_dir is
called; a write failure after the scan returns 2 with the message and no report. Both fail on main.

AI-assisted (Claude Code, Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
2026-11-23 03:00:52 +01: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
59c3a1fc69 fix: bvh_index finds archives with os.walk so an unlistable sub-folder makes the run exit 1 (review) 2026-11-23 02:50:30 +01:00
b65bf4a03c bvh_index: a folder scan that skipped an archive exits 1, not 0 2026-11-23 02:24:42 +01:00
e49775e742 Merge pull request #3099 from kapitche 2026-11-22 17:00:36 -05:00
9b7f4f2829 Merge pull request #3181 from Leo Leahy 2026-11-22 15:15:29 -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
44daebd5fd bvh_index: parse XML root past encoding headers 2026-11-22 17:06:21 -03:00
50d5736032 Merge pull request #2684 from tikD1337 2026-11-22 13:17:04 -05:00
87f3b53036 Merge pull request #2468 from bbareth 2026-11-22 13:15:31 -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
d9bdad3786 fix(tools): omit fill counts for incomplete carved BVH nodes
Archive scans only report fill for complete node buffers. Carved chunks exposed header metadata but recorded partial fill counts, so the same data produced different measurements.
2026-11-22 17:43:46 +01:00
8987f3bd4d bvh_index.py: flatten per-archive summaries in scan_dir() 2026-11-22 16:29:59 +01:00
736f9d6ebd bink_index, bvh_index: report paths cannot replace carve inputs
With a carve directory as the target, --out (and bvh_index's --csv) could
replace <dir>/index.json (or a carved payload through a hard link) and
exit 0; #1264 only compared the report with the target path itself, which
covers an .rpf target but not a directory. bvh_index also lost the report
to a FileNotFoundError in a missing folder, and ended in a PermissionError
traceback when the report path was an existing directory.

Refuse report paths that resolve to the carve manifest or an input file,
create the report folder before writing, and reject a directory report
path; tests cover each shape on synthetic fixtures.
2026-11-22 19:12:17 +08:00
7fceb64ed4 Merge pull request #1137 from Tayar 2026-11-22 02:47:53 -05:00
193add486e bvh_index: reject colliding report destinations 2026-11-22 04:28:04 -03:00
1275714a1e Tests: four tool tests stop printing JSON summaries into the test log
test_world_census, test_bvh_index, test_world_index and
test_audit_shader4_regs call the tools' main(), which prints a JSON summary
or report; run as scripts (as CI does) that is about 280 lines of noise
around the results. A setUpModule per file redirects stdout; the tests that
check the output already redirect it themselves.
2026-11-22 12:40:15 +05:30
799069f9d1 bvh_index.py: a fill histogram only when every node byte was inflated
scan_rpf() built the fill histogram when the declared node bytes fit in the
stream's full size, but it only has the bytes it kept under --max-inflate. A
capped stream gave {'total': 0}, which looks like a BVH with no filled nodes.
The histogram now needs the declared bytes to be in what was kept; a capped
stream has no fill key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:35:29 +01:00
c73379d0fc Merge pull request #498 from Tomgamer 2026-11-21 19:43:47 -05:00
ce37e3c9b5 bvh/page/story_index: pass --max-inflate to directory scans, reject --start/--limit for a directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:08:28 +01:00
7b6139cdff Report invalid BVH roots and clarify index output 2026-11-21 23:46:04 +00:00
2a122c7cbc Cite BVH4 header source and report version field 2026-11-21 23:21:07 +00:00
eb629d41a8 Decode BVH4 header and node pointer fields
The indexer treated the pre-header wrapper words as the root and labelled the real header fields as counts. Parse the documented XboxBvh4Header fields, decode root node pointers, and document the runtime node and leaf layouts while keeping the dehydrated packed stream open.
2026-11-21 22:55:52 +00: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
1681676f5a Docs: measured BVH archive composition
Index the three *_bvh4 RPF9 packs with the fixed carver and record the measured stream/byte composition. Add tools/bvh_index.py for the 0x81020006 header family (tag + 0x140 + 64*n == end), with synthetic tests. No game data, keys or carved payloads are included.
2026-11-21 19:19:53 +00:00