make_game: stage the runtime install and publish it all or none (RT-249) (OLD-9937) #1446
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1446"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by LouisRiverstone on 2026-11-25T00:24:14Z.
Claimed in the coordination issue as: OLD-9937 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148463379)
Replaces the carried-over draft #204. I'm the original author of old upstream PR 9937.
What and why
RT-249. The runtime stage of
make_game.pycopied the files into--outone by one. A failure partway through (disk full, an interrupt, or on Windows a destination file held open by an antivirus scan or another program) could leave a newgta6rt.exenext to an oldgta6rt_tls_host.dll.The stage now writes every file, including
game_path.txt,shader_path.txtandgta6rt.sh, to a staging folder inside--out, on the same filesystem. Only once everything is there doespublish()move the files into place, all or none: each old file is first moved aside, and any failure puts back the files already published. If the rollback itself is blocked,IncompleteRollbackkeeps the staging folder, which then holds the old copies as<name>.old, and the error says where they are. Onmainthe stage already refuses an--outwhere one of the runtime file names is a directory, and that check is kept; it runs before the build.tests/test_make_game_runtime_staging.py(new, 12 tests) covers a failed copy, a failedgame_path.txtwrite, a failed publish with and without an old copy, a blocked rollback, a missing output folder, a--runtime-buildthat is the output folder itself,shader_path.txtstaged with the rest, and a restore that fails for the file being published, stale staging folders removed by the next install, the BCPack history path, and a successful run that leaves no staging folder.The old branch's final diff, applied on current
mainas one commit. It applied cleanly.Tested
python -I tests/test_make_game_runtime_staging.py: 9 tests OK on Linux (Python 3.14.4) and on Windows 11 (Python 3.11).tests/test_make_game*.pyfiles pass on Linux. On Windows 11 with Python 3.11, seven of them fail, and they fail the same way onmain, so the cause is that environment and not this change.python -m compileall -q make_game.py tools tests: OK.GPUs tested: n/a
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator rule changes)On Windows a running
gta6rt.execan be renamed, so it does not block the install; its old copy may stay in a.runtime-staging-*folder, which the next install removes.Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T14:09:16Z.
Reviewed
354142d90, merged with main71a769d7d, on Windows 11 with Python 3.14. All 27tests/test_make_game_*.pyfiles pass, along withtest_dstorage_history.pyand the line-endings test. The three points below came from probes on synthetic folders (no game files), not from the test suite.1. Regression from the merge of main (
354142d90): the BCPack history profile moves.runtime()now asks forOn main this is
os.path.join(os.path.dirname(shader_dir), "bcpack", "history.bcph"), which resolves to<work>/shaders/bcpack/history.bcph. That is where the runtime reads it (runtime/shims/dstorage.cpp:474,shaders.parent_path() / "bcpack" / "history.bcph"), and also the path indocs/directstorage.md:180andtests/test_dstorage_history.py:100. I calledruntime()withttpf_mips.find_poolsandmake_game.py'spy()patched: main passes--out work/shaders/bcpack/history.bcph, this PR passes--out work/bcpack/history.bcph. The stage would then build the profile where nothing reads it. Fix:os.path.join(os.path.abspath(work), "shaders", "bcpack", "history.bcph"). A test that patchespyand checks that--outargument would stop it from moving again.2.
publish()loses the old file when its own restore fails. I patchedos.replaceso that moving the newgta6rt.exein fails and putting the old one back fails too. The innerexceptre-raises that error, and the outer handler only rolls back the names indone, so it raises a plainPermissionErrorrather thanIncompleteRollback.install_runtime()then removes the staging folder, which held the only copy, asgta6rt.exe.old.--outends up with nogta6rt.exeat all. The fix is to count a failed restore of the current name as a rollback failure, so that it raisesIncompleteRollbackand the stage is kept.3. A running
gta6rt.exedoes not block the install on Windows; it leaves a folder behind. Windows lets a running image be renamed. I ran a process from<out>\gta6rt.exe(a copy ofPING.EXE). On main,shutil.copy2over it fails with WinError 32. With this PR,publish()succeeds: the old image moves to<stage>\gta6rt.exe.oldand the new file takes its place. The finalshutil.rmtree(stage, ignore_errors=True)cannot remove the file that is still in use, so a.runtime-staging-*folder holding the old exe stays in--out. That happens once per install while the game runs, and nothing removes it later. This is still better than main. Two suggestions: remove stale.runtime-staging-*folders at the start ofinstall_runtime(), and change the description and theOSErrormessage, which name a running gta6rt.exe as a cause of a failed install.The rest read fine to me: the move order in
publish(), the--runtime-build==--outcase, and the bytes ofshader_path.txt, which are unchanged from main.Recommendation: fix 1 before merging (it is a one-line change); 2 and 3 are small.
AI-assisted review.
Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T20:12:25Z.
Re-checked
6a721500amerged with main9f9a7c5f3, on Windows 11 Pro (26300) with Python 3.14. All 25tests/test_make_game_*.pyfiles pass, along withtest_dstorage_history.py, the line-endings test,compileallandmake_game.py --help. I reran the probes from my review on synthetic folders:runtime()now passes--out <work>/shaders/bcpack/history.bcph, which is the path the runtime reads.gta6rt.exein and putting the old one back.install_runtime()raisesIncompleteRollbackand keeps the staging folder, with the old file asgta6rt.exe.old.gta6rt_tls_host.dllis untouched.ping.exeasgta6rt.exe. Two installs while it was running both succeeded and left one staging folder, and the first install after it exited removed that folder.All three points from my review are fixed.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T07:21:15Z.
Thanks for this! Staging the runtime install and publishing it all at once, with rollback, avoids a mixed old/new install.
During maintainer testing (local, 2026-11-28) (head
6a721500a, merged on mainb1619e0a3/6dfca6428, Windows 11, Python tests via pytest/unittest) we found:.oldrecovery copies left by a failed rollback, while the error tells the user to run the stage again, so a second failure loses the old files.To get this merged:
.oldcopies until a later install succeeds, or tell the user how to restore them.AI-assisted (Claude Code), posted for DadaCap (maintainer).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:41:34Z.
Red/green:
pytest tests/test_make_game_runtime_staging.pyfails on main (1 failed, 1 passed) and passes on head6a721500aemerged with main (12 passed, 6 subtests passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)