gen_gdk_runtime_classes: write --out atomically #1668
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1668"
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 xel1uz on 2026-11-25T07:39:20Z.
Item ID:
GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT(new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)Claimed as:
GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT- a failed--outwrite truncates an existing file and leaves a partial one behind. Reproduced on42537e7b.What and why
The generator opened its target with
open(a.out, "w")and thenjson.dumped into it, so the previous table was truncated the moment the file was opened; a short or failed write left partial JSON behind.The table is now written to a temp file in the destination directory and published with
os.replace; failures clean the temp file up and keep the previous table.Tested
pytest tests/test_gen_gdk_runtime_classes.py -qwith the tool at42537e7b: 1 failed, 2 passed.With this branch: 3 passed.
Repro with 128 synthetic classes, a 14-byte existing output and
ulimit -f 1: the original grew the file 14 -> 1024 bytes (partial JSON); with this patch it stayed 14 bytes and no temp file remained.git diff --checkclean;python3 -I scripts/check_no_game_data.pyclean on the changed files.GPUs tested: n/a - CPU only, no Vulkan device involved.
AI-assisted: Yes.
Checklist
main(42537e7b) and merges cleanly.docs/design.md- not applicable, no translator change.Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T09:11:24Z.
Independent verification (Windows, Python 3.11.9): the tool change itself is correct — atomic mkstemp+chmod+os.replace in dest dir, mode preserved, verified on a synthetic docs tree. But the new test file is POSIX-only and breaks Windows CI: top-level
import resource,signal.SIGXFSZ,preexec_fn—python -I tests/test_gen_gdk_runtime_classes.pyfails at import on Windows (ModuleNotFoundError: No module named 'resource'). The windows-latestcheckjob runs exactly this, so it will fail. Repo convention for this pattern is@unittest.skipUnless(os.name == "posix")+ lazyimport resourceinside a subprocess script — seetests/test_rpf_probe.py. AI-assisted verification.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:04:25Z.
Hi @xel1uz, thanks for this pull request.
CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post
claiming: <ID>there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.
Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:38:35Z.
Tested
f85de7d95merged (no commit) withmainaa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.Blocker on Windows: the new
tests/test_gen_gdk_runtime_classes.pyimportsresourceat module level (line 5, forRLIMIT_FSIZE). That module does not exist on Windows, so the file stops withModuleNotFoundError: No module named 'resource'and none of its tests run, with or without the fix.Importing it only inside the size-limit test, and skipping that test when the import fails, would let the rest run here.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:26:12Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
53b77df14: red 1 failure (GenGdkRuntimeClassesTests.test_failed_write_preserves_existing_file) / green 3 OK.f85de7d95,python -I tests/test_gen_gdk_runtime_classes.py.resourcelimit the test needs.b'{\\n "classes": {}, ...' != b'previous table must survive\\n'). MEASURED, the test alone 3 runs, 3/3 fail.Red = main + only the test file from this PR (
git checkout pr-N -- <test>); green = main +git merge --no-ffof this PR, no conflict. Green runs more tests than red because the merge keeps the tests main added to this file since the PR branched; that is the method, not a finding.AI-assisted: Claude Code (Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:11:19Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
4364a4fa6, PR headf85de7d95: red 1 failure / green 3 OKRe-check on the current main (same head as my earlier verification).
git merge-tree). Reviews: none. No game data in the diff. Skipped on the merge: none.test_failed_write_preserves_existing_file.test_gdk_runtime_calls,test_gen_gdk_classes_out_dir): 26 passed on main and merge.os.close(fd)in the failure path as #1648.Verdict: READY
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T18:28:26Z.
Thank you! Merged into
mainwith a merge commit. It was verified ready on its current head (f85de7d95) by OreoFR's Mac agent (macOS, red/green on main + PR); see the verification comment above. (AI-assisted, posted for DadaCap.)