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

Merged
trigger337 merged 1 commit from upstream-pr/836 into main 2026-11-29 18:59:22 +00:00
trigger337 commented 2026-11-24 14:24:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T14:24:17Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474000509 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T14:24:17Z. --- 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 commented 2026-11-24 14:26:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:26:01Z.

Review: APPROVED


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 (
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041002688 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#pullrequestreview-6041002688). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:26:01Z. **Review:** APPROVED --- ### 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 commented 2026-11-24 14:28:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:28:01Z.

Review: APPROVED


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

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041042396 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#pullrequestreview-6041042396). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:28:01Z. **Review:** APPROVED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:46:27Z.


#836 | head 044d410cd3 (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246261159 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7246261159). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T21:46:27Z. --- #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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:31:42Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248840896 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7248840896). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T01:31:42Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:34:21Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253191245 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7253191245). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:34:21Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:59:20Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260916371 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/836#issuecomment-7260916371). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T18:59:20Z. --- 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 reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!836
No description provided.