Apply published_mode(out) to staged manifest file before atomic replacement,
and restore write permission (0o600) before TemporaryDirectory cleanup in
exception block when replace fails, preventing Windows PermissionError [WinError 5]
and stranded temporary files.
agent: yes
AI-assisted: yes
_hash_file() read each 8 MiB chunk with f.read(), which allocates the next
bytes object while the last one is still referenced: two chunks per worker
at the peak. With --jobs N that is 16 MiB times N for hashing alone.
It now fills one memoryview-backed bytearray with readinto(), as
manifest_verifier.sha256_file() already does. Digests, sizes and the
change-during-read checks are unchanged.
Measured on a 320 MiB file: tracemalloc peak 16.0 -> 8.0 MiB.
Tests: a multi-chunk file must hash right with a peak under 1.5 chunks, a
short readinto() must not skip or repeat bytes, and the edit-during-read
case hooks readinto, the call the tool now makes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
verify printed OK and exited 0 for an empty "files" table even when the folder held files, so make_game.py's package check verified nothing. Reject that case with one ERROR line and exit 2; keep the empty-folder round trip that create writes and the tests rely on.
In tools/manifest.py walk(), unconditional .replace("\\", "/") collapsed literal backslashes in POSIX filenames into "/", causing distinct files such as sub/a.dat and sub\a.dat to collide in create() and verify() and diverging from manifest_verifier.py (#2235). Normalize only os.sep/os.altsep when distinct from "/", and add a POSIX regression test.
A file can resize after the directory scan. Check the expected size again on the handle used for hashing so verification cannot combine a size and digest from different versions of the file.
Normalize the expected hex digest before serial or parallel verification. Add synthetic API and CLI regressions for case variants, altered content, missing/size errors and malformed digests. AI-assisted with Codex and an independent Claude review.
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.
AI-assisted (Claude), on behalf of dev-ewann.
manifest create --out <game>/a.txt hashed the file and then replaced it
with the manifest (exit 0), so the copy no longer matched the manifest it
had just recorded; turing_atlas --out <existing dir> built the atlas and
then died with a PermissionError. Refuse an existing non-manifest target
inside the hashed folder (and hard links to files that will be hashed)
before hashing, and reject a folder for turing_atlas' --out with one line.
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
verify read the manifest with json.load(...)["files"] and indexed each entry's "size" and "sha256" directly,
and main caught only OSError. A truncated or malformed manifest therefore ended in a JSONDecodeError, KeyError
or TypeError traceback. load_manifest now checks the JSON, the "files" table and every entry, and raises
ManifestError, which main reports as an ERROR line with exit 2 like a missing file.
create wrote the final manifest in place, so an interrupted run left exactly such a truncated file. It now
writes <out>.partial and swaps it in with os.replace, removing the partial file on any failure; the previous
manifest stays as it was.
The shipped game/xbox-1.0.2.1.json still loads (108 entries).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Default is half the CPU count; --jobs 1 keeps serial hashing. create rebuilds entries in walk order so the JSON does not depend on completion order, and verify prints problems in manifest order so its output and exit code are identical for every job count. Progress now reports completed file counts from the main thread instead of per-file worker lines.
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>