manifest_verifier: restore write mode before unlink on replace failure and publish mode (MANIFEST-VERIFIER-STAGE-CLEANUP) #899

Merged
trigger337 merged 1 commit from upstream-pr/899 into main 2026-11-29 18:36:55 +00:00
trigger337 commented 2026-11-24 15:03:08 +00:00 (Migrated from github.com)

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


Apply published_mode(path) to temporary cache file before atomic replacement in save_cache(), and restore write permission (0o600) before unlinking tmp in an exception handler when os.replace fails. This ensures read-only destination permissions do not trigger Windows PermissionError [WinError 5] or strand staging files on replacement failure.

Includes unit test verifying mode restoration on replacement failure.

Clean-room / zero game data verified via scripts/check_no_game_data.py.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474703543 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/899). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T15:03:08Z. --- Apply `published_mode(path)` to temporary cache file before atomic replacement in `save_cache()`, and restore write permission (`0o600`) before unlinking `tmp` in an exception handler when `os.replace` fails. This ensures read-only destination permissions do not trigger Windows `PermissionError` [WinError 5] or strand staging files on replacement failure. Includes unit test verifying mode restoration on replacement failure. Clean-room / zero game data verified via `scripts/check_no_game_data.py`. agent: yes AI-assisted: yes
LewisStephens99 commented 2026-11-24 15:10:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LewisStephens99 on 2026-11-24T15:10:08Z.


Independent verification on Windows 11, Python 3.14: 57/58 tests passed; test_save_cache_stage_cleanup_restores_write_mode_on_replace_failure fails because Windows reports st_mode & 0o777 as 0o666 for both chmod(..., 0o600) and chmod(..., 0o666) in this environment. The implementation does execute os.chmod(tmp, 0o600) before unlink in the replacement-failure exception path, so this appears to be a cross-platform assertion issue: test os.chmod calls directly or skip exact POSIX mode reads on Windows. No source crash or cleanup failure observed; no game data or GPU used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7135571146 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/899#issuecomment-7135571146). Originally posted by [LewisStephens99](https://github.com/LewisStephens99) on 2026-11-24T15:10:08Z. --- Independent verification on Windows 11, Python 3.14: 57/58 tests passed; `test_save_cache_stage_cleanup_restores_write_mode_on_replace_failure` fails because Windows reports `st_mode & 0o777` as `0o666` for both `chmod(..., 0o600)` and `chmod(..., 0o666)` in this environment. The implementation does execute `os.chmod(tmp, 0o600)` before unlink in the replacement-failure exception path, so this appears to be a cross-platform assertion issue: test `os.chmod` calls directly or skip exact POSIX mode reads on Windows. No source crash or cleanup failure observed; no game data or GPU used.
OreoFR commented 2026-11-28 21:45:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:45:14Z.


Verified by OreoFR

  • Base: main 4a54aedcb + PR head 02f5f2a68 (tested at 02f5f2a68, head is now ff28c7104)
  • Test: python -I tests/test_manifest_verifier.py
  • Red on main: 1 failure (no chmod 0o600 on cleanup)
  • Green with the PR: OK (4 skipped)
  • 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246246752 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/899#issuecomment-7246246752). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:45:14Z. --- **Verified by OreoFR** - Base: main `4a54aedcb` + PR head `02f5f2a68` (tested at `02f5f2a68`, head is now `ff28c7104`) - Test: `python -I tests/test_manifest_verifier.py` - Red on main: 1 failure (no chmod 0o600 on cleanup) - Green with the PR: OK (4 skipped) - 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).
zmasi commented 2026-11-29 01:19:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:19:29Z.


