gamedata_maps: support UTF-8 BOM index.json, validate row fields, and write JSON atomically (GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO) #1526
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1526"
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 IlyassRS3 on 2026-11-25T03:26:38Z.
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
Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:26:46Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:34:15Z.
[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.Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T07:45:19Z.
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.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:41:55Z.
Merged after local re-verification: this PR merged onto
mainddcf9ac03without 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.