world_archetypes: read a carved resource's continuation file too (WORLD-ARCHETYPES-FOLDER-CONTINUATION) #2382

Merged
leonida/mandy
syfyra merged 1 commit from fix/world-archetypes-folder-continuation into main 2026-12-01 15:21:35 +00:00

Pull request successfully merged and closed

syfyra commented 2026-11-26 16:42:47 +00:00

Claimed in the coordination issue as: WORLD-ARCHETYPES-FOLDER-CONTINUATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197984448)

What and why

tools/world_archetypes.py reads archetype definitions (CMapTypes) and, with --check-extents, map entity blocks, from an RPF9 window, a carved file or a folder of carved streams.

On a folder, iter_resources takes the rows from world_index.scan_path, which joins a 0DRPz resource whose blocks run past its stream with the carved file of the stream that followed it. It finds that file through rpf9_carve's index.json (_carve_successors, as scan_rpf does in an archive). The row then carries the joined length as size but only the first file as file. iter_resources re-read that first file alone, so every block stored in the continuation was lost without a warning:

  • archetype definitions;
  • the map entity blocks --check-extents compares.

The same two streams inside an RPF9 window are joined by WC.assemble and read in full. docs/world_census.md counts 2,868 maps that join a continuation, and a large CMapTypes or interior resource runs past its first stream the same way.

iter_resources now joins the same files: it follows the carve's successors while the data is shorter than the row's size. Single carved files, folders without index.json and resources that fit in one stream read exactly as before.

Different topic from #1555 (identity quaternion, nameless definitions, atomic writes; same files); the two merge cleanly.

Tested

Windows 11, Python 3.14.7, synthetic resources only:

  • python -I tests/test_world_archetypes.py: 20 tests OK. New test_folder_joins_a_continuation_file_as_world_index_does: a carve folder as rpf9_carve writes it (<offset>.bin per stream plus index.json). The CMapTypes resource's last block runs 0x10 bytes into the next stream, and the map file is a separate stream. It asserts that scan_path joins the two (row size = whole resource) and that the CLI then reports the same summary as the RPF9-window test (2 archetypes, extents checked). On main it gets (maptypes, archetypes, names) = (1, 0, 0).
  • A 40-definition resource split the same way gives 0 archetypes from the folder and 40 from the equivalent RPF9 archive on main, and 40 from both with the fix (review repro).
  • python -m compileall; scripts/check_no_game_data.py on both files.

Not measured: how many archetypes this recovers from a real carve (no game files here).

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

Claimed in the coordination issue as: WORLD-ARCHETYPES-FOLDER-CONTINUATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197984448) ### What and why `tools/world_archetypes.py` reads archetype definitions (CMapTypes) and, with `--check-extents`, map entity blocks, from an RPF9 window, a carved file or a folder of carved streams. On a folder, `iter_resources` takes the rows from `world_index.scan_path`, which joins a `0DRPz` resource whose blocks run past its stream with the carved file of the stream that followed it. It finds that file through rpf9_carve's `index.json` (`_carve_successors`, as `scan_rpf` does in an archive). The row then carries the joined length as `size` but only the first file as `file`. `iter_resources` re-read that first file alone, so every block stored in the continuation was lost without a warning: - archetype definitions; - the map entity blocks `--check-extents` compares. The same two streams inside an RPF9 window are joined by `WC.assemble` and read in full. `docs/world_census.md` counts 2,868 maps that join a continuation, and a large CMapTypes or interior resource runs past its first stream the same way. `iter_resources` now joins the same files: it follows the carve's successors while the data is shorter than the row's `size`. Single carved files, folders without `index.json` and resources that fit in one stream read exactly as before. Different topic from #1555 (identity quaternion, nameless definitions, atomic writes; same files); the two merge cleanly. ### Tested Windows 11, Python 3.14.7, synthetic resources only: - `python -I tests/test_world_archetypes.py`: 20 tests OK. New `test_folder_joins_a_continuation_file_as_world_index_does`: a carve folder as rpf9_carve writes it (`<offset>.bin` per stream plus `index.json`). The CMapTypes resource's last block runs 0x10 bytes into the next stream, and the map file is a separate stream. It asserts that `scan_path` joins the two (row size = whole resource) and that the CLI then reports the same summary as the RPF9-window test (2 archetypes, extents checked). On `main` it gets `(maptypes, archetypes, names) = (1, 0, 0)`. - A 40-definition resource split the same way gives 0 archetypes from the folder and 40 from the equivalent RPF9 archive on `main`, and 40 from both with the fix (review repro). - `python -m compileall`; `scripts/check_no_game_data.py` on both files. Not measured: how many archetypes this recovers from a real carve (no game files here). 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)
imShangLi commented 2026-12-01 04:16:37 +00:00

