page_index: take a continuation shorter than 64 bytes (PAGE-INDEX-TINY-CONTINUATION) #2373

Open
github-bot wants to merge 1 commit from github-bot/gh-2373 into main AGit
Owner

@⁠syfyra on GitHub · 2026-11-26 16:25 UTC · original
syfyra:fix/page-index-tiny-continuation → main · +33 −2 · 2 files · 1 commits · draft

Claimed in the coordination issue as: PAGE-INDEX-TINY-CONTINUATION (#1608)

What and why

tools/page_index.py reads the RPF9 data area as a sequence of zlib streams, and scan_rpf dropped every stream that inflates to fewer than 64 bytes (the carver's cutoff). Such a stream can be exactly the continuation a page needs: docs/navmesh.md recovers 10 continuations of 16-48 bytes in navmeshes.rpf, 3 of them 0DRP pages', and tools/navmesh_decode.py accepts short streams "strictly as continuations" for that reason.

page_index skipped the short stream and took the next stream as the continuation instead. The page was reported complete, with that unrelated stream's bytes as its continuation, its target_stream and its record payload. Synthetic case: a page whose last record runs 0x20 bytes past its stream, then a 0x28-byte stream, then an unrelated 0x100-byte stream → the 0x100-byte stream was reported as the continuation.

scan_rpf now yields short streams too, and index_streams takes one only while a page waits for a continuation, as navmesh_decode.py does. On its own a short stream is never a page (the header alone is 0x60 bytes) and is not counted in summary.streams, so an archive without short streams reports exactly as before. A carved directory holds no short streams (the carver drops them), so that mode is unchanged. The docstring says so.

This merges cleanly with my #2371 (same loop, a directory page is never a continuation) and with #1566; with #2371 merged in, tests/test_page_index.py passes.

Tested

Windows 11, Python 3.14.7, synthetic RPF streams only:

  • python -I tests/test_page_index.py: 22 tests OK. New test_a_continuation_under_64_bytes_is_taken_only_as_one: a 0x20-byte stream before the page (skipped, not counted), the page, a 0x28-byte continuation and a 0x100-byte stream. It expects the 0x28-byte continuation, target_stream 1, span 0x120 and streams 2. On main it fails with the 0x100-byte stream reported as the continuation.
  • tests/test_csv_line_endings.py OK; python -m compileall; scripts/check_no_game_data.py on both files.

Not measured: the effect on a real navmeshes.rpf (no game files here); the expected change is that the 3 pages docs/navmesh.md names get their own short continuation.

GPUs tested: n/a (CPU-only tool)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠syfyra** on GitHub · 2026-11-26 16:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2373) `syfyra:fix/page-index-tiny-continuation` → `main` · +33 −2 · 2 files · 1 commits · draft Claimed in the coordination issue as: PAGE-INDEX-TINY-CONTINUATION (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `tools/page_index.py` reads the RPF9 data area as a sequence of zlib streams, and `scan_rpf` dropped every stream that inflates to fewer than 64 bytes (the carver's cutoff). Such a stream can be exactly the continuation a page needs: `docs/navmesh.md` recovers **10** continuations of 16-48 bytes in `navmeshes.rpf`, **3** of them `0DRP` pages', and `tools/navmesh_decode.py` accepts short streams "strictly as continuations" for that reason. page_index skipped the short stream and took the **next** stream as the continuation instead. The page was reported complete, with that unrelated stream's bytes as its continuation, its `target_stream` and its record payload. Synthetic case: a page whose last record runs 0x20 bytes past its stream, then a 0x28-byte stream, then an unrelated 0x100-byte stream → the 0x100-byte stream was reported as the continuation. `scan_rpf` now yields short streams too, and `index_streams` takes one only while a page waits for a continuation, as `navmesh_decode.py` does. On its own a short stream is never a page (the header alone is 0x60 bytes) and is not counted in `summary.streams`, so an archive without short streams reports exactly as before. A carved directory holds no short streams (the carver drops them), so that mode is unchanged. The docstring says so. This merges cleanly with my #2371 (same loop, a directory page is never a continuation) and with #1566; with #2371 merged in, `tests/test_page_index.py` passes. ### Tested Windows 11, Python 3.14.7, synthetic RPF streams only: - `python -I tests/test_page_index.py`: 22 tests OK. New `test_a_continuation_under_64_bytes_is_taken_only_as_one`: a 0x20-byte stream before the page (skipped, not counted), the page, a 0x28-byte continuation and a 0x100-byte stream. It expects the 0x28-byte continuation, `target_stream` 1, span 0x120 and `streams` 2. On `main` it fails with the 0x100-byte stream reported as the continuation. - `tests/test_csv_line_endings.py` OK; `python -m compileall`; `scripts/check_no_game_data.py` on both files. Not measured: the effect on a real `navmeshes.rpf` (no game files here); the expected change is that the 3 pages docs/navmesh.md names get their own short continuation. GPUs tested: n/a (CPU-only tool) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:29:03 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2373/head:github-bot/gh-2373'
git switch 'github-bot/gh-2373'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2373'
git switch 'github-bot/gh-2373'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2373'
git switch 'github-bot/gh-2373'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2373'
git switch 'main'
git merge --squash 'github-bot/gh-2373'
git switch 'main'
git merge --ff-only 'github-bot/gh-2373'
git switch 'main'
git merge 'github-bot/gh-2373'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.