gamedata_maps: support UTF-8 BOM index.json, validate row fields, and write JSON atomically (GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO) #1526
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!1526
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/gamedata-maps-hardening"
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
Summary
Hardens carve index loading, payload parsing, and JSON report writing in
tools/gamedata_maps.py:_read_index_rows,_read_row,_row_nonneg_int,read_payloads): opensindex.jsonwithencoding="utf-8-sig", validates thatoffis a non-negative non-boolinteger (preserving the existingrow N needs an 'off'diagnostic when missing), validateshead(string orNone) andsize/stored(non-negative non-boolint orNone), and stops continuation joins on empty missing chunks.parse_pamh): checks[offset + start, offset + start + count)againsthalfonce per non-empty row and copies max/min slices directly._write_json,main): stages--jsonoutput via a sibling temp file withnewline="\n", trailing LF,allow_nan=False,file_mode.published_mode, andreplace_retry.replace, preserving pre-existing files on error.Coordination
GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151890540)Testing
python3 -I tests/test_gamedata_maps.py -v— 28/28 OK (including 3 new regression tests)python3 -I tests/test_gamedata_maps_bad_index.py -v— 8/8 OKpython3 -I tests/test_missing_input_exit_codes.py— 2/2 OKpython3 -I tests/test_psin_psch.py— 4/4 OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I scripts/check_no_game_data.py tools/gamedata_maps.py tests/test_gamedata_maps.py— cleanpython3 -m compileall -q tools/gamedata_maps.py tests/test_gamedata_maps.py— cleanmain:tools/gamedata_maps.py: 3/3 new tests fail (FAILED (failures=5, errors=2)).Checklist
[KEEP]
tools/gamedata_maps.pyandtests/test_gamedata_maps.py:utf-8-sigindex loading,_row_nonneg_intvalidation ofoff/stored/size(rejecting bools and negatives),headtype check, and an atomic_write_json(temp file +replace_retry.replace,allow_nan=False) with tests for each.no-game-data,change-scope); the PR is mergeable. Hold for green before merging.parse_pamhchange to slice copies rather than per-cell loops is a behavior-preserving rewrite bundled into a "validation/IO" PR; the bounds check is equivalent, but it is an unrelated optimisation that a reviewer should confirm.Independent verification (native Windows, Python 3.11.9): diff vs merge-base reviewed;
utf-8-sigindex.json, non-neg/non-booloff/head/size/storedvalidation preserving the row diagnostic, single-boundsparse_pamhslice (indexing equivalence verified), atomic_write_jsonvia NamedTemporaryFile+replace_retry withnewline="\n"/allow_nan=False, empty-chunk join guard — all present. Tests reproduce claimed counts exactly:test_gamedata_maps.py28/28,test_gamedata_maps_bad_index.py8/8,test_missing_input_exit_codes.py2/2,test_psin_psch.py4/4, line-endings 3/3; compileall +check_no_game_data.pyclean. AI-assisted verification.Merged after local re-verification: this PR merged onto
mainddcf9ac03 without conflict, and its test file(s) (tests/test_gamedata_maps.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.