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
test_world_census, test_bvh_index, test_world_index and
test_audit_shader4_regs call the tools' main(), which prints a JSON summary
or report; run as scripts (as CI does) that is about 280 lines of noise
around the results. A setUpModule per file redirects stdout; the tests that
check the output already redirect it themselves.
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>