Independent verification on Windows 11 (10.0.26200, x64) of current head ff28c7104c merged onto origin/main (5825b02ff8, 0 merge conflicts), tested under both Python 3.12.10 and Python 3.14.5 to check the untested ff28c7104c revision noted in #7246246752 and the earlier Python 3.14 failure in #7135571146:

  • Red (origin/main + #899 tests/test_manifest_verifier.py):
    • python -I tests/test_manifest_verifier.py: Ran 77 tests, FAILED (failures=1, skipped=5) (test_save_cache_stage_cleanup_restores_write_mode_on_replace_failure: AssertionError: False is not true : []) on both Python 3.12.10 and Python 3.14.5.
  • Green (ff28c7104c merged onto origin/main):
    • python -I tests/test_manifest_verifier.py: Ran 80 tests, OK (skipped=5) on both Python 3.12.10 (7.25 s) and Python 3.14.5 (9.03 s).
    • Unmocked NTFS read-only destination check: creating cache.json, setting os.chmod(cache, 0o444), and calling manifest_verifier.save_cache(...) hits os.chmod(tmp, 0o444) followed by os.replace PermissionError ([WinError 5]), restores 0o600, and unlinks tmp cleanly (0 .verify-cache-* files left) on both Python 3.12.10 and Python 3.14.5.
  • Hygiene: git diff --check, python -I -m compileall -q, python -I scripts/check_no_game_data.py, python -I tests/test_ci_registration.py (18/18), and python -I tests/test_text_write_line_endings.py (3/3) all exited 0.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248707951 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/899#issuecomment-7248707951). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:19:29Z. --- Independent verification on Windows 11 (`10.0.26200`, x64) of current head `ff28c7104c` merged onto `origin/main` (`5825b02ff8`, `0` merge conflicts), tested under both `Python 3.12.10` and `Python 3.14.5` to check the untested `ff28c7104c` revision noted in `#7246246752` and the earlier `Python 3.14` failure in `#7135571146`: - **Red (`origin/main` + `#899` `tests/test_manifest_verifier.py`)**: - `python -I tests/test_manifest_verifier.py`: `Ran 77 tests`, `FAILED (failures=1, skipped=5)` (`test_save_cache_stage_cleanup_restores_write_mode_on_replace_failure`: `AssertionError: False is not true : []`) on both `Python 3.12.10` and `Python 3.14.5`. - **Green (`ff28c7104c` merged onto `origin/main`)**: - `python -I tests/test_manifest_verifier.py`: `Ran 80 tests`, `OK (skipped=5)` on both `Python 3.12.10` (`7.25 s`) and `Python 3.14.5` (`9.03 s`). - Unmocked NTFS read-only destination check: creating `cache.json`, setting `os.chmod(cache, 0o444)`, and calling `manifest_verifier.save_cache(...)` hits `os.chmod(tmp, 0o444)` followed by `os.replace` `PermissionError` (`[WinError 5]`), restores `0o600`, and unlinks `tmp` cleanly (`0` `.verify-cache-*` files left) on both `Python 3.12.10` and `Python 3.14.5`. - **Hygiene**: `git diff --check`, `python -I -m compileall -q`, `python -I scripts/check_no_game_data.py`, `python -I tests/test_ci_registration.py` (`18/18`), and `python -I tests/test_text_write_line_endings.py` (`3/3`) all exited `0`. AI-assisted.
MoonEyes commented 2026-11-29 18:26:56 +00:00 (Migrated from github.com)

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


Tested 3e0f3074c 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: python -I tests/test_manifest_verifier.py gives 80 OK (5 skipped).
  • Red with tools/manifest_verifier.py back to main: FAILED (failures=1, skipped=5).
  • Does not force a rebase of #2566 (merge-tree against 8db8335d2).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260490536 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/899#issuecomment-7260490536). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T18:26:56Z. --- Tested `3e0f3074c` 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: `python -I tests/test_manifest_verifier.py` gives 80 OK (5 skipped). - Red with `tools/manifest_verifier.py` back to `main`: `FAILED (failures=1, skipped=5)`. - Does not force a rebase of #2566 (merge-tree against `8db8335d2`). AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 18:36:52 +00:00 (Migrated from github.com)

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


Merging. Red/green verified on 3e0f3074c 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260621123 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/899#issuecomment-7260621123). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T18:36:52Z. --- Merging. Red/green verified on `3e0f3074c` 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 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!899
No description provided.