make_game assets: reuse local BCPack history on resume (ASSETS-BCPACK-STRICT-HISTORY) #2512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2512"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-27T23:04:33Z.
Claimed in the coordination issue as: ASSETS-BCPACK-STRICT-HISTORY
What and why
A pool with a BCPack predictor missing from the built-in tables stays limited after resuming
make_game.py --stages assets, even when the history accepted byttpf_mips.py --historyis available.The assets stage now reads an optional
<work>/bcpack-history.jsonand passes it to the strict decoder, including strict fallbacks when a calibration profile is also present. Adding, editing or removing the history invalidates the pool's pass stamp. An unchanged history keeps the cache. The stage reports an invalid history before updating the pool. A strict refusal preserves any DDS already named by the catalog.Tested
Windows 11, Python 3.12.4, no game files:
587bb6f5aand pass with this patch. The accepted DDS matches the complete expected BC1 mip payload byte for byte. The cases cover cache reuse, a changed history, removal that preserves the last usable DDS, and an invalid history that leaves the pool unchanged.make_game.py --help,git diff --checkandcheck_no_game_data.pypassed.mainatd44285197and with #1013 atb6b1fe75f. Both combined trees passed the texture-assets and assets-pools suites (38 passed / 3 skipped with main, 46 passed / 3 skipped with #1013).GPUs tested: n/a (CPU-only synthetic tests).
AI-assisted: yes (Codex).
Checklist
mainand trial merge checked.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T23:18:38Z.
Review of
51b2819b6, on request in the French Discord group. Read the diff and ran the tests; no game files.Tests (Windows 11, Python with the standard library,
python -m unittest test_ttpf_assets):tools/ttpf_assets.py(587bb6f5a, test file with theProfilesimport neutralised): both FAIL, so they test the change.test_history_added_after_strict_rejection:AssertionError: unexpectedly None(no DDS after the history is added).test_invalid_history_reports_error_without_updating_the_pool:SystemExit not raised.check_no_game_data.pyon the changed files: clean.Read in code, all fine:
bcpack-history.json, and the catalog stays untouched.<calibrated>+<strict>. Calibrated rows keep the calibrated part (partition("+")[0]), and strict fallbacks get the history-aware stamp. Adding, editing or removing the history therefore re-runs the pass.v1-+ 16 hex), with or without a history.Nits (no change needed):
bcpack-history.jsonalso re-runs the pass, as theindent=2step of the test shows. That's conservative, and probably fine for a file that rarely changes.load_historypasses the whole history toload_bc6h/load_bc7/load_bc_historyonce per section. This is harmless, because each one picks its own codec.Looks good to me.
AI-assisted (Claude Code, Claude Opus 5.5), for OreoFR.
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-27T23:46:01Z.
Reviewed
51b2819b6. The history handling looks right to me. The stamp covers the history bytes, and an unchanged file keeps the pass. An invalid file stops the stage before any pool is touched, and a strict refusal keeps the previous DDS.Locally (Windows 11, Python 3.13.12):
tests/test_ttpf_assets.pygives 33 passed, 3 skipped (NumPy, rpf9dump, POSIX modes). Both new tests fail withtools/ttpf_assets.pyfrom587bb6f5aand pass with the patch. The BCPack, ttpf_mips, history-calib and docs suites pass. The three red CI jobs (check,macos-python,stdlib-tests-linux) fail intest_docs_cli_flags,test_docs_python_deps,test_docs_repo_paths,test_tool_stdout_encodingandtest_windows_boot_journal_seed; main's own CI run atd44285197fails in the same five, so none of it comes from this PR. (The last one is my test from #2481: an 8.3 temp path on the runner; a fix follows.)A few points:
Nothing tests the calibration + history path. The whole file still passes after each of three mutations:
Profileswhen a calibration profile is present (L104-106);strict = Noneinstead ofprofiles.strict_stamp(L206);method = stampinstead ofstamp.partition("+")[0](L225).The third one matters. Calibrated rows would get a
BCPackDecoderending in-strict, andcandidate()would revisit them as strict rows once the profile is removed. The mocked testtest_a_pool_hashes_the_decoder_sources_once_for_all_its_strict_fallback_rowsalready runs without NumPy. A variant withProfiles(calibration={}, history={...}, strict_stamp=...)would cover this path if it checked two things: thehistorypassed totexture_dds, and the strict fallback'sBCPackDecoder.The stamp hashes the raw bytes. Reformatting the file, adding a BOM, an empty section (
{"bc1": {}}) or provisional-only entries each cause every strict DDS to be decoded again and renamed. That is safe. If it isn't wanted, hashingjson.dumps(history, sort_keys=True, separators=(",", ":"))would remove the formatting cases. Theindent=2step in the new test would then need a real content change.README: according to the docstring of
bcpack_history_calib.py, pool self-calibration writes provisional tables, and confirmed entries come from--ref-dds/--ref-pairs. A pool-only history unblocks nothing in strict mode but still starts a new pass. One sentence saying so would spare someone a long rerun. Also,make_game.py's help text (line 26) names onlybcpack-calibration.json; the history file could be listed there too.Nit: the test could also check that the DDS replaced after the
indent=2edit is removed.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T00:15:16Z.
Thanks for the review. I addressed the coverage and documentation points in
a1e046535.make_game.py --helpnow lists both optional BCPack files.I kept the byte-based stamp. Any edit to the history file still invalidates the saved pass.
On Windows without game files, 253 focused tests passed and 4 were skipped. The trial merge with
main(d44285197) was clean, with 39 targeted assets tests passed and 3 skipped.git diff --checkand the no-game-data check passed.AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:43Z.
Reviewed at head
a1e046535on Windows 11 (Python 3).Verification
python -B -m unittest tests/test_ttpf_assets.py -v: 34/34 tests OK (0.506 s).Finding (Request changes)
tools/ttpf_assets.py:59-76;tools/bcpack_tables_bptc.py:203-217,305-351;tools/bcpack_history_calib.py:2427-2475):The resume/stamp/mixed-calibration/DDS-cleanup plumbing in
make_game.pyandtools/ttpf_assets.pylooks solid. However,load_history()validates abc7section only by callingbcpack_tables_bptc.load_bc7(history), which checks array shapes and int conversions but omits the range checks enforced by--verify(confirmed <= known <= 8, index depths, and BC6H value ranges). For example, wrapping the mode-6 fixture fromtests/test_bcpack.py:1029-1095withhistoryEndpointConfirmedBitsset to9(whileknown == 8) passesload_history()and satisfies strict mode's depth thresholds (bcpack.py:1148-1236), causingcomplete_poolto publish provisional output as a confirmed strict DDS and stamp the pass. Reusing--verify's range checks on the parsed history snapshot before running texture-pool work (and adding an invalid-BC7 test alongside the BC1 case attests/test_ttpf_assets.py:275-286) closes this cleanly.AI-assisted review + local Python verification.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T06:52:12Z.
#2512 | head
a1e0465356(merged cleanly with main09c153948) |python -I tests/test_ttpf_assets.py| red on main:ImportError: cannot import name 'Profiles' from 'ttpf_assets'(load_profile(work)on plainmainalso ignoresbcpack-history.json, returning(strict_stamp(), None)) | green on PR+main:34 tests OK (skipped=3)(-k test_history_added_after_strict_rejection:1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yesVerified the merged tree across
tests/test_ttpf_mips.py(93 OK),tests/test_bcpack.py(20 OK),tests/test_docs_links.py(17 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py. Note: independently reproduced the range-validation finding noted in review above —bcpack_tables_bptc.load_bc7acceptshistoryEndpointConfirmedBits[9]*6withhistoryEndpointKnownBits[8]*6, sottpf_assets.load_historycurrently rejects out-of-rangebc1–bc5entries viaload_bc_historywhile letting out-of-rangebc6h/bc7depth bounds pass preflight.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T07:21:22Z.
Thanks for this! Reusing a local
bcpack-history.jsonon resume, with cache invalidation when it changes, lifts the limit on pools whose predictor is missing from the built-in tables.During maintainer testing (local, 2026-11-28) (head
a1e046535, merged on mainb1619e0a3/6dfca6428, Windows 11, Python tests via pytest/unittest) we found:load_history()(only theload_bc7shape checks run) and can publish a provisional decode as a confirmed strict DDS.To get this merged:
--verifyuses to the parsed BC7 (and BC6H) history before the pool work.AI-assisted (Claude Code), posted for DadaCap (maintainer).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T14:36:16Z.
Review: COMMENTED
Request changes after a static code audit against
a1e046535+ec740bcc3, with in-memory synthetic checks.tools/ttpf_assets.py:68passes BC6H/BC7 history through the loaders without the full schema checks. A synthetic BC7 pool published a strict DDS with confirmed depth 9 and known depth 8. It also published incorrect bytes when the depth declarations survived but the endpoint row was absent. Please share the--verifybounds checks, enforce confirmed value-row presence and add an assets regression.tools/ttpf_assets.py:254runs cleanup against a manifest snapshot. Overlapping A → B → A history passes can delete both stamped DDS files and leave the final catalog pointing to a missing file. Please serialize the manifest read, publish and cleanup across writers.tools/ttpf_assets.py:224rewrites already valid calibrated DDS files when only history changes. A denied replacement can abort the pass before later strict fallbacks. Please reuse calibrated rows with matching stamps and complete output.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T15:47:20Z.
Thanks for the review. I pushed two commits on top of
a1e046535.0507555a5: history ranges.load_history()checked thebc6handbc7sections with the table loaders only. So a BC7 confirmed depth of 9 over a known depth of 8 passed. I moved the range checks ofbcpack_history_calib.py --verifyinto a sharedcheck_history_tables().load_history()now runs it on the parsed history before any pool is opened. The checks also require the value row for every entry that has confirmed bits (BC7historyEndpoints/historyIndices, BC6HendpointHistory/indexHistory). Without that row, the decoder read zeros as confirmed values.--verifyuses the same function, so it rejects those tables too.bcpack_tables_bptc.pyis unchanged, so the decoder digest and saved passes are unchanged.a23d69194: calibrated rows on a history edit. With a calibration profile, a history edit re-decoded every calibrated row and replaced its DDS with the same bytes under the same name. A row whose decoder stamp and file name already match the pass, and whose file exists, is now kept as is. So a history edit re-decodes only the strict fallbacks.Overlapping A → B → A passes: I did not change this here. Run one after the other, each pass removes only the files its rows no longer name. Losing a file needs two builds running on the same work folder at the same time. Nothing in
make_game.pyserializes two builds on one work folder, andmainhas the same race when the calibration profile is edited. A lock across the manifest read, publish and cleanup is a separate change from the history support.New tests:
test_out_of_range_bc6h_and_bc7_history_reports_error_without_updating_the_pool, next to the BC1 one. It covers BC7 confirmed above known, BC7 confirmed bits without values, a BC6H value out of range and BC6H confirmed bits without values.test_verify_rejects_confirmed_bits_without_valuesintests/test_bcpack_history_calib.py.test_calibrated_and_strict_rows_use_separate_stamps_with_history: after a history edit, the calibrated decoder is not called again and its file is not replaced.Tested on Windows 11 with Python 3.12.4:
a1e046535:python -I tests/test_ttpf_assets.pygave 34 tests OK (3 skipped).python -I tests/test_bcpack_history_calib.pygave 19 OK.SystemExit not raised, and the 4--verifysubtests fail with0 != 2. The second pass fails with(2, 0) != (1, 0).a23d69194:tests/test_ttpf_assets.pygave 35 OK (3 skipped).tests/test_bcpack_history_calib.pygave 20 OK.mainc1ecf04ed(clean):test_ttpf_assets35 OK (3 skipped),test_ttpf_mips93 OK,test_bcpack20 OK,test_json_bom_inputs10 OK,test_calibrated_texture2 OK (1 skipped),test_text_write_line_endings3 OK,test_docs_links17 OK.python -I -m unittest discover -s tests -p test_dstorage_history.pygave 6 OK (1 skipped).test_bcpack_history_calibgave 24 tests with 1 failure,test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive. It fails the same way onmainalone (23 tests, 1 failure), so this PR does not cause it.scripts/check_no_game_data.pyon the changed files andgit diff --checkare clean.@timbot103, could you take another look?
AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:46:42Z.
RUN for #2512 (make_game assets: reuse local BCPack history on resume)
Kind: Python (make_game.py, tools/, tests/). Tester: second machine, not the author.
Heads
a23d691944(merge base587bb6f5ac)48bae6cadeCommands (repo root, one process per file)
python -I tests/test_ttpf_assets.py
python -I tests/test_bcpack_history_calib.py
python -m compileall -q make_game.py tools tests
python -I make_game.py --help
plus the 29 other tests that mention make_game, ttpf_assets or bcpack_history_calib (python -I tests/)
RED (PR non-test changes reverted to the merge base, tests kept)
Each revert is caught by at least one test.
GREEN at PR head
GREEN merged into current main
4f383c8aeand assumes a case-sensitive file system, Windows is case-insensitive. Not caused by this PR (the test is not in the PR branch).Not covered: no game files used, so nothing exercised an actual pool decode here; runtime/ and Rust are untouched (no link/import check needed).
Machine: Windows 11 Pro, RTX 3090 24 GB, NVIDIA 621.40, Python 3.13.12 (uv build, no numpy).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:33:48Z.
Review: APPROVED
Approve. Checked timbot103's three points against
a23d69194:load_history()now runs the--verifychecks (check_history_tables) before any pool opens, and requires a value row for every confirmed entry. I fed 25 malformed histories toload_history: BC7 confirmed above known, confirmed bits without values, BC6H class 3 without rows, bad keys,Infinity, deep nesting, BOM. Each one either gave a cleanValueErroror was a valid table. Nothing escaped as a traceback.make_game.pyhas no lock on the work folder, andmainhas the same race when the calibration profile is edited. It belongs in a separate change.publish()is atomic, so a file that exists is complete.Tests: merged on origin/main
791899f65(clean), Windows 11, Python 3.12.10,python -I:test_ttpf_assets35 OK (3 skipped).test_bcpack_history_calib24 with 1 failure,test_resolve_pools_deduplicates_macos_case.... That test assumes a case-sensitive file system, and it fails the same way onmain.test_text_write_line_endings,--help,git diff --checkandcheck_no_game_dataall pass.Review by OreoFR's agent (AI-assisted, Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T08:14:21Z.
Merged after OreoFR's check (check: red/green on
main+ this PR) and a re-check here: no conflict withmain0125399d4, same head as checked, not frozen,no-game-datagreen.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.