psin_psch: fix PMAP exact_end, schema checks, head handling, and carve-dir/atomic JSON I/O (PSIN-PSCH-VALIDATION-AND-IO-HARDENING) #1523
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1523"
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:23:41Z.
Summary
Fixes several concrete bugs and hardens validation and report I/O in
tools/psin_psch.py:exact_endcalculation (decode_pmap): computes the data-area end frommax(b["offset"] + b["length"] for b in blocks)instead of row-orderblocks[-1], so valid PMAP tables with a trailing empty block or out-of-order final row are no longer falsely rejected.check_psch_schema): rejects self-referencingPSCH_TYPE_ARRAY(elem_idx == idx) andPSCH_TYPE_MAP(k_idx == idx/v_idx == idx) descriptors and reports duplicate struct or enum hashes inPSCHinstead of silently overwriting earlier entries.headrow filtering (_has_psin_head,scan_target): handlesNone/non-stringheadfields in carveindex.jsonrows without raising an uncaughtAttributeError, and matches uppercase"5053494E"prefixes as well as lowercase.--carve-dir& pre-parse overwrite protection (check_report_path,main): checks.binpayloads inside--carve-dirviagm.check_report_path(not onlyindex.json), and runs the initialcheck_report_pathguard before readingindex.jsonso--json <dir>/index.jsonstill exits 2 even whenindex.jsonis corrupt._write_json,main): stages--jsonoutput in a sibling temp file withnewline="\n", trailing LF,allow_nan=False,file_mode.published_mode, andreplace_retry.replace, preserving pre-existing files on failure.Coordination
PSIN-PSCH-VALIDATION-AND-IO-HARDENING(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151838167)Testing
python3 -I tests/test_psin_psch.py -v— 9/9 OK (including 5 new regression tests)python3 -I tests/test_missing_input_exit_codes.py— 2/2 OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I scripts/check_no_game_data.py tools/psin_psch.py tests/test_psin_psch.py— cleanpython3 -m compileall -q tools/psin_psch.py tests/test_psin_psch.py— cleanmain:tools/psin_psch.py: 5/5 new tests fail (FAILED (failures=3, errors=2)).Checklist
Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:23:54Z.
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:01Z.
[KEEP]
tools/psin_psch.pyandtests/test_psin_psch.py; the PMAPexact_endfix (use max block end instead of the last row), duplicate struct/enum hash checks and atomic JSON writes look reasonable, with new tests for each.no-game-dataandchange-scopechecks are reported and both were still pending, so there is no green CI signal yet. Merge once they pass.Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T07:53:22Z.
Independent verification (native Windows, Python 3.11.9 — stdlib-only, representative): diff vs merge-base reviewed; PMAP exact_end via max(block end), duplicate/self-ref schema checks, lowercase head match, check_report_path rows coverage, atomic _write_json all present; tests 9/9+2/2+3/3, mutation reproduces FAILED(3,2). compileall + check_no_game_data clean. AI-assisted verification.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:45:11Z.
Red/green:
pytest tests/test_psin_psch.pyfails on main (5 failed, 4 passed) and passes on head64b23f4f17merged with main (9 passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)