awc_manifest: publish mode on Windows (AWC-MANIFEST-STAGE-CLEANUP) #779

Merged
trigger337 merged 3 commits from upstream-pr/779 into main 2026-12-01 12:53:58 +00:00
trigger337 commented 2026-11-24 13:43:54 +00:00 (Migrated from github.com)

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


In tools/awc_manifest.py, write_manifest already restored 0o600 before unlinking on failure in its finally 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 (25/25 in test_awc_manifest.py), scripts/check_no_game_data.py passes cleanly.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473316080 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T13:43:54Z. --- In `tools/awc_manifest.py`, `write_manifest` already restored `0o600` before unlinking on failure in its `finally` 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 (25/25 in `test_awc_manifest.py`), `scripts/check_no_game_data.py` passes cleanly. agent: yes AI-assisted: yes
tiguan26 commented 2026-11-25 04:01:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T04:01:36Z.

Review: APPROVED


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: the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051678687 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#pullrequestreview-6051678687). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T04:01:36Z. **Review:** APPROVED --- 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: the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change. AI-assisted (Claude).
DeadlyChirp commented 2026-11-25 15:23:53 +00:00 (Migrated from github.com)

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


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

python -I tests/test_awc_manifest.py:

  • PR: 25 tests OK (2 skipped). main: 23 tests OK (2 skipped).
  • The skips are the existing symlink tests (WinError 1314, no symlink privilege). The 2 new tests run and pass.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166778925 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/779#issuecomment-7166778925). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-25T15:23:53Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit 1ed165078). `python -I tests/test_awc_manifest.py`: - PR: 25 tests OK (2 skipped). main: 23 tests OK (2 skipped). - The skips are the existing symlink tests (`WinError 1314`, no symlink privilege). The 2 new tests run and pass. (AI-assisted test run; output checked by hand.)
PierreEbele commented 2026-11-25 20:09:15 +00:00 (Migrated from github.com)

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


Reviewed ff7a65d: I ran python3 -I tests/test_awc_manifest.py (25/25 on the PR), test_csv_line_endings.py, test_file_mode.py, test_report_paths.py and check_no_game_data.py (all clean) on Linux, plus a probe against origin/main. No product bug or behavioral difference in any reachable scenario - and on main with this PR's test file all 25 tests pass, so neither new test pins the diff: the cleanup test raises at the pre-stage os.open check before anything is staged (probe: staged file created: False on both trees) and cannot fail on main in any environment, the cleanup it names being already covered by test_failed_replace_removes_the_staging_file_and_keeps_the_manifest; the os.name="nt" test passes on main because the finally: chmod(0o600) still fires on the renamed-away staged name and the patched mock counts that call before its FileNotFoundError is swallowed. Suggested: drop the cleanup test and assert the published mode instead - over a 0o640 destination with os.name="nt", main republishes at 0o600 while this branch preserves 0o640. The guard drop itself is fine and consistent with bvh_index/anim_glb/awc_opus. AI-assisted review.

Recommendation: Fix first

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7173262521 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/779#issuecomment-7173262521). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T20:09:15Z. --- Reviewed ff7a65d: I ran `python3 -I tests/test_awc_manifest.py` (25/25 on the PR), `test_csv_line_endings.py`, `test_file_mode.py`, `test_report_paths.py` and `check_no_game_data.py` (all clean) on Linux, plus a probe against `origin/main`. No product bug or behavioral difference in any reachable scenario - and on main with this PR's test file all 25 tests pass, so neither new test pins the diff: the cleanup test raises at the pre-stage `os.open` check before anything is staged (probe: `staged file created: False` on both trees) and cannot fail on main in any environment, the cleanup it names being already covered by `test_failed_replace_removes_the_staging_file_and_keeps_the_manifest`; the os.name="nt" test passes on main because the `finally:` chmod(0o600) still fires on the renamed-away staged name and the patched mock counts that call before its FileNotFoundError is swallowed. Suggested: drop the cleanup test and assert the published mode instead - over a 0o640 destination with `os.name="nt"`, main republishes at 0o600 while this branch preserves 0o640. The guard drop itself is fine and consistent with bvh_index/anim_glb/awc_opus. AI-assisted review. **Recommendation:** Fix first
tiguan26 commented 2026-11-26 06:59:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-26T06:59:05Z.


Confirming @PierreEbele's finding: with this PR's test file against main's tool, every test passes here too (Linux, run as root), so neither new test pins the change. My approval was for the guard removal, which is right and matches the other writers; I didn't check that the tests fail without it. Asserting the published mode over a non-default destination mode with os.name patched to nt, as the review suggests, would pin it. AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7184976894 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/779#issuecomment-7184976894). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-26T06:59:05Z. --- Confirming @PierreEbele's finding: with this PR's test file against main's tool, every test passes here too (Linux, run as root), so neither new test pins the change. My approval was for the guard removal, which is right and matches the other writers; I didn't check that the tests fail without it. Asserting the published mode over a non-default destination mode with `os.name` patched to `nt`, as the review suggests, would pin it. AI-assisted (Claude).
zmasi commented 2026-11-29 00:44:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:44:05Z.


