With a calibration profile, a history edit changes the pass stamp, so the
pass decoded every calibrated row again and replaced its DDS with the same
bytes under the same name. Calibrated output does not depend on the
history, and a replacement denied for a file in use stopped the pass
before the strict fallbacks.
Skip a row whose decoder stamp and file name already match the pass and
whose file exists.
load_history() checked the bc6h and bc7 sections through the table loaders,
which check shapes and integers only. A confirmed endpoint depth above the
known one (9 over 8) passed, and strict decoding then published a
provisional reconstruction as a confirmed DDS.
Move the range checks of bcpack_history_calib.py --verify into
check_history_tables() and run them on the parsed history before any pool
is opened. Both now also reject an entry with confirmed bits whose values
the table leaves out: the decoder read zeros there as confirmed values.
Apply published_mode(path) and restore write permission (0o600) on replace
failure before unlinking the temporary file in publish(), preventing Windows
PermissionError [WinError 5] and stranded temporary files.
agent: yes
AI-assisted: yes
Squash-merged after diff review of PR #6827 - make_game: a broken bcpack calibration profile is one ERROR line, not a JSON traceback (EGEN-TTPF-CALIB-PROFILE-BADJSON)
Review (@shdann): a file that could not be removed because it was open
stayed for good. The manifest had already switched away from it and the
pass was stamped, so later builds returned before any cleanup.
The manifest that switches the rows now lists the replaced files under
BCPackReplaced. They are removed after it is published, and the list is
written again with only what could not be removed (dropped when empty).
A build that finds the pass stamped still finishes that list. This also
covers a build stopped between the manifest write and the removal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: the same-file check compared every replaced name with every row's
file, os.path.samefile per pair, so a pool with thousands of rows and
replaced files took minutes to hours. Each row's file is now stat'ed once
into a set of (device, inode), and each replaced name once against it.
The removal moves into remove_replaced(), and a test fails if the check
is done per pair (50 rows and 50 replaced files: at most 100 stats).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for the removal of replaced DDS files:
- A row that named the new file in another letter case (the same file on
Windows and macOS) no longer has it removed: names are compared through
normcase, and a file that is the same file on disk as one a row names is
kept.
- Only names that end in .dds are removed, so a row that names
manifest.json (or anything else) cannot remove it.
- A file that could not be removed is counted, and one line on stderr says
how many stay next to the full-chain files.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
complete_pool publishes <index>_bcpack_<method>.dds and switches the
manifest row to it, but left the file the row named before in the pool
folder, named by no row: every texture the pass completes was stored twice.
After the manifest is published, a superseded file that no row names any
more is removed. It stays when the manifest write fails (the row still
names it), when another row names it, and when it can't be removed; only a
plain file name inside the pool's folder is ever removed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`python -I` implies `-P`, so the directory of the script is not `sys.path[0]` and a tool that imports the module
next to it dies before `main()`:
python -I tools/calibrated_texture.py --help
ModuleNotFoundError: No module named 'bcpack'
`calibrated_texture.py` imports `bcpack`, `bcpack_tables` and `ttpf_mips` and added nothing; `ttpf_assets.py`
imports `bcpack`, `file_mode`, `ttpf_mips` and `calibrated_texture` and added nothing either, so the build's
texture stage tools could only be run through `make_game.py`, never directly as CONTRIBUTING.md documents.
Insert `os.path.dirname(os.path.abspath(__file__))` before the sibling imports, the pattern already used by
`tools/anim_clips.py`. `tests/test_tool_startup.py` derives the affected set from the sources and runs
`python -I <tool> --help` for all of them, so a new tool with a sibling import is covered without editing the
test; without the two fixes it fails exactly on those two tools.
A sweep of `python -I tools/*.py --help` over all 110 tools found no other case.