mode_round_probe: publish mode on Windows (MODE-ROUND-PROBE-STAGE-CLEANUP) #797

Merged
trigger337 merged 1 commit from upstream-pr/797 into main 2026-11-28 11:07:48 +00:00
trigger337 commented 2026-11-24 13:57:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T13:57:08Z.


In tools/mode_round_probe.py, write_json_report already restored 0o600 before unlinking on failure in its except BaseException block, but previously skipped applying published_mode on Windows via if os.name != "nt":.

Remove the Windows skip so Windows outputs inherit published permissions consistently across platforms, and add synthetic regression tests for cleanup on replace failure and Windows published_mode application.

Tests pass (13/13 in test_mode_round_probe.py), scripts/check_no_game_data.py passes cleanly.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473536841 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/797). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T13:57:08Z. --- In `tools/mode_round_probe.py`, `write_json_report` already restored `0o600` before unlinking on failure in its `except BaseException` block, but previously skipped applying `published_mode` on Windows via `if os.name != "nt":`. Remove the Windows skip so Windows outputs inherit published permissions consistently across platforms, and add synthetic regression tests for cleanup on replace failure and Windows `published_mode` application. Tests pass (13/13 in `test_mode_round_probe.py`), `scripts/check_no_game_data.py` passes cleanly. agent: yes AI-assisted: yes
DeadlyChirp commented 2026-11-25 15:23:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:23:56Z.


Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit d70e9d631).

python -I tests/test_mode_round_probe.py:

  • PR: 13 tests OK. main: 11 tests OK. The 2 new tests pass on Windows.

(AI-assisted test run; output checked by hand.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166780270 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/797#issuecomment-7166780270). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-25T15:23:56Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit d70e9d631). `python -I tests/test_mode_round_probe.py`: - PR: 13 tests OK. main: 11 tests OK. The 2 new tests pass on Windows. (AI-assisted test run; output checked by hand.)
PierreEbele commented 2026-11-25 20:45:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T20:45:34Z.


Reviewed a94cb3b8: I ran tests/test_mode_round_probe.py on the PR (13 OK) and on main (11 OK), with this PR's test file on main (only test_publish_applies_published_mode_on_windows fails there, so it does pin the fix), plus check_no_game_data.py and a probe comparing the two trees. The guard removal is right and consistent with the other staging writers; issues in the new tests: (1) test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly never reaches the staging code - with a 0o444 destination, os.open(destination, os.O_WRONLY) (line 225) fails before any temp file is created (probe: replace/unlink mocks 0 calls, on main too); patch published_mode to return 0o444 with a writable destination so the cleanup path is actually exercised; (2) that test leaves report.json at 0o444, which on a native Windows run makes TemporaryDirectory teardown fail with PermissionError - restore 0o600 in a finally like the existing readonly test; I could not run Windows here, so (2) is from shutil.rmtree/read-only semantics, not an execution; (3) the new tests belong in ModeRoundProbeTests next to the other publish tests rather than SummaryLineTests. AI-assisted review.

Recommendation: Fix first

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174147883 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/797#issuecomment-7174147883). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T20:45:34Z. --- Reviewed a94cb3b8: I ran `tests/test_mode_round_probe.py` on the PR (13 OK) and on `main` (11 OK), with this PR's test file on `main` (only `test_publish_applies_published_mode_on_windows` fails there, so it does pin the fix), plus `check_no_game_data.py` and a probe comparing the two trees. The guard removal is right and consistent with the other staging writers; issues in the new tests: (1) `test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly` never reaches the staging code - with a `0o444` destination, `os.open(destination, os.O_WRONLY)` (line 225) fails before any temp file is created (probe: replace/unlink mocks 0 calls, on `main` too); patch `published_mode` to return `0o444` with a writable destination so the cleanup path is actually exercised; (2) that test leaves `report.json` at `0o444`, which on a native Windows run makes `TemporaryDirectory` teardown fail with `PermissionError` - restore `0o600` in a `finally` like the existing readonly test; I could not run Windows here, so (2) is from `shutil.rmtree`/read-only semantics, not an execution; (3) the new tests belong in `ModeRoundProbeTests` next to the other publish tests rather than `SummaryLineTests`. AI-assisted review. **Recommendation:** Fix first
MoonEyes commented 2026-11-28 11:07:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T11:07:45Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238345770 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/797#issuecomment-7238345770). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T11:07:45Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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!797
No description provided.