VERIFY-2382 — Linux, Python 3.15, CPU only, no game files

Claimed as VERIFY-2382 (+18/-0 test, +14/-1 tool). Two-step method: merge into a clean worktree at main (9d231d37), then take only the test file onto clean main.

tree python -I tests/test_world_archetypes.py
main test_world_archetypes.py baseline green
main + this pull request PASS
main + only this pull request's test file FAIL (assertion)

The failure on the last row is an AssertionError, not an import or attribute error, so the test is exercising the changed code rather than merely failing to load it. Reverse control holds: the change is what turns it green.

Verified. Nothing found against it; merges cleanly with main at 9d231d37.

AI-assisted: yes — MiMo-V2.6-Flash (OpenCode).

### VERIFY-2382 — Linux, Python 3.15, CPU only, no game files Claimed as `VERIFY-2382` (+18/-0 test, +14/-1 tool). Two-step method: merge into a clean worktree at `main` (`9d231d37`), then take **only the test file** onto clean `main`. | tree | `python -I tests/test_world_archetypes.py` | |---|---| | `main` | test_world_archetypes.py baseline green | | `main` + this pull request | **PASS** | | `main` + only this pull request's test file | **FAIL (assertion)** | The failure on the last row is an `AssertionError`, not an import or attribute error, so the test is exercising the changed code rather than merely failing to load it. Reverse control holds: the change is what turns it green. **Verified.** Nothing found against it; merges cleanly with `main` at `9d231d37`. AI-assisted: yes — MiMo-V2.6-Flash (OpenCode).
aslan2142 reviewed 2026-12-01 12:03:21 +00:00
aslan2142 left a comment
No description provided.
Draft review against current `main`: joining carved continuation files via `WI._carve_successors` in `tools/world_archetypes.py:130-149` 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:34:14 +00:00

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.)

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 approved these changes 2026-12-01 13:06:42 +00:00
aslan2142 left a comment

Now ready for review and MERGEABLE. Clean-room verified: reading carved resource continuation files in tools/world_archetypes.py:130-149 with tests in tests/test_world_archetypes.py is clean and verified with positive + negative control (@imShangLi).

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

(AI-assisted review.)

Now ready for review and `MERGEABLE`. Clean-room verified: reading carved resource continuation files in `tools/world_archetypes.py:130-149` with tests in `tests/test_world_archetypes.py` is clean and verified with positive + negative control (`@imShangLi`). Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
merzleckeier commented 2026-12-01 13:57:41 +00:00

I extended the synthetic check to split both the definition resource and the map resource across two continuations each. The same six streams were written as an archive and as an indexed carve folder. At e801a13a + 9f27ba2e, the public --check-extents command reported two archetypes and one matching conjugate-rotation case in each mode. The reassembled byte strings and the semantic JSON fields matched between modes. On main, archive mode produced the same correct values, while carved mode produced zero archetypes and zero matching rotations.

python -I tests/test_world_archetypes.py passed 24/24 with the PR and 23/23 on main. MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).

I extended the synthetic check to split both the definition resource and the map resource across two continuations each. The same six streams were written as an archive and as an indexed carve folder. At `e801a13a` + `9f27ba2e`, the public `--check-extents` command reported two archetypes and one matching conjugate-rotation case in each mode. The reassembled byte strings and the semantic JSON fields matched between modes. On `main`, archive mode produced the same correct values, while carved mode produced zero archetypes and zero matching rotations. `python -I tests/test_world_archetypes.py` passed 24/24 with the PR and 23/23 on `main`. MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).
Sign in to join this conversation.
No description provided.