page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION) #2371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2371"
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:20:58Z.
Claimed in the coordination issue as: PAGE-INDEX-DIRECTORY-NOT-CONTINUATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197498211)
What and why
tools/page_index.pyfollows a0DRPpage whoseq38table or last record runs past its zlib stream into the next stream(s).index_streamsappended the next stream to the waiting page's continuations before asking whether that stream is a directory page of its own, so the check that exists for exactly this ("treat this stream as the new directory page instead of swallowing it as a continuation") ran too late:3eb5f8656to keep "the last continuation", which in that branch is always the new page).docs/page_directory.mdmeasured that no continuation stream is a0DRPpage: "A resource therefore extends forward by payload, not by nesting another directory."tools/navmesh_nodes.pyalready stops a resource at a stream that opens one of its own.index_streamsnow checksis_pagebefore appending. The waiting page is reported as parsed with the continuations it really had (the tuple inwaitingalways holds that parse) and markedresource ended before q38 was complete, and the stream is indexed as the new page. Archives where every page completes before the next one starts are unchanged.Different topic from #1566 (versions,
--limit, atomic writes), which also edits these files; the two merge cleanly.Tested
Windows 11, Python 3.14.7, synthetic RPF streams only:
python -I tests/test_page_index.py: 22 tests OK. Newtest_a_directory_page_is_not_taken_as_a_continuation_even_when_it_would_complete_one: onmainit gets one page (A complete, B as its continuation); with the fix A is incomplete with no continuation and B is indexed with its record. The existingtest_new_page_after_a_continuation_is_reported_with_both_streamsasserted the second page among the first page's continuations. It is renamed..._ends_the_previous_resourceand now expects the one real continuation and resource streams[page, continuation].tests/test_csv_line_endings.py(imports the tool) OK.tests/test_opus_tags.pyfails here onmaintoo, in an unrelated Windows path assertion.python -m compileall;scripts/check_no_game_data.pyon both files.Not measured: how many pages this recovers on real archives (no game files here). Where the docs' counts were taken, every continuation completed its page before the next page, which is the unchanged path.
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:02:57Z.
Review: COMMENTED
Draft review against current
main: checkingis_page(data)before appending the stream as a continuation intools/page_index.py:308-317cleanly prevents a new directory page from being swallowed by an incomplete preceding resource, with regression tests intests/test_page_index.py. 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:35Z.
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:20Z.
Review: APPROVED
Now ready for review and
MERGEABLE. Clean-room verified: guarding continuation chaining withis_page(data)intools/page_index.py:308-317with tests intests/test_page_index.pyis clean and focused. (Note:#2373also 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:13Z.
I checked this with #2373 in both merge orders on
9f27ba2e(head80c6f304). Both orders produced the same tree (8b14b141) and passed all 27 tests intests/test_page_index.py. The subsequentmainchange through3e7b34a5touches only translator wording and comments.One additional synthetic archive contains an unfinished page, two short continuations (24 and 20 bytes), and a complete directory page. With this PR alone, both pages are reported separately but the short fragments are omitted. With #2373 alone, the short fragments are kept but the second directory is swallowed. With both, the first report keeps both short continuations and remains incomplete, while the second directory is independently indexed as complete. The count of full-sized streams is two in all four cases, including
main.MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).