restofworld_index: judge text on the same 512 bytes in an archive (RESTOFWORLD-INDEX-TEXT-SAMPLE) #2388
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2388"
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:57:15Z.
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.af55ea1b4removed 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
Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-26T18:04:13Z.
Review: COMMENTED
Verified on the PR branch: python3 -m unittest tests.test_restofworld_index -v -> 35 tests OK, including the new continuation-file and texture-detection cases. Not approving yet: this branch carries 522 commits not on current main, so a merge would include unrelated history. Please rebase onto main and re-run the suite.
Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:27:13Z.
Review: COMMENTED
macOS arm64 check of #2388 (RESTOFWORLD-INDEX-TEXT-SAMPLE). A four-line indexer change, no GPU or translator code.
Tested head
16dde2277with its diff applied to a copy ofmainbdbc7e923(git applyclean; branch 10 commits behind). Working tree left untouched for this one because no build is involved.Environment: Apple M3 Pro, arm64, macOS 27.2.1, CPython 3.15.2.
The new test passes, and the control bites
python -I tests/test_restofworld_index.py:Ran 35 tests ... OKat the head.tools/restofworld_index.pyput back tomain's): exactly one failure,test_text_is_judged_on_the_same_512_bytes_as_a_carved_file, which is the regression the PR names. The other 34 tests still pass, so the change does not move unrelated classifications.name=+ 301 printable bytes +bytes(range(256))+ zeros), so it needs no game file.The change is the right one
_printable()samplesdata[:512]and requireslen(sample) >= 64(line 138-144), while the archive path stopped collectingheadat 256 bytes, so the 306-byte case in the test was text when carved and raw from the archive. Collecting 512 bytes makes both call the same function on the same amount of data;body(the carved payload) is unaffected, andheadis only used for the PSIN/CPU and printable sniffing plus the fast-reject below 16 bytes.No regressions
mainbdbc7e923; the PR adds no semantic test, so this is the same tree, unchanged.len(head) < 256constant in an offline archive indexer, whichscripts/run_gpu_tests.py,tools/rdna2spirv.pyandruntime/do not load; I did not want to quote a green GPU run for a file the shader path never reads. The same-main baseline from this session is 195 PASS / 3 FAIL / 70 SKIP on MoltenVK and 190 / 5 / 73 on KosmicKrisp.I found no bug in the change. The only thing I would add is a small comment on
_printable's 512-byte sample saying the archive scan must collect the same 512 (the new comment on theheadline says it the other way round, which is enough, but the two sites can drift again).No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T04:16:41Z.
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).
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:03:42Z.
Review: COMMENTED
Draft review against current
main: increasing the archive text sample from 256 to 512 bytes intools/restofworld_index.py:335-336to match carved-file_printablesampling 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.)
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:35:58Z.
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:07:17Z.
Review: APPROVED
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.)
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:57:45Z.
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).