gamedata_blobs: fix unshipped count, index type checks, and atomic JSON #2258
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2258
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/gamedata-blobs-safety"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: GAMEDATA-BLOBS-UNSHIPPED-OVERLAP-INDEX-TYPES-AND-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189816855)
What and why
unshippedoverlap double-subtraction incross_reference_sgd5()(tools/gamedata_blobs.py) so preload-list entries present in bothdb0anddb1are counted accurately viasum(1 for s in stems if s not in db0_set and s not in db1_set)instead ofp["entries"] - len(in_db0) - len(in_db1).check_carve_index()to convertUnicodeDecodeErrorandRecursionErrorfromjson.load()into single-lineValueErrordiagnostics and requiretype(row.get("off")) is intandtype(row.get("stored")) is int(non-bool,>= 0).index.jsonacrossmain()andread_payloads(..., _checked_index=is_dir), reject trailing/or\--jsondirectory paths incheck_report_path()and non-file--shadersupfront beforeread_payloads(), and catchRecursionErrorcleanly inmain().--jsonoutput atomically via_write_json_atomic()(staging next toos.path.realpath(out_path), trailing LF\n,os.fsync(), preserving permissions withpublished_mode(), publishing viareplace_retry.replace(), and unlinking.blobs-*.tmpfiles on failure).GamedataBlobsSafetyTeststotests/test_gamedata_blobs.py(without overlapping#1269's lines) covering overlapunshipped,bool/negative/strindex types,RecursionError, singleindex.jsonparse, early CLI validation, and atomic JSON write/failure rollback.Tested
python -I tests/test_gamedata_blobs.py -v->Ran 14 tests in 1.178s(OK).upstream/maina73a57e1with updatedtests/test_gamedata_blobs.pycopied into detached worktree):Ran 14 tests in 1.119s(FAILED (failures=10)).python -I tests/test_ci_registration.py(Ran 16 tests in 5.560s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 13.499s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q tools/gamedata_blobs.py tests/test_gamedata_blobs.py(exit 0),git diff --check(exit 0).GPUs tested: n/a (synthetic carve/RPF/SGD5 fixtures and atomic JSON output tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Approving d1545dfde.
The unshipped-count fix is real:
entries - len(in_db0) - len(in_db1)subtracted a stem present in both databases twice (it could go negative); counting stems in neither set is right. Index rows now need nonnegative integeroff/stored, bad UTF-8 is reported, the index is not checked twice, and the JSON is written atomically.Merged onto
maind1dff7949in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_gamedata_blobs.py: 14 passed (main: 10). AI-assisted (Claude Code, Claude Opus 5.5).#2258 | head
843a265f47d63dec939e7f69ac1f26ebde1ae193|python3 -I tests/test_gamedata_blobs.py -v| red: 15 tests, 11 assertion failures | green: 15 passed | Red → greenBaseline assertions failed on summary counts, invalid index diagnostics and output handling.
Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Native Windows 11 NTFS Verification (
843a265f47)Verified
843a265f47d63dec939e7f69ac1f26ebde1ae193merged cleanly ontoorigin/main(c7753ed98a56677f10e34078b37eab0540e190ec,git merge-tree --write-treerc=0) on native Windows 11 (26200) + NTFS:origin/mainc7753ed98a):python -I tests/test_gamedata_blobs.pyfailed11/15(FAILED (failures=11)).origin/main + 843a265f47):python -I tests/test_gamedata_blobs.py:15/15 OK(overlap-safeunshippedcount, strictintrow type/sign checks,RecursionErrorhandling, singleindex.jsonparse,.bk2input-alias refusal, and pure-LF atomic JSON output).stat.S_IREADprobe: Rangamedata_blobs.main([carve, "--json", blobs.json])against a read-onlyblobs.json(stat.S_IREAD): exitedrc=1, left0.blobs-*.tmpstaged files, and preservedblobs.jsonbyte-for-byte.AI-assisted.
Merged at head 843a265. Tested by others on this head: sodove (WSL, Python 3.14) and zmasi (Windows 11 NTFS):
tests/test_gamedata_blobs.py11/15 fail on main, 15/15 pass with the PR. No GPU involved. AI-assisted: yes.