[PR #2371] page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION) #2374

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/2371
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/page-index-directory-not-continuation


📝 Commits (1)

  • 80c6f30 page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION)

📊 Changes

2 files changed (+39 additions, -14 deletions)

View changed files

📝 tests/test_page_index.py (+29 -4)
📝 tools/page_index.py (+10 -10)

📄 Description

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.py follows a 0DRP page whose q38 table or last record runs past its zlib stream into the next stream(s). index_streams appended 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:

  • When the waiting page needed only a few more bytes, a following directory page covered them. The waiting page was reported complete, with the new page's header read as its record's payload, and the new page was never indexed (synthetic case: page A's last record runs 0x10 bytes past its 0x100-byte stream, page B follows → 1 page reported instead of 2).
  • When the waiting page stayed incomplete, the new page was reported correctly but was still listed among the waiting page's continuations and resource streams (added by 3eb5f8656 to keep "the last continuation", which in that branch is always the new page).

docs/page_directory.md measured that no continuation stream is a 0DRP page: "A resource therefore extends forward by payload, not by nesting another directory." tools/navmesh_nodes.py already stops a resource at a stream that opens one of its own. index_streams now checks is_page before appending. The waiting page is reported as parsed with the continuations it really had (the tuple in waiting always holds that parse) and marked resource 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. New test_a_directory_page_is_not_taken_as_a_continuation_even_when_it_would_complete_one: on main it 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 existing test_new_page_after_a_continuation_is_reported_with_both_streams asserted the second page among the first page's continuations. It is renamed ..._ends_the_previous_resource and 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.py fails here on main too, in an unrelated Windows path assertion.
  • python -m compileall; scripts/check_no_game_data.py on 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

  • 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/2371 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/page-index-directory-not-continuation` --- ### 📝 Commits (1) - [`80c6f30`](https://github.com/ubiquitarianism/leonida/commit/80c6f3041d19b95dc664443bf4327f97fbe1dcab) page_index: a directory page is never a continuation (PAGE-INDEX-DIRECTORY-NOT-CONTINUATION) ### 📊 Changes **2 files changed** (+39 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_page_index.py` (+29 -4) 📝 `tools/page_index.py` (+10 -10) </details> ### 📄 Description 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.py` follows a `0DRP` page whose `q38` table or last record runs past its zlib stream into the next stream(s). `index_streams` appended 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: - **When the waiting page needed only a few more bytes**, a following directory page covered them. The waiting page was reported **complete**, with the new page's header read as its record's payload, and the new page **was never indexed** (synthetic case: page A's last record runs 0x10 bytes past its 0x100-byte stream, page B follows → 1 page reported instead of 2). - **When the waiting page stayed incomplete**, the new page was reported correctly but was still listed among the waiting page's continuations and resource streams (added by 3eb5f8656 to keep "the last continuation", which in that branch is always the new page). `docs/page_directory.md` measured that no continuation stream is a `0DRP` page: "A resource therefore extends forward by payload, not by nesting another directory." `tools/navmesh_nodes.py` already stops a resource at a stream that opens one of its own. `index_streams` now checks `is_page` before appending. The waiting page is reported as parsed with the continuations it really had (the tuple in `waiting` always holds that parse) and marked `resource 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. New `test_a_directory_page_is_not_taken_as_a_continuation_even_when_it_would_complete_one`: on `main` it 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 existing `test_new_page_after_a_continuation_is_reported_with_both_streams` asserted the second page among the first page's continuations. It is renamed `..._ends_the_previous_resource` and 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.py` fails here on `main` too, in an unrelated Windows path assertion. - `python -m compileall`; `scripts/check_no_game_data.py` on 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 - [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#2374
No description provided.