page_index: take a continuation shorter than 64 bytes (PAGE-INDEX-TINY-CONTINUATION) #2373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2373"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.pyreads the RPF9 data area as a sequence of zlib streams, andscan_rpfdropped 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.mdrecovers 10 continuations of 16-48 bytes innavmeshes.rpf, 3 of them0DRPpages', andtools/navmesh_decode.pyaccepts 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_streamand 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_rpfnow yields short streams too, andindex_streamstakes one only while a page waits for a continuation, asnavmesh_decode.pydoes. On its own a short stream is never a page (the header alone is 0x60 bytes) and is not counted insummary.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.pypasses.Tested
Windows 11, Python 3.14.7, synthetic RPF streams only:
python -I tests/test_page_index.py: 22 tests OK. Newtest_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_stream1, span 0x120 andstreams2. Onmainit fails with the 0x100-byte stream reported as the continuation.tests/test_csv_line_endings.pyOK;python -m compileall;scripts/check_no_game_data.pyon 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
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 thanMIN_STREAM = 64bytes whenwaiting is not Noneintools/page_index.py:50,122,306-312looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green.(AI-assisted review.)
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.)
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 intools/page_index.py:50,122,306-312with tests intests/test_page_index.pyis clean and focused. (Note:#2371also editstools/page_index.py, so recheck mergeability after whichever lands first.)Approving — ready to merge once CI runs green on current
main.(AI-assisted review.)
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:57:38Z.
Combined #2373 and #2371 in both orders on
9f27ba2e(this heada05681d1). Both merges produced tree8b14b141and 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).mainmakes one callback. The short fragments do not increment the count, but they reach the modulo check. Moving that check into the branch that incrementsstreams_seenrestored 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).