world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP) #816
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!816
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/world-build-stage-cleanup"
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?
Pull request successfully merged and closed
When writing world JSON atomically, if os.replace fails (for instance due to permission errors), resetting os.chmod to 0o600 ensures unlinking the temporary file does not fail on Windows with PermissionError.
agent: yes
AI-assisted: yes
Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 before removal in _write_json_atomic). Unit tests pass (tests/test_world_build.py: 12/12 WorldBuildStagingTest PASS).
Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed. Only the staging/permission lines change.
AI-assisted (Claude).
#816 | head d90e4b213f82d12ab45250ddc0b3c6a110d35e7a (merged cleanly with main aa918e5d9f) |
python -I tests/test_world_build.py+ live unmocked Windows NTFSstat.S_IREADworld.jsonleak check | red on main:FAILED (failures=1)AND live NTFS reproduction leaked.world-8jl6rgtt.tmp(_write_json_atomiccopiedFILE_ATTRIBUTE_READONLYontotmp_pathviapublished_mode(path), thenos.replacefailed on read-onlyworld.jsonandos.remove(tmp_path)silently failed underexcept OSError: pass) | green on PR+main:69 ran, OK(69/69unit testsOK, and0.world-*.tmpleftovers on live Windows NTFS when replacing a read-onlyworld.json) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited
tools/world_build.pyandtests/test_world_build.pyon Windows 11 NTFS, reproducing the real read-only.world-*.tmpleak onmainand confirmingos.chmod(tmp_path, 0o600)beforeos.remove(tmp_path)eliminates the leftover staged file cleanly. Also verifiedtests/test_ci_registration.py,tests/test_text_write_line_endings.py, andscripts/check_no_game_data.py.Verified by OreoFR
4a54aedcb+ PR headd90e4b213python -I tests/test_world_build.pyAI-assisted (Claude Code, Claude Opus 5.5).
Tested
d90e4b213merged (no commit) withmain4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.test_world_build.py69 OK; 4 skipped in total).tools/back tomain:tests/test_world_build.pyFAILED (failures=1); the other 6 files unchanged.8db8335d2).AI-assisted (Claude Code).
Merging. Red/green verified on
d90e4b213against currentmainby an agent other than the author (verdicts above), no conflict withmain, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (translator-testsmesh,semantic-testsf16), not from this change. Merged by MoonEyes.AI-assisted (Claude Code).