tools: make gamedata_sps1.py --json writes atomic, validate paths and avoid duplicate index read #1817
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1817
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1817/head"
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?
@kirigayakazima on GitHub · 2026-11-25 12:29 UTC · original
kirigayakazima:fix/gamedata-sps1-atomic-json→main· +176 −6 · 2 files · 1 commits · merged 2026-11-25 17:33 UTCClaimed in the coordination issue as: GAMEDATA-SPS1-ATOMIC-JSON-AND-PATH-SAFETY (#1608)
What and why
tools/gamedata_sps1.py--jsonreports atomically via_write_json_atomic()(tempfile.mkstempbesideos.path.realpath(path), explicitnewline="\n", trailing\n,os.fsync,published_mode, andreplace_retry), preserving any existing file and cleaning up staging files on write/replace failure.--jsonpaths upfront viaap.error(...)(exit2).rowsinread_payloads(target, rows=None)so directory CLI runs reuse the already-parsedindex.jsonrows instead of reading and parsingindex.jsontwice.tests/test_gamedata_sps1_atomic.py(leavingtests/test_gamedata_sps1.pyuntouched).Tested
python -I tests/test_gamedata_sps1.py -v->Ran 7 tests in 0.884s,OK.python -I tests/test_gamedata_sps1_atomic.py -v->Ran 5 tests in 0.048s,OK(verified in a detachedupstream/mainworktree that the new regression suite fails before the fix:FAILED (failures=7)).python -I tests/test_ci_registration.py->Ran 16 tests in 4.722s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 12.631s,OK.python -I scripts/check_no_game_data.py tools/gamedata_sps1.py tests/test_gamedata_sps1_atomic.py-> exit0.python -I -m compileall -q tools/gamedata_sps1.py tests/test_gamedata_sps1_atomic.pyandgit diff --check-> clean.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).@madvillain91 on GitHub · 2026-11-25 13:14 UTC · original · reviewed
Independent Windows 11 26H2 (26300.9711) check at
def89c3aaagainst main98c2f7777(PR base0d80bc5df), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_gamedata_sps1.py (7/7, 1.454s), test_gamedata_sps1_atomic.py (4 passed, 1 symlink test skipped on WinError 1314 without SeCreateSymbolicLinkPrivilege, 0.061s), test_ci_registration.py (16/16, 7.547s), and test_text_write_line_endings.py (3/3, 13.605s), with check_no_game_data.py and compileall clean. Verified single index.json read when targeting a directory, atomic --json write via replace_retry with LF trailing newline and staging cleanup on failure, and empty/whitespace/trailing-separator --json path validation. LGTM.@DeadlyChirp on GitHub · 2026-11-25 15:51 UTC · original
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_gamedata_sps1_atomic.py:[WinError 1314] A required privilege is not held by the client(no symlink privilege on this machine).(AI-assisted test run; output checked by hand.)
@aslan2142 on GitHub · 2026-11-25 17:33 UTC · original
Merged. Thank you, @kirigayakazima.
--jsonwrites are atomic, and paths are validated.mainand pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.maina8266e3f8+def89c3aa: the semantic suite passes (490 files, 6,292 tests, 0 files failed);test_gamedata_sps1_atomicpass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 2 changed files.AI-assisted (Claude Code, Claude Opus 5.5).