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

Merged
syfyra merged 1 commit from upstream-pr/2373 into main 2026-12-01 15:20:45 +00:00
syfyra commented 2026-11-26 16:25:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T16:25:48Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5513640028 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2373). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T16:25:48Z. --- 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)
aslan2142 commented 2026-12-01 12:03:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:03:03Z.

Review: COMMENTED


Draft review against current main: allowing inflated continuations shorter than MIN_STREAM = 64 bytes when waiting is not None in tools/page_index.py:50,122,306-312 looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130893611 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2373#pullrequestreview-6130893611). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:03:03Z. **Review:** COMMENTED --- Draft review against current `main`: allowing inflated continuations shorter than `MIN_STREAM = 64` bytes when `waiting is not None` in `tools/page_index.py:50,122,306-312` looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:32:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:32:53Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311291340 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2373#issuecomment-7311291340). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:32:53Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 13:06:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T13:06:32Z.

Review: APPROVED


Now ready for review and MERGEABLE. Clean-room verified: accepting < 64-byte continuations in tools/page_index.py:50,122,306-312 with tests in tests/test_page_index.py is clean and focused. (Note: #2371 also edits tools/page_index.py, so recheck mergeability after whichever lands first.)

Approving — ready to merge once CI runs green on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131832836 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2373#pullrequestreview-6131832836). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T13:06:32Z. **Review:** APPROVED --- Now ready for review and `MERGEABLE`. Clean-room verified: accepting `< 64`-byte continuations in `tools/page_index.py:50,122,306-312` with tests in `tests/test_page_index.py` is clean and focused. (Note: `#2371` also edits `tools/page_index.py`, so recheck mergeability after whichever lands first.) Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
merzleckeier commented 2026-12-01 13:57:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:57:38Z.


Combined #2373 and #2371 in both orders on 9f27ba2e (this head a05681d1). Both merges produced tree 8b14b141 and passed all 27 page-index tests. A synthetic archive with two short fragments followed by a new directory indexed the new directory separately and kept both fragments on the unfinished first page only with both PRs applied.

There is a small progress-report regression in index_streams. When the 2,000th counted stream is a page still waiting for its payload, two following short continuations cause three identical progress callbacks at (2000, 0). main makes one callback. The short fragments do not increment the count, but they reach the modulo check. Moving that check into the branch that increments streams_seen restored one callback. All 27 tests and the combined archive probe still pass with that local change. The fix is also independent of #2371.

MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313464741 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2373#issuecomment-7313464741). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T13:57:38Z. --- Combined #2373 and #2371 in both orders on `9f27ba2e` (this head `a05681d1`). Both merges produced tree `8b14b141` and passed all 27 page-index tests. A synthetic archive with two short fragments followed by a new directory indexed the new directory separately and kept both fragments on the unfinished first page only with both PRs applied. There is a small progress-report regression in `index_streams`. When the 2,000th counted stream is a page still waiting for its payload, two following short continuations cause three identical progress callbacks at `(2000, 0)`. `main` makes one callback. The short fragments do not increment the count, but they reach the modulo check. Moving that check into the branch that increments `streams_seen` restored one callback. All 27 tests and the combined archive probe still pass with that local change. The fix is also independent of #2371. MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2373
No description provided.