restofworld_index: judge text on the same 512 bytes in an archive (RESTOFWORLD-INDEX-TEXT-SAMPLE) #2388
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2388
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/restofworld-index-text-sample"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: RESTOFWORLD-INDEX-TEXT-SAMPLE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7198290287)
What and why
tools/restofworld_index.pyclassifies each zlib stream of an RPF9 archive, or each carved file of a folder, by its first bytes. Itstextclass comes from_printable, which samples the first 512 bytes: text when the sample is at least 64 bytes and more than 90% printable.A carved file is classified from its whole data.
scan_rpfkeeps a stream whole only when it may be a PSIN or a CPU resource (texture scan). For every other stream it passedclassifya 256-byte head, so_printablesaw at most 256 bytes there. One stream could therefore get two signatures. A stream whose first 306 bytes are printable, followed by binary data, read astextfrom the archive and asraw:6e616d65from its carved file. af55ea1b4 removed the same archive-versus-folder split for PSIN streams.The archive scan now keeps a 512-byte head, the sample
_printabletakes. The other head checks (PSIN, CPU-resource prefix) read at most 16 bytes, so nothing else changes. A stream that was text under the 256-byte sample is still text unless bytes 256-511 bring it under 90% printable, which is what a carved-file scan already says.Different topic from #1535 (validation and I/O, same files); the two merge cleanly.
Tested
Windows 11, Python 3.14.7, synthetic streams only:
python -I tests/test_restofworld_index.py: 35 tests OK. Newtest_text_is_judged_on_the_same_512_bytes_as_a_carved_fileputs the stream above into an archive and expects the signatureclassifygives for its whole data, which is nottext. Onmainit gets'text' != 'raw:6e616d65'. The existing signature, PSIN-chain and scan tests are unchanged.python -m compileall;scripts/check_no_game_data.pyon both files.Not measured: how many streams of a real archive change class (no game files here).
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
VERIFY-2388 — Linux, Python 3.15, CPU only, no game files
Claimed as
VERIFY-2388(+11/-0 test, +2/-2 tool). Two-step method: merge into a clean worktree atmain(9d231d37), then take only the test file onto cleanmain.python -I tests/test_restofworld_index.pymainmain+ this pull requestmain+ only this pull request's test fileThe 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
mainat9d231d37.AI-assisted: yes — MiMo-V2.6-Flash (OpenCode).
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.)
Now ready for review and
MERGEABLE(1 commit). Clean-room verified: aligning archive text detection to the same 512-byte sample intools/restofworld_index.py:335-336with tests intests/test_restofworld_index.pyis clean and verified (@wavehs,@imShangLi,@MSedgeMC).Approving — ready to merge once CI runs green on current
main.(AI-assisted review.)
I checked the exact text cutoff at
16dde227+9f27ba2eby running both the actual archive reader and the carve-folder reader. For 460 printable bytes among the first 512,maingivestextfor the archive andrawfor the folder. The PR givesrawfor both. At 461 of 512, both trees givetextin both modes. I also appended 128 printable bytes to the first case and 128 nonprintable bytes to the second, so the probe would catch accidentally sampling beyond byte 512.python -I tests/test_restofworld_index.pypassed 38/38 with the PR and 37/37 onmain. MEASURED on Linux, CPython 3.14.10, with synthetic fixtures. AI-assisted (Codex).