Commit Graph

19 Commits

Author SHA1 Message Date
1c194ebe8e Merge pull request #2371 from syfyra/fix/page-index-directory-not-continuation
page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION)
2026-12-01 16:21:21 +01:00
a53be6d9b0 Merge pull request #2373 from syfyra/fix/page-index-tiny-continuation
page_index: take a continuation shorter than 64 bytes (PAGE-INDEX-TINY-CONTINUATION)
2026-12-01 16:20:45 +01:00
a05681d111 page_index: take a continuation shorter than 64 bytes (PAGE-INDEX-TINY-CONTINUATION)
scan_rpf dropped every zlib stream that inflates to fewer than 64 bytes,
the carver's cutoff. A page whose table or last record runs a few bytes
past its stream can be continued by such a stream: docs/navmesh.md
recovers 10 continuations of 16-48 bytes in navmeshes.rpf, 3 of them
0DRP pages'. page_index skipped the short stream and took the next one
in its place, so the page was reported complete with an unrelated
stream's bytes as its continuation and record payload.

Yield short streams too and take one only while a page waits for a
continuation, as tools/navmesh_decode.py does; on its own a short stream
is neither a page (the header alone is 0x60 bytes) nor counted in
"streams", so archives without such streams report exactly as before.
A carved directory holds no short streams, so its mode is unchanged.

Tested: new test_a_continuation_under_64_bytes_is_taken_only_as_one
(fails before: the 256-byte stream after the 40-byte one is taken).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:23:56 +01:00
80c6f3041d page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION)
index_streams appended the next stream to a waiting page's continuations
before asking whether that stream is a directory page of its own. When
the waiting page needed only a few more bytes, the next 0DRP page
covered them: the waiting page was reported complete with the new
page's header as its record's payload, and the new page was never
indexed. When the waiting page stayed incomplete, the new page was still
listed among its continuations and its resource streams.

docs/page_directory.md measured that no continuation stream is a 0DRP
page ("a resource extends forward by payload, not by nesting another
directory"), and tools/navmesh_nodes.py already stops a resource at a
stream that opens one of its own. Check is_page before appending: the
waiting page is reported as parsed with the continuations it had, and
the stream is indexed as the new page.

Tested: new test_a_directory_page_is_not_taken_as_a_continuation_even_
when_it_would_complete_one (fails before: one page instead of two); the
existing test of a new page after a continuation now expects the first
page's one continuation instead of both streams (renamed accordingly).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:18:58 +01:00
83f4e8a984 page_index: handle mixed None/int versions, guard scan_rpf limit and listdir errors, and write JSON/CSV atomically 2026-11-25 05:42:21 +01:00
94cb323d46 Merge pull request #3156 from Tayar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:51 -05:00
0455bed876 Reserve the carve manifest path for page and story indexes 2026-11-22 19:15:38 -03:00
d3926922ba Merge pull request #3516 from Kam471 2026-11-22 17:02:26 -05:00
ad600c89d4 page_index: name a page that declares q28 records without a table pointer
Review of #3388: with n28 > 0 and a +0x28 word that is not a
0x50000000 pointer, _q28 still returned ([], ""), so q28_declared could
exceed q28_records with no q28_error. It now says "q28 is not a
0x50000000 pointer". No page of data.rpf, navmeshes.rpf or anim.rpf has
that shape (all 48,194 have a q28 pointer).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:05:27 +00:00
633e5fda58 page_index: count page counts in one pass 2026-11-22 20:44:02 +00:00
575a49b029 page_index: keep q28 records after a null pointer; whole-archive counts for page_directory.md
_q28 stopped a +0x28 table at the first record whose pointer is not
0x50000000-based. Over all of anim.rpf that is a zero pointer on 3,672
records (3,511 of 22,823 pages), and 116,277 ordinary records after them
were left out of the report. Such a record is now kept with target null
and the table is read on; any other non-base pointer still ends it.

A q28 table that ends past the streams read for q38 (1,355 anim.rpf,
225 navmeshes.rpf, 1 data.rpf pages) came back empty with no reason; it
now says so in q28_error. The summary gains q28_declared,
q28_null_targets and q28_tables_unread.

docs/page_directory.md: navmeshes.rpf and anim.rpf read to the end
(9,603 and 22,823 pages) next to the 64 MiB / 256 MiB samples, with the
header ranges and the two q28 statements the samples did not show.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 20:22:59 +00:00
e73aaca078 page_index: report 0DRP resource groups and the +0x20 disagreement (ASSET-150)
The +0x20 count is the only field that looked like a grouping unit, so it was tested against
every stream boundary reading on story000.rpf before being used: a directory is followed by one
non-directory stream in 16,128 of 16,977 cases regardless of the count, and the best page-size
reading matches 9,622 pages (56.7%). The boundary comes from the q38 table, so each page now
reports the streams that make up its resource and whether the declared count agrees with the
64 KiB units they occupy.
2026-11-22 16:40:07 +00:00
c0ac6f3332 page_index.py: refuse report paths that overwrite source archives or carved inputs 2026-11-22 16:28:46 +05:30
a81c92abd7 page_index: report output write failures 2026-11-22 04:43:22 -03:00
962257ca31 page_index.py: bound --limit scans to the requested window and validate output path 2026-11-22 07:08:11 +01:00
3eb5f8656b BUILD: keep the re-parsed page when a new page follows a continuation 2026-11-21 19:51:37 -06: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
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
950e599577 Docs: decode the RPF9 0DRP page directory
Measure the 0x60-byte header, the +0x38 table of {hash,size,pointer} resource records, and continuation streams. Correct the +0x60 key claim: it is payload on 29,297 of 29,298 pages. Add a stdlib page indexer with synthetic tests.
2026-11-21 19:56:46 +00:00