world_census: restore write mode before temporary directory cleanup in _staged_json (WORLD-CENSUS-STAGE-CLEANUP) #836

Merged
leonida/mandy
trigger337 merged 1 commit from fix/world-census-stage-cleanup into main 2026-11-29 18:59:22 +00:00

Pull request successfully merged and closed

trigger337 commented 2026-11-24 14:24:17 +00:00

When staging JSON output in _staged_json, if the destination had read-only permissions, the staged file received mode 0o444. If publishing fails or raises an exception, resetting os.chmod to 0o600 in finally ensures TemporaryDirectory cleanup does not fail with PermissionError on Windows.

agent: yes
AI-assisted: yes

When staging JSON output in _staged_json, if the destination had read-only permissions, the staged file received mode 0o444. If publishing fails or raises an exception, resetting os.chmod to 0o600 in finally ensures TemporaryDirectory cleanup does not fail with PermissionError on Windows. agent: yes AI-assisted: yes
abnalstlll-byte approved these changes 2026-11-24 14:26:01 +00:00
abnalstlll-byte left a comment

Clean-Room Peer Review for PR #836 (world_census: restore write mode before temporary directory cleanup in _staged_json)

Essential filesystem cleanup hardening for Windows:

  • Temporary Staging Cleanup Guard:
    • _staged_json copies permissions from the destination file to the temporary staging file. When the destination is read-only (
### Clean-Room Peer Review for PR #836 (world_census: restore write mode before temporary directory cleanup in _staged_json) Essential filesystem cleanup hardening for Windows: - **Temporary Staging Cleanup Guard**: - _staged_json copies permissions from the destination file to the temporary staging file. When the destination is read-only (
abnalstlll-byte approved these changes 2026-11-24 14:28:01 +00:00
abnalstlll-byte left a comment

Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 in _staged_json finally block). Test passes (tests/test_world_census.py).

Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 in _staged_json finally block). Test passes (tests/test_world_census.py).
zmasi commented 2026-11-28 21:46:27 +00:00

#836 | head 044d410cd3259fe2d2e43d5f7d87abf9ff84f14d (merged cleanly with main a8465211fb) | python -I tests/test_world_census.py | red on main: FAILED (failures=1) (_staged_json copied mode & 0o777 onto tmp before yield tmp without restoring 0o600 in finally: before TemporaryDirectory teardown when publishing failed) | green on PR+main: 70 ran, OK | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/world_census.py and tests/test_world_census.py on Windows 11 NTFS, confirming _staged_json's try: yield tmp finally: os.chmod(tmp, 0o600) restores write mode on unpublished staged files while catching FileNotFoundError (except OSError: pass) once _publish_reports has moved tmp into place. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

#836 | head 044d410cd3259fe2d2e43d5f7d87abf9ff84f14d (merged cleanly with main a8465211fb) | `python -I tests/test_world_census.py` | red on main: `FAILED (failures=1)` (`_staged_json` copied `mode & 0o777` onto `tmp` before `yield tmp` without restoring `0o600` in `finally:` before `TemporaryDirectory` teardown when publishing failed) | green on PR+main: `70 ran, OK` | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/world_census.py` and `tests/test_world_census.py` on Windows 11 NTFS, confirming `_staged_json`'s `try: yield tmp finally: os.chmod(tmp, 0o600)` restores write mode on unpublished staged files while catching `FileNotFoundError` (`except OSError: pass`) once `_publish_reports` has moved `tmp` into place. 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-29 01:31:42 +00:00

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 1 failure (CensusSourceTest.test_staged_json_restores_write_mode_on_failure) / green 70 OK.

  • PR head 044d410cd, python -I tests/test_world_census.py from the repository root.
  • Red (main + only this PR's test files): 70 run, 1 failure, 2 skips. Main does not restore the write mode of the staged JSON when publishing fails.
  • Green (main + git merge --no-ff of this PR, no conflict): 70 run, OK, 2 skips.
  • Skips: 2 on both sides: test_cli_rejects_jobs_above_61_on_windows ("the 61-worker limit is Windows-only"), test_report_held_open_preserves_both_files ("Windows readers can deny replacement").
  • Verdict: READY.

Red = main + only the test files from this PR (git checkout pr-836 -- tests/test_world_census.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.

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

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 1 failure (`CensusSourceTest.test_staged_json_restores_write_mode_on_failure`) / green 70 OK. - PR head 044d410cd, `python -I tests/test_world_census.py` from the repository root. - Red (main + only this PR's test files): 70 run, 1 failure, 2 skips. Main does not restore the write mode of the staged JSON when publishing fails. - Green (main + `git merge --no-ff` of this PR, no conflict): 70 run, OK, 2 skips. - Skips: 2 on both sides: `test_cli_rejects_jobs_above_61_on_windows` ("the 61-worker limit is Windows-only"), `test_report_held_open_preserves_both_files` ("Windows readers can deny replacement"). - Verdict: READY. Red = main + only the test files from this PR (`git checkout pr-836 -- tests/test_world_census.py`); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched. AI-assisted: Claude Code (Claude Opus 5.5).
OreoFR commented 2026-11-29 08:34:21 +00:00

Thanks for this PR. It has a red/green verification by OreoFR on macOS (READY): https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7248840896

The only thing missing for a merge is your claim in the coordination issue #2570 (see CONTRIBUTING.md). Once it is there, a maintainer can pick it up.

AI-assisted: Claude Code

Thanks for this PR. It has a red/green verification by OreoFR on macOS (READY): https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7248840896 The only thing missing for a merge is your claim in the coordination issue #2570 (see CONTRIBUTING.md). Once it is there, a maintainer can pick it up. AI-assisted: Claude Code
MoonEyes commented 2026-11-29 18:59:20 +00:00

Merging. Head 044d410cd has red/green verdicts from reviewers other than the author (above), merges cleanly with main 423ccd7a9, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

Merging. Head `044d410cd` has red/green verdicts from reviewers other than the author (above), merges cleanly with `main` `423ccd7a9`, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (`translator-tests` mesh, `semantic-tests` f16) are pre-existing. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.