Skip to content

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

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
aznohonza:fix/runtime-install-keep-recovery
Nov 30, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
aznohonza:fix/runtime-install-keep-recovery

Conversation

@aznohonza

Copy link
Copy Markdown
Contributor

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)

install_runtime() removed every .runtime-staging-* folder before it
started, including the folder an IncompleteRollback kept as the only
copies of the previous runtime. If the retry also failed, those copies
were already gone. Clean the stale folders only after a successful
publish, so a failed retry leaves the recovery folder in place.

RT-INSTALL-KEEP-RECOVERY.
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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

@MoonEyes
MoonEyes merged commit 9dffbe7 into ProjectLeonida:main Nov 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants