sandbox_scene: write --out atomically #1669
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1669"
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:24Z.
Item ID:
SANDBOX-SCENE-ATOMIC-OUT(new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)Claimed as:
SANDBOX-SCENE-ATOMIC-OUT- a failed--outwrite truncates an existing file and leaves a partial one behind. Reproduced on42537e7b.What and why
The scene was written straight to the target with
open(args.out, "wb"), so an interrupted or failed write left a half-written binary and the previous baseline was lost.The scene is now written to a temp file in the destination directory and moved into place with
os.replace, which also keeps the target's existing permissions; a failure removes the temp file and leaves the previous output intact.Tested
pytest tests/test_sandbox_scene.py -qwith the tool at42537e7b: 1 failed, 14 passed, 5 subtests passed - the failure istest_failed_write_preserves_existing_output.With this branch: 15 passed, 5 subtests passed.
Repro with
ulimit -f 1: exit 2 and the file went 20 -> 1024 bytes on the original, versus 20 -> 20 bytes here with no temp file left. A successful run produces the same 2256 bytes (identical SHA-256) before and after.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-25T08:52:16Z.
Heads-up from independent verification (Windows, Python 3.11.9): the tool change itself is correct (mkstemp + chmod + os.replace, LF endings, check_no_game_data clean), but the 3 new tests are POSIX-only and fail on Windows —
python -I tests/test_sandbox_scene.pygives 2 failures:test_failed_write_preserves_existing_outputneedsulimit -f/SIGXFSZ, andtest_successful_write_preserves_scene_bytesassertsst_mode == 0o640which Windows chmod cannot produce (got 0o666). The windows-latest CI leg runs exactlypython -Ion this file, so this will fail Windows CI unless the tests getskipUnless(os.name == "posix")or platform-aware assertions. Should pass on the Linux/pytest leg per your report. AI-assisted verification.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:04:39Z.
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:33Z.
Tested
24278bbdcmerged (no commit) withmainaa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.Blocker on Windows: two of the new tests in
tests/test_sandbox_scene.pyfail here, with and without the fix. The 15 others pass.test_failed_write_preserves_existing_outputstarts the tool throughbashto set a file-size limit. Here that launch fails, soFile too largenever appears in stderr.test_successful_write_preserves_scene_bytesexpectsst_mode & 0o777 == 0o640, but Windows reports0o666(438 != 416).Skipping these two where the platform cannot give them (no POSIX shell or
chmodmodes), or checking only what Windows supports, would make the file pass here. The atomic write itself is not red/green-testable on this machine for that reason.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:26:10Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
53b77df14: red 1 failure (TestAtomicSceneOutput.test_failed_write_preserves_existing_output) / green 17 OK.24278bbdc,python -I tests/test_sandbox_scene.py.chmodmodes are real.b'LSB1...' != b'pre-existing scene contents'). MEASURED, TestAtomicSceneOutput alone 3 runs, 3/3 fail.test_successful_write_preserves_scene_bytes(the 0o640 mode check) passes on both sides here, so it guards the mode but is not a red test.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:54:40Z.
Re-verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
4364a4fa6, PR head24278bbdc(unchanged since my earlier check) : red 1 failure / green 17 OKpython3.12 -I tests/test_sandbox_scene.py:git merge-tree). main changed this test file since the PR base (#2442 and two other commits), so red = the merged test file against main's code: 17 tests, 1 failure:TestAtomicSceneOutput.test_failed_write_preserves_existing_output(MEASURED n=3). The raw red (PR's older test file, 15 tests) shows the same failure.git merge --no-ff): 17/17 OK, skipped 0.Verdict: READY (still missing the author's claim in the coordination issue).
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:59:11Z.
Merging. Head
24278bbdchas red/green verdicts from reviewers other than the author (above), merges cleanly withmainbcbbd9a9c, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-testsmesh,semantic-testsf16) are pre-existing. Merged by MoonEyes.AI-assisted (Claude Code).