Independent verification on Windows 11 (10.0.26200, x64) of ef0fb06124 merged onto origin/main (e66c65b950, 0 merge conflicts) under both Python 3.12.10 and Python 3.14.5:

  • Green (ef0fb06124 merged onto origin/main):
    • python -I tests/test_awc_manifest.py: Ran 26 tests, OK (skipped=2) on Python 3.12.10 (6.04 s) and Python 3.14.5 (3.18 s; the 2 skips are the existing WinError 1314 symlink privilege checks).
    • python -I tests/test_file_mode.py: Ran 5 tests, OK (skipped=2) on both Python versions.
    • Unmocked NTFS check: writing a new manifest.json publishes 0o666, and attempting to overwrite a 0o444 manifest.json raises PermissionError cleanly with 0 leftover .awc_manifest-*.tmp files.
  • Red-check finding confirmed on native Windows 11 (ef0fb06124 test file against origin/main tools/awc_manifest.py):
    • Running #779's tests/test_awc_manifest.py against unpatched origin/main tools/awc_manifest.py also passes 26/26 (OK (skipped=2)) on both Python 3.12.10 and Python 3.14.5, confirming on native Windows what earlier Linux reviews noted on ff7a65d:
      1. In test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly, setting os.chmod(path, 0o444) causes os.close(os.open(destination, os.O_WRONLY)) at tools/awc_manifest.py:227 to raise PermissionError before NamedTemporaryFile creates a staging file.
      2. In test_publish_applies_published_mode_on_windows, self.assertTrue(len(chmod_calls) > 0) passes even when if os.name != "nt": skips line 237 because finally: at line 243 calls os.chmod(staged.name, 0o600) after replace_retry renames staged.name (track_chmod appends before real_chmod raises FileNotFoundError). Stubbing published_mode to a distinct mode (e.g. 0o640) and asserting (staged_name, 0o640) was passed before replace_retry would pin the guard removal directly.
  • Hygiene: git diff --check, python -I -m compileall -q, and python -I scripts/check_no_game_data.py all exited 0.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248314771 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7248314771). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:44:05Z. --- Independent verification on Windows 11 (`10.0.26200`, x64) of `ef0fb06124` merged onto `origin/main` (`e66c65b950`, `0` merge conflicts) under both `Python 3.12.10` and `Python 3.14.5`: - **Green (`ef0fb06124` merged onto `origin/main`)**: - `python -I tests/test_awc_manifest.py`: `Ran 26 tests`, `OK (skipped=2)` on `Python 3.12.10` (`6.04 s`) and `Python 3.14.5` (`3.18 s`; the 2 skips are the existing `WinError 1314` symlink privilege checks). - `python -I tests/test_file_mode.py`: `Ran 5 tests`, `OK (skipped=2)` on both Python versions. - Unmocked NTFS check: writing a new `manifest.json` publishes `0o666`, and attempting to overwrite a `0o444` `manifest.json` raises `PermissionError` cleanly with `0` leftover `.awc_manifest-*.tmp` files. - **Red-check finding confirmed on native Windows 11 (`ef0fb06124` test file against `origin/main` `tools/awc_manifest.py`)**: - Running `#779`'s `tests/test_awc_manifest.py` against unpatched `origin/main` `tools/awc_manifest.py` also passes `26/26` (`OK (skipped=2)`) on both `Python 3.12.10` and `Python 3.14.5`, confirming on native Windows what earlier Linux reviews noted on `ff7a65d`: 1. In `test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly`, setting `os.chmod(path, 0o444)` causes `os.close(os.open(destination, os.O_WRONLY))` at `tools/awc_manifest.py:227` to raise `PermissionError` before `NamedTemporaryFile` creates a staging file. 2. In `test_publish_applies_published_mode_on_windows`, `self.assertTrue(len(chmod_calls) > 0)` passes even when `if os.name != "nt":` skips line `237` because `finally:` at line `243` calls `os.chmod(staged.name, 0o600)` after `replace_retry` renames `staged.name` (`track_chmod` appends before `real_chmod` raises `FileNotFoundError`). Stubbing `published_mode` to a distinct mode (e.g. `0o640`) and asserting `(staged_name, 0o640)` was passed before `replace_retry` would pin the guard removal directly. - **Hygiene**: `git diff --check`, `python -I -m compileall -q`, and `python -I scripts/check_no_game_data.py` all exited `0`. AI-assisted.
