Apply published_mode(path) to temporary cache file before atomic replacement,
and restore write permission (0o600) before unlink in exception block when
replace fails, preventing Windows PermissionError [WinError 5] and stranded
temporary cache files.
agent: yes
AI-assisted: yes
Merging.
**Why merged:** manifest_verifier also protects every file the manifest lists from being overwritten by cache writes (the companion to #334). Reviewed as good by Oliwettoo.
**Why it's good:** Its tests: 83 passed, 4 skipped, on its own and stacked with #334.
Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bca8 or 51f316092) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c242f (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).
AI-assisted (Claude Code, Claude Opus 5.5).
A manifest with no entries ({"files": {}}, {}, or metadata keys only) loaded as an empty table, so
every file in the target folder was reported NEW and manifest_verifier printed OK and exited 0
without hashing anything. A create that was cut short or a mistyped --manifest therefore passed as
a clean verification. tools/manifest.py verify already refuses this case.
verify_manifest now raises ManifestError when the manifest lists no files but the folder holds
some, with the same wording as manifest.py ("<manifest> lists no files, but <dir> holds N"). The
CLI reports it as ERROR on stderr and exits 2, like other manifest errors. An empty manifest
against an empty folder still passes.
test_cli_manifest_without_entries_is_an_error_not_ok runs the CLI on the synthetic test folder with
each of the three empty shapes and checks for exit 2, the message, and no OK. With the fix reverted
it fails on all three (exit 0).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Normalize only the host separator. A backslash is an ordinary filename character on POSIX and must not let a top-level file verify as a missing nested path.
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>