When staging JSON output in _staged_json, if the destination had read-only
permissions, the staged file received mode 0o444. If publishing fails or
raises an exception, resetting os.chmod to 0o600 in finally ensures
TemporaryDirectory cleanup does not fail with PermissionError on Windows.
agent: yes
AI-assisted: yes
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.
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>
Each shard starts scanning WARMUP (8 MiB) before its start to land on a real stream boundary. The
streams it found there belong to the previous shard, but scan_shard added their streams, stored,
inflated and rejected counts anyway; only metadata streams were caught by the later `s < start`
check, which is what the "adopted" counter counted. So every total except the map rows grew with
the number of shards.
On a 1.0.2.1 copy, data.rpf gave 28,509 streams with one shard (rpf9_carve's count), 42,293 with
--shard-size 16 MiB and 51,831 with 10,000,019 bytes, with identical map rows. With this change
all three give 28,509 streams, 423,279,355 stored and 1,403,250,069 inflated bytes and 638
rejected candidates (1, 29 and 49 shards).
A warm-up stream now only moves the scan past its bytes. The adopted counter, which only ever
measured the double count, is gone.
test_world_census: test_tiny_shards_give_the_same_stream_totals compares every total of a
one-shard run with 400-byte shards (the existing tiny-shard test only checked maps, entities and
interval coverage, which a union hides). It fails on the old code (inflated 39,312 vs 7,504).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit eb96a79ceb86a56cbc9a654ad7b2d04df1da27a4)
`end = min(size, start + a.limit) if a.limit else size` treated
--limit 0 as no limit, so asking for zero bytes scanned the whole
archive (a full census of a multi-GiB archive) and wrote its outputs.
It is now an empty range and refused as "bad scan range", like
--limit -1. A missing archive, or a folder given as one, ended in a
FileNotFoundError / IsADirectoryError traceback; it is now one line
naming the path, exit 2, before --out is created.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ci.yml: cancel only superseded pull request runs; a push to main was
cancelled by the next merge and left that commit without a CI result
(#326 review).
- world_census.py: --jobs above 61 is rejected with an argparse error on
Windows instead of ProcessPoolExecutor's ValueError traceback, with a
test next to the below-1 test (#308 review).
- docs/textures.md: drop the duplicated "The BCPack counts above..."
paragraph (#292 review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--shard-size 0 (or a negative size) never finished planning shards: pos
never advanced, so the list grew until memory ran out. --jobs 0 crashed
with a ValueError traceback from ProcessPoolExecutor.
Both flags now take a positive_int, so argparse exits 2 with "must be at
least 1". _expected_shards also raises ValueError for a size below 1, for
callers that skip the CLI.
Tests: the CLI cases run in a subprocess with a timeout, and the planner
case counts additions, so a regression fails instead of hanging.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>