OreoFR commented 2026-11-29 01:31:45 +00:00 (Migrated from github.com)

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


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

  • PR head ef0fb0612, python -I tests/test_awc_manifest.py from the repository root.
  • Red (main + only this PR's test files): 26 run, OK, 0 skips. The new tests do not fail on main.
  • Green (main + git merge --no-ff of this PR, no conflict): 26 run, OK, 0 skips.
  • Skips: none.
  • Why there is no red (READ IN CODE): main's write_manifest always calls os.chmod(staged.name, 0o600) in its finally, so the new test_publish_applies_published_mode_on_windows, which only checks that some chmod call happened (len(chmod_calls) > 0), passes on main with os.name faked as "nt"; it does not check for the published_mode call the fix restores. test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly also passes on main.
  • Suggestion: assert a chmod with the published mode (as #792 and #752 effectively catch).
  • Verdict: NO RED.

Red = main + only the test files from this PR (git checkout pr-779 -- tests/test_awc_manifest.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:7248841491 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7248841491). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T01:31:45Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 26 OK (no failure) / green 26 OK. - PR head ef0fb0612, `python -I tests/test_awc_manifest.py` from the repository root. - Red (main + only this PR's test files): 26 run, OK, 0 skips. The new tests do not fail on main. - Green (main + `git merge --no-ff` of this PR, no conflict): 26 run, OK, 0 skips. - Skips: none. - Why there is no red (READ IN CODE): main's `write_manifest` always calls `os.chmod(staged.name, 0o600)` in its `finally`, so the new `test_publish_applies_published_mode_on_windows`, which only checks that some chmod call happened (`len(chmod_calls) > 0`), passes on main with `os.name` faked as `"nt"`; it does not check for the `published_mode` call the fix restores. `test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly` also passes on main. - Suggestion: assert a chmod with the published mode (as #792 and #752 effectively catch). - Verdict: NO RED. Red = main + only the test files from this PR (`git checkout pr-779 -- tests/test_awc_manifest.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).
trigger337 commented 2026-11-30 10:40:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-30T10:40:55Z.


@PierreEbele @tiguan26 @OreoFR Updated tests/test_awc_manifest.py so test_publish_applies_published_mode_on_windows asserts that published_mode (0o640) was applied to the staged file rather than checking len(chmod_calls) > 0. Confirmed RED on unpatched main (AssertionError: False is not true : [('/tmp/.../.awc_manifest-...tmp', 384)]) and GREEN (26/26 tests OK) on the PR head. Also merged latest main and registered in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275926701).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7275932135 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7275932135). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-30T10:40:55Z. --- @PierreEbele @tiguan26 @OreoFR Updated `tests/test_awc_manifest.py` so `test_publish_applies_published_mode_on_windows` asserts that `published_mode` (0o640) was applied to the staged file rather than checking `len(chmod_calls) > 0`. Confirmed RED on unpatched main (`AssertionError: False is not true : [('/tmp/.../.awc_manifest-...tmp', 384)]`) and GREEN (26/26 tests OK) on the PR head. Also merged latest `main` and registered in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275926701). AI-assisted: yes
aslan2142 commented 2026-12-01 11:38:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:38:55Z.

Review: APPROVED


Reviewed the diff against main: tools/awc_manifest.py:236 cleanly removes the os.name != "nt" guard so published_mode applies on Windows too, and tests/test_awc_manifest.py:465-500 verifies both read-only replace-failure cleanup and exact published_mode (0o640) application. Clean-room verified. Approving; please merge current main so CI re-runs green past the old tools/d3d12_run_fps.py failure before merge.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130472393 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#pullrequestreview-6130472393). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:38:55Z. **Review:** APPROVED --- Reviewed the diff against `main`: `tools/awc_manifest.py:236` cleanly removes the `os.name != "nt"` guard so `published_mode` applies on Windows too, and `tests/test_awc_manifest.py:465-500` verifies both read-only replace-failure cleanup and exact `published_mode` (`0o640`) application. Clean-room verified. Approving; please merge current `main` so CI re-runs green past the old `tools/d3d12_run_fps.py` failure before merge. *(AI-assisted review.)*
MoonEyes commented 2026-12-01 12:31:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T12:31:23Z.


Verified by MoonEyes (another person than the author) on head d401ff120 merged with main c60ce461a: Windows 11, Python 3.14, CPU only. I read the whole diff. tests/test_awc_manifest.py 26 OK (2 skipped); with tools/awc_manifest.py back to main, 1 failure. Neighbours OK.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311252244 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7311252244). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T12:31:23Z. --- Verified by MoonEyes (another person than the author) on head `d401ff120` merged with `main` `c60ce461a`: Windows 11, Python 3.14, CPU only. I read the whole diff. `tests/test_awc_manifest.py` 26 OK (2 skipped); with `tools/awc_manifest.py` back to `main`, 1 failure. Neighbours OK. AI-assisted (Claude Code).
MoonEyes commented 2026-12-01 12:37:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T12:37:30Z.


Closing and reopening this so that CI runs again on the current main. Nothing else changes, the head stays d401ff120. MoonEyes's agent.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311408496 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7311408496). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T12:37:30Z. --- Closing and reopening this so that CI runs again on the current `main`. Nothing else changes, the head stays `d401ff120`. MoonEyes's agent.
aslan2142 commented 2026-12-01 12:53:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:53:27Z.


Fresh CI checks are all green and the PR is MERGEABLE/CLEAN on current main. Merging now.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311796970 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/779#issuecomment-7311796970). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:53:27Z. --- Fresh CI checks are all green and the PR is `MERGEABLE`/`CLEAN` on current `main`. Merging now. *(AI-assisted review.)*
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!779
No description provided.