make_game: keep recovery copies until an install succeeds (RT-INSTALL-KEEP-RECOVERY) #2792

Merged
aznohonza merged 1 commit from upstream-pr/2792 into main 2026-11-30 23:08:04 +00:00
aznohonza commented 2026-11-30 21:24:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-11-30T21:24:51Z.


Claimed in the coordination issue as: RT-INSTALL-KEEP-RECOVERY

What and why

install_runtime() removed every .runtime-staging-* folder in the output folder before it started. A blocked rollback (IncompleteRollback) keeps its staging folder because it holds the only copies of the previous runtime files (<name>.old), so a retry that failed deleted those last copies before it had a chance to use them.

The cleanup now runs only after a successful publish. A failed retry leaves the recovery folder in place; the next install that completes removes it.

Tested

Red then green, CPU only, no game files or GPU:

  • Added test_failed_retry_keeps_the_previous_recovery_folder in tests/test_make_game_runtime_staging.py, which puts a gta6rt.exe.old in a stale staging folder and makes the next install fail while copying.
  • On main d8ca18240 the new case fails: the stale folder and its gta6rt.exe.old are already gone when the copy fails.
  • With the change, all 13 tests in python -I tests/test_make_game_runtime_staging.py pass.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5574036286 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2792). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-11-30T21:24:51Z. --- Claimed in the coordination issue as: [RT-INSTALL-KEEP-RECOVERY](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7292346799) ### What and why `install_runtime()` removed every `.runtime-staging-*` folder in the output folder before it started. A blocked rollback (`IncompleteRollback`) keeps its staging folder because it holds the only copies of the previous runtime files (`<name>.old`), so a retry that failed deleted those last copies before it had a chance to use them. The cleanup now runs only after a successful publish. A failed retry leaves the recovery folder in place; the next install that completes removes it. ### Tested Red then green, CPU only, no game files or GPU: - Added `test_failed_retry_keeps_the_previous_recovery_folder` in `tests/test_make_game_runtime_staging.py`, which puts a `gta6rt.exe.old` in a stale staging folder and makes the next install fail while copying. - On `main` `d8ca18240` the new case fails: the stale folder and its `gta6rt.exe.old` are already gone when the copy fails. - With the change, all 13 tests in `python -I tests/test_make_game_runtime_staging.py` pass. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule)
OreoFR commented 2026-11-30 21:30:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T21:30:35Z.


Verified by OreoFR on macOS 27.2.1, Apple M5, head 0fa9a51ab, main 0b6e0e3bc. CPU only, no game files.

MEASURED

  • Red (main + only this PR's tests/test_make_game_runtime_staging.py): 1 failed, 12 passed. The only failure is the new test_failed_retry_keeps_the_previous_recovery_folder.
  • Green (main + this PR, merged with merge-tree): 13 passed, 8 subtests passed.
  • Every tests/*make_game* file, main vs green: 530 → 531 passed, 5 skipped, and the same single failure on both sides (test_make_game_argparse.py::JobsHandlingTest::test_custom_jobs_forwarded_to_shaders). It also fails on main on this Mac, so this PR does not cause it.

READ IN CODE

  • The stale .runtime-staging-* sweep moved from before mkdtemp to after the successful publish and the removal of stage. Every failure path still re-raises before the sweep, so a failed retry keeps the recovery folder. The current stage is already gone when the sweep runs, so the glob only picks up older folders.

ASSUMED

  • Not run on Windows, where a file held open by a running game is the other source of leftover folders. The behavior there only changes in timing: the folder is swept after the next successful install instead of before it.

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7292507431 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2792#issuecomment-7292507431). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T21:30:35Z. --- Verified by OreoFR on macOS 27.2.1, Apple M5, head `0fa9a51ab`, main `0b6e0e3bc`. CPU only, no game files. **MEASURED** - Red (main + only this PR's `tests/test_make_game_runtime_staging.py`): 1 failed, 12 passed. The only failure is the new `test_failed_retry_keeps_the_previous_recovery_folder`. - Green (main + this PR, merged with merge-tree): 13 passed, 8 subtests passed. - Every `tests/*make_game*` file, main vs green: 530 → 531 passed, 5 skipped, and the same single failure on both sides (`test_make_game_argparse.py::JobsHandlingTest::test_custom_jobs_forwarded_to_shaders`). It also fails on main on this Mac, so this PR does not cause it. **READ IN CODE** - The stale `.runtime-staging-*` sweep moved from before `mkdtemp` to after the successful publish and the removal of `stage`. Every failure path still re-raises before the sweep, so a failed retry keeps the recovery folder. The current `stage` is already gone when the sweep runs, so the glob only picks up older folders. **ASSUMED** - Not run on Windows, where a file held open by a running game is the other source of leftover folders. The behavior there only changes in timing: the folder is swept after the next successful install instead of before it. AI-assisted: Claude Code
ecox982745 commented 2026-11-30 22:13:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T22:13:39Z.


Independent native Windows check with a real open handle. Tested 0fa9a51ab merged onto b1f91c2f9 (tree 920307e69), Windows 11 and Python 3.13. I used a temporary installation with two synthetic runtime artifacts and an older .old recovery copy. CreateFileW held the second destination with read sharing only while install_runtime() attempted to publish.

Both trees returned Windows error 32 and rolled back the first file. With main, the older recovery copy was already gone. With the patch, it survived with identical bytes. After I closed the handle, a fresh install on both trees published both artifacts and game_path.txt, removed staging directories, and preserved an unrelated settings file. All 13 stock runtime-staging tests passed on the patched tree. CPU and synthetic filesystem data only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7293548464 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2792#issuecomment-7293548464). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-30T22:13:39Z. --- Independent native Windows check with a real open handle. Tested `0fa9a51ab` merged onto `b1f91c2f9` (tree `920307e69`), Windows 11 and Python 3.13. I used a temporary installation with two synthetic runtime artifacts and an older `.old` recovery copy. `CreateFileW` held the second destination with read sharing only while `install_runtime()` attempted to publish. Both trees returned Windows error 32 and rolled back the first file. With `main`, the older recovery copy was already gone. With the patch, it survived with identical bytes. After I closed the handle, a fresh install on both trees published both artifacts and `game_path.txt`, removed staging directories, and preserved an unrelated settings file. All 13 stock runtime-staging tests passed on the patched tree. CPU and synthetic filesystem data only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
MoonEyes commented 2026-11-30 23:08:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T23:08:01Z.


Merging. Head 0fa9a51ab merges cleanly with main eec86d0fa and does not force a rebase of #2566. CI green on this head. Red/green by OreoFR (macOS) and a native Windows check with a real open handle by ecox982745, both on this head; I ran the make_game tests on main + PR (Windows, Python 3.14): the new test errors without the change and passes with it. The one other failure (test_make_game_argparse, 1 of 38) is the same on main. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7294749530 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2792#issuecomment-7294749530). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T23:08:01Z. --- Merging. Head `0fa9a51ab` merges cleanly with `main` `eec86d0fa` and does not force a rebase of #2566. CI green on this head. Red/green by OreoFR (macOS) and a native Windows check with a real open handle by ecox982745, both on this head; I ran the make_game tests on main + PR (Windows, Python 3.14): the new test errors without the change and passes with it. The one other failure (test_make_game_argparse, 1 of 38) is the same on main. 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!2792
No description provided.