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

Open
opened 2026-11-26 21:21:02 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2373
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/page-index-tiny-continuation


📝 Commits (1)

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

📊 Changes

2 files changed (+33 additions, -2 deletions)

View changed files

📝 tests/test_page_index.py (+22 -0)
📝 tools/page_index.py (+11 -2)

📄 Description

Claimed in the coordination issue as: PAGE-INDEX-TINY-CONTINUATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197610793)

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2373 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/page-index-tiny-continuation` --- ### 📝 Commits (1) - [`a05681d`](https://github.com/ubiquitarianism/leonida/commit/a05681d1115824a83b1ae2d0e759cf71b256788b) page_index: take a continuation shorter than 64 bytes (PAGE-INDEX-TINY-CONTINUATION) ### 📊 Changes **2 files changed** (+33 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_page_index.py` (+22 -0) 📝 `tools/page_index.py` (+11 -2) </details> ### 📄 Description Claimed in the coordination issue as: PAGE-INDEX-TINY-CONTINUATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197610793) ### 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2378
No description provided.