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

Open
github-bot wants to merge 1 commit from github-bot/gh-2371 into main AGit
Owner

@⁠syfyra on GitHub · 2026-11-26 16:20 UTC · original
syfyra:fix/page-index-directory-not-continuation → main · +39 −14 · 2 files · 1 commits · draft

Claimed in the coordination issue as: PAGE-INDEX-DIRECTORY-NOT-CONTINUATION (#1608)

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

**@⁠syfyra** on GitHub · 2026-11-26 16:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2371) `syfyra:fix/page-index-directory-not-continuation` → `main` · +39 −14 · 2 files · 1 commits · draft Claimed in the coordination issue as: PAGE-INDEX-DIRECTORY-NOT-CONTINUATION (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### 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)
index_streams appended the next stream to a waiting page's continuations
before asking whether that stream is a directory page of its own. When
the waiting page needed only a few more bytes, the next 0DRP page
covered them: the waiting page was reported complete with the new
page's header as its record's payload, and the new page was never
indexed. When the waiting page stayed incomplete, the new page was still
listed among its continuations and its resource streams.

docs/page_directory.md measured that no continuation stream is a 0DRP
page ("a resource extends forward by payload, not by nesting another
directory"), and tools/navmesh_nodes.py already stops a resource at a
stream that opens one of its own. Check is_page before appending: the
waiting page is reported as parsed with the continuations it had, and
the stream is indexed as the new page.

Tested: new test_a_directory_page_is_not_taken_as_a_continuation_even_
when_it_would_complete_one (fails before: one page instead of two); the
existing test of a new page after a continuation now expects the first
page's one continuation instead of both streams (renamed accordingly).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:23:15 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2371/head:github-bot/gh-2371'
git switch 'github-bot/gh-2371'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2371'
git switch 'github-bot/gh-2371'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2371'
git switch 'github-bot/gh-2371'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2371'
git switch 'main'
git merge --squash 'github-bot/gh-2371'
git switch 'main'
git merge --ff-only 'github-bot/gh-2371'
git switch 'main'
git merge 'github-bot/gh-2371'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.