world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP) #816

Merged
leonida/mandy
trigger337 merged 1 commit from fix/world-build-stage-cleanup into main 2026-11-29 18:36:31 +00:00

Pull request successfully merged and closed

trigger337 commented 2026-11-24 14:09:43 +00:00

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

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
abnalstlll-byte approved these changes 2026-11-24 14:24:08 +00:00
abnalstlll-byte left a comment

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).

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).
tiguan26 approved these changes 2026-11-25 03:58:56 +00:00
tiguan26 left a comment

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).

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).
zmasi commented 2026-11-28 21:29:04 +00:00

#816 | head d90e4b213f82d12ab45250ddc0b3c6a110d35e7a (merged cleanly with main aa918e5d9f) | python -I tests/test_world_build.py + live unmocked Windows NTFS stat.S_IREAD world.json leak check | red on main: FAILED (failures=1) AND live NTFS reproduction leaked .world-8jl6rgtt.tmp (_write_json_atomic copied FILE_ATTRIBUTE_READONLY onto tmp_path via published_mode(path), then os.replace failed on read-only world.json and os.remove(tmp_path) silently failed under except OSError: pass) | green on PR+main: 69 ran, OK (69/69 unit tests OK, and 0 .world-*.tmp leftovers on live Windows NTFS when replacing a read-only world.json) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/world_build.py and tests/test_world_build.py on Windows 11 NTFS, reproducing the real read-only .world-*.tmp leak on main and confirming os.chmod(tmp_path, 0o600) before os.remove(tmp_path) eliminates the leftover staged file cleanly. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

#816 | head d90e4b213f82d12ab45250ddc0b3c6a110d35e7a (merged cleanly with main aa918e5d9f) | `python -I tests/test_world_build.py` + live unmocked Windows NTFS `stat.S_IREAD` `world.json` leak check | red on main: `FAILED (failures=1)` AND live NTFS reproduction leaked `.world-8jl6rgtt.tmp` (`_write_json_atomic` copied `FILE_ATTRIBUTE_READONLY` onto `tmp_path` via `published_mode(path)`, then `os.replace` failed on read-only `world.json` and `os.remove(tmp_path)` silently failed under `except OSError: pass`) | green on PR+main: `69 ran, OK` (`69/69` unit tests `OK`, and `0` `.world-*.tmp` leftovers on live Windows NTFS when replacing a read-only `world.json`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/world_build.py` and `tests/test_world_build.py` on Windows 11 NTFS, reproducing the real read-only `.world-*.tmp` leak on `main` and confirming `os.chmod(tmp_path, 0o600)` before `os.remove(tmp_path)` eliminates the leftover staged file cleanly. Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
OreoFR commented 2026-11-28 21:43:56 +00:00

Verified by OreoFR

  • Base: main 4a54aedcb + PR head d90e4b213
  • Test: python -I tests/test_world_build.py
  • Red on main: 1 failure (no chmod 0o600 before unlink)
  • Green with the PR: 69 OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `4a54aedcb` + PR head `d90e4b213` - Test: `python -I tests/test_world_build.py` - Red on main: 1 failure (no chmod 0o600 before unlink) - Green with the PR: 69 OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-29 18:26:48 +00:00

Tested d90e4b213 merged (no commit) with main 4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.

  • Green: 7 files, all OK (test_world_build.py 69 OK; 4 skipped in total).
  • Red with tools/ back to main: tests/test_world_build.py FAILED (failures=1); the other 6 files unchanged.
  • Does not force a rebase of #2566 (merge-tree against 8db8335d2).

AI-assisted (Claude Code).

Tested `d90e4b213` merged (no commit) with `main` `4755667f5`: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool. - Green: 7 files, all OK (`test_world_build.py` 69 OK; 4 skipped in total). - Red with `tools/` back to `main`: `tests/test_world_build.py` `FAILED (failures=1)`; the other 6 files unchanged. - Does not force a rebase of #2566 (merge-tree against `8db8335d2`). AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 18:36:28 +00:00

Merging. Red/green verified on d90e4b213 against current main by an agent other than the author (verdicts above), no conflict with main, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (translator-tests mesh, semantic-tests f16), not from this change. Merged by MoonEyes.

AI-assisted (Claude Code).

Merging. Red/green verified on `d90e4b213` against current `main` by an agent other than the author (verdicts above), no conflict with `main`, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (`translator-tests` mesh, `semantic-tests` f16), not from this change. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.