fix(dev): dev.py update backs up all a build writes, per folder, one update at a time (#1932's review) #1945

Open
GummiNaomi wants to merge 3 commits from GummiNaomi/Longshot:fix/dev-update-review into main
Member

Summary

A follow-up to #1932 (dev.py update), which was merged before BeanBot's review of it was answered. This fixes the
review's six blocking points; the command's options and the window are unchanged.

  1. What a backup keeps. It held only a few root files, so a launcher-built folder (the game and its libraries in
    bin/) or a half-done build could be left mixed after a rollback, with .longshot_installed.json describing the
    newer build. A backup now keeps everything nx2/make_game.py's finish can write, replace or remove (BUILT,
    BUILT_DIRS and the FFmpeg libraries, in the folder and in bin/: the game, the renderer and libraries,
    image.bin, .longshot_installed.json, the shader list, the texts, prompts and DLSS runtime, the settings files,
    the tool's marks), with a note of which of them were there (backup.json). Putting it back restores those and
    removes what wasn't there (files a build added, a finish's .new copies).
  2. Rollback took the newest backup of any folder. Backups are now kept per folder
    (update/backups/<name>-<hash of its path>/, the last three of each), and --rollback takes the named folder's
    newest and checks that folder's game.
  3. The running check compared argv[0], resolved against the updater's own folder, with the game folder. It now
    reads each longshot process's program path (/proc/<pid>/exe; Windows: QueryFullProcessImageNameW) and matches
    the folder and its bin/; a path it can't read still counts as running.
  4. Two updates at once could both pass the recovery and share the worktree and the pending record. An update or
    rollback now holds update/update.lock (common.Lock) from the recovery to its end; a second one stops at once and
    says so; a --check beside a running update lists and recovers nothing.
  5. Recovery after a stop trusted the updater's own exit, though on Linux its queue runner and builder can outlive
    it. A stopped update is now put back only once its build job (the queue's live update-... ticket) has ended too;
    until then the next command says the build is still running and how to cancel it.
  6. An older commit's build environment. A tree without this command was built with this checkout's
    build.environment() and tools.lock. A tree other than this checkout now gets its environment from its own devtools
    (build.environment and windows_prebuilt, run in a process of its own: tree_environment); a tree too old to have
    them is refused.

BeanBot's second review (of 06988e9b), fixed in a7b0311e and e4930e66:

  • Recovery waits for its own build and its own folder. The pending record names the update's child build (pid and
    start time, recorded before the child can write anything), its queue job and the queue folder it is in. Recovery puts
    the backup back only once all three are gone and the game in the backup's own folder is not running; until then it
    keeps the record and says why. A check of folder B no longer restores folder A while A's game runs.
  • Each fetch reads its own result: a private ref (--no-write-fetch-head), not the shared FETCH_HEAD that a
    concurrent check could rewrite between an update's fetch and its read.
  • Settings are written only with the update lock held; a check beside a running update is read only, and the temp
    file is per process.
  • Backups are published whole: made in a .partial- folder and renamed when complete, so a half-made one (a full
    disk, a stop) is never listed or chosen; ordered by their creation time.
  • #1932's backups and pending records are still read (game.txt): recovered after upgrading, and listed for
    --rollback of their folder.
  • A first FFmpeg library staged as av*/sw*.dll.new is removed by a restore.
  • Restores are staged and retried: each file is copied beside the live one and swapped in; a swap Windows refuses for
    a moment is tried again for up to 20 s; the folder's marks and installed-file note go back last, so a restore that
    still stops leaves them describing the build that is there; a failed removal or copy stops it with the error.
  • An explicit --rollback keeps longshot_options.ini and longshot_env.txt as they are now; a failed update's
    recovery still restores them.
  • The launcher-folder test uses the platform's renderer name (longshot_vk.so on Linux).
  • Scoped, in the docs: a backup does not cover the game files a first build unpacks (romfs/, .longshot_exefs/)
    or the caches (cache/); the next build or the game's first start makes those again.

Read first: scripts/devtools/update.py (tracked, back_up, put_back, _swap, running_in, exe_path, recover,
update_lock, tree_environment, cmd_update/update_locked).

Testing

Tested: Windows 11 Pro 26200, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D, Python 3.13.

  • tests/test_dev_update.py, 40 cases, all pass (the ten from the second review fail on 06988e9b, the held-file one on
    a7b0311e). New: a launcher-shaped folder (bin/ game and renderer, the
    installed-file note, texts) put back whole after a build that replaced some of it, added an FFmpeg library, prompts,
    image.bin and a .new copy, then failed; backups and --rollback per folder (another folder's game running stops
    its rollback); one update at a time (an update and a rollback stop while the lock is held, a check lists and leaves the
    stopped update's record, which the next command puts back); recovery waiting for a live update-... queue ticket and
    ignoring other jobs; the running check by program path (the folder, its bin/, another folder, an unreadable path);
    exe_path of this process; a tree's own environment (a stand-in devtools in another tree, a tree without devtools
    refused, this checkout's in process). Against main's update.py the nine new or changed cases fail; here all pass.

  • Checks: test_dev_update, test_doc_anchors, byte_compile_tracked pass.

  • A real update with these fixes: dev.py update --game <a folder built from main @ 87c0d7b4> --pick 1915 --with 1929
    (the folder's commit predates update.py, so the build took that tree's own environment: fix 6). #1915 was
    cherry-picked onto 87c0d7b4 and open #1929 merged on top; the backup kept 14 paths (the game, the renderer, the SDL
    libraries, image.bin, .longshot_installed.json, the shader list, the pipeline states, language.txt, the options,
    the mark, texts/, prompts/, ngx/), 1.6 GB, with its backup.json; the build (with DLSS, from the tree's own
    environment) and its shader step took 4.3 min; the folder records the pick and the open pull request. The game then
    ran 60 s with no window, with no CRASH or [error] line in its log.

  • The second review's fixes, for real (the same folder, main @ f1f2dc5b then 2b3de5b2):

    • an update: the full backup 1.62 GB in 1.6 s, the build 2.5 min;
    • a stop 12 s into a forced update (its whole process tree killed): the next command put the folder back byte for
      byte, no record left;
    • a --rollback right after an update first stopped on longshot.exe, which Windows held for a moment just after
      the build, after it had put back the folder's marks, so the folder said "old commit" while it held the new game.
      Fixed in e4930e66 (the retry, the marks last). Run again the same way: the update (0.8 min, nothing changed to
      compile), then the rollback at once: the game, the renderer and the mark exactly as before, no staged copy left;
      the longshot_env.txt edit made after the update kept.

Still to test:

  • Linux: an update, a rollback, and Stop in the window while a build runs, expecting the folder put back only after
    the builder ends (by hand: someone with Linux)

Measurements

Nothing to measure: a fix to a development tool, the game unchanged (a backup's size is in Tested and Risks).

Risks

Developers only: nothing reaches players. Backups take more room in the development folder's update/backups/ (1.6 GB
each here, three per folder). A folder backed up by #1932's version has no backup.json; its old backups are no
longer read (delete update/backups/'s older folders). A revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (run_all.py --changed, the checks that
    read the changed files: 5 pass, test_oot_state_tap skipped for want of gcc here.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary A follow-up to #1932 (`dev.py update`), which was merged before BeanBot's review of it was answered. This fixes the review's six blocking points; the command's options and the window are unchanged. 1. **What a backup keeps.** It held only a few root files, so a launcher-built folder (the game and its libraries in `bin/`) or a half-done build could be left mixed after a rollback, with `.longshot_installed.json` describing the newer build. A backup now keeps everything `nx2/make_game.py`'s finish can write, replace or remove (`BUILT`, `BUILT_DIRS` and the FFmpeg libraries, in the folder and in `bin/`: the game, the renderer and libraries, `image.bin`, `.longshot_installed.json`, the shader list, the texts, prompts and DLSS runtime, the settings files, the tool's marks), with a note of which of them were there (`backup.json`). Putting it back restores those and removes what wasn't there (files a build added, a finish's `.new` copies). 2. **Rollback took the newest backup of any folder.** Backups are now kept per folder (`update/backups/<name>-<hash of its path>/`, the last three of each), and `--rollback` takes the named folder's newest and checks that folder's game. 3. **The running check** compared `argv[0]`, resolved against the updater's own folder, with the game folder. It now reads each `longshot` process's program path (`/proc/<pid>/exe`; Windows: `QueryFullProcessImageNameW`) and matches the folder and its `bin/`; a path it can't read still counts as running. 4. **Two updates at once** could both pass the recovery and share the worktree and the pending record. An update or rollback now holds `update/update.lock` (`common.Lock`) from the recovery to its end; a second one stops at once and says so; a `--check` beside a running update lists and recovers nothing. 5. **Recovery after a stop** trusted the updater's own exit, though on Linux its queue runner and builder can outlive it. A stopped update is now put back only once its build job (the queue's live `update-...` ticket) has ended too; until then the next command says the build is still running and how to cancel it. 6. **An older commit's build environment.** A tree without this command was built with this checkout's `build.environment()` and `tools.lock`. A tree other than this checkout now gets its environment from its own devtools (`build.environment` and `windows_prebuilt`, run in a process of its own: `tree_environment`); a tree too old to have them is refused. **BeanBot's second review** (of 06988e9b), fixed in a7b0311e and e4930e66: - **Recovery waits for its own build and its own folder.** The pending record names the update's child build (pid and start time, recorded before the child can write anything), its queue job and the queue folder it is in. Recovery puts the backup back only once all three are gone and the game in the *backup's own* folder is not running; until then it keeps the record and says why. A check of folder B no longer restores folder A while A's game runs. - **Each fetch reads its own result:** a private ref (`--no-write-fetch-head`), not the shared FETCH_HEAD that a concurrent check could rewrite between an update's fetch and its read. - **Settings are written only with the update lock held;** a check beside a running update is read only, and the temp file is per process. - **Backups are published whole:** made in a `.partial-` folder and renamed when complete, so a half-made one (a full disk, a stop) is never listed or chosen; ordered by their creation time. - **#1932's backups and pending records are still read** (`game.txt`): recovered after upgrading, and listed for `--rollback` of their folder. - **A first FFmpeg library staged as `av*/sw*.dll.new`** is removed by a restore. - **Restores are staged and retried:** each file is copied beside the live one and swapped in; a swap Windows refuses for a moment is tried again for up to 20 s; the folder's marks and installed-file note go back last, so a restore that still stops leaves them describing the build that is there; a failed removal or copy stops it with the error. - **An explicit `--rollback` keeps `longshot_options.ini` and `longshot_env.txt`** as they are now; a failed update's recovery still restores them. - **The launcher-folder test** uses the platform's renderer name (`longshot_vk.so` on Linux). - **Scoped, in the docs:** a backup does not cover the game files a first build unpacks (`romfs/`, `.longshot_exefs/`) or the caches (`cache/`); the next build or the game's first start makes those again. Read first: `scripts/devtools/update.py` (`tracked`, `back_up`, `put_back`, `_swap`, `running_in`, `exe_path`, `recover`, `update_lock`, `tree_environment`, `cmd_update`/`update_locked`). ## Testing **Tested:** Windows 11 Pro 26200, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D, Python 3.13. - `tests/test_dev_update.py`, 40 cases, all pass (the ten from the second review fail on 06988e9b, the held-file one on a7b0311e). New: a launcher-shaped folder (`bin/` game and renderer, the installed-file note, texts) put back whole after a build that replaced some of it, added an FFmpeg library, prompts, `image.bin` and a `.new` copy, then failed; backups and `--rollback` per folder (another folder's game running stops its rollback); one update at a time (an update and a rollback stop while the lock is held, a check lists and leaves the stopped update's record, which the next command puts back); recovery waiting for a live `update-...` queue ticket and ignoring other jobs; the running check by program path (the folder, its `bin/`, another folder, an unreadable path); `exe_path` of this process; a tree's own environment (a stand-in devtools in another tree, a tree without devtools refused, this checkout's in process). Against `main`'s `update.py` the nine new or changed cases fail; here all pass. - Checks: `test_dev_update`, `test_doc_anchors`, `byte_compile_tracked` pass. - **A real update with these fixes:** `dev.py update --game <a folder built from main @ 87c0d7b4> --pick 1915 --with 1929` (the folder's commit predates `update.py`, so the build took that tree's own environment: fix 6). #1915 was cherry-picked onto 87c0d7b4 and open #1929 merged on top; the backup kept 14 paths (the game, the renderer, the SDL libraries, `image.bin`, `.longshot_installed.json`, the shader list, the pipeline states, `language.txt`, the options, the mark, `texts/`, `prompts/`, `ngx/`), 1.6 GB, with its `backup.json`; the build (with DLSS, from the tree's own environment) and its shader step took 4.3 min; the folder records the pick and the open pull request. The game then ran 60 s with no window, with no `CRASH` or `[error]` line in its log. - **The second review's fixes, for real** (the same folder, main @ f1f2dc5b then 2b3de5b2): - an update: the full backup 1.62 GB in 1.6 s, the build 2.5 min; - a stop 12 s into a forced update (its whole process tree killed): the next command put the folder back byte for byte, no record left; - a `--rollback` right after an update first **stopped on `longshot.exe`**, which Windows held for a moment just after the build, after it had put back the folder's marks, so the folder said "old commit" while it held the new game. Fixed in e4930e66 (the retry, the marks last). Run again the same way: the update (0.8 min, nothing changed to compile), then the rollback at once: the game, the renderer and the mark exactly as before, no staged copy left; the `longshot_env.txt` edit made after the update kept. **Still to test:** - Linux: an update, a rollback, and Stop in the window while a build runs, expecting the folder put back only after the builder ends (by hand: someone with Linux) ## Measurements Nothing to measure: a fix to a development tool, the game unchanged (a backup's size is in Tested and Risks). ## Risks Developers only: nothing reaches players. Backups take more room in the development folder's `update/backups/` (1.6 GB each here, three per folder). A folder backed up by #1932's version has no `backup.json`; its old backups are no longer read (delete `update/backups/`'s older folders). A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). (`run_all.py --changed`, the checks that read the changed files: 5 pass, `test_oot_state_tap` skipped for want of gcc here.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(dev): dev.py update backs up all a build writes, per folder, one update at a time (#1932's review)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
PR description / Description follows the template (pull_request_target) Successful in 13s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 17s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Third-party parts / As their notes say (pull_request) Successful in 18s
CI / Website build and checks (pull_request) Failing after 13s
06988e9b06
BeanBot's review of #1932 (merged before its points were fixed):
1. The backup now holds everything nx2/make_game.py's finish can write, replace or remove: the game and its libraries
   in the folder and in bin/ (a launcher-built folder), the FFmpeg libraries, image.bin, .longshot_installed.json, the
   shader list, the texts, prompts and DLSS runtime, the settings files and this tool's marks, with a note of what was
   there. Putting it back restores those and removes what a build added (a half-done finish's files and .new copies).
2. Backups are kept per folder (update/backups/<name>-<hash>/), and --rollback takes the named folder's newest and checks
   that folder's game.
3. The running check reads each longshot's program path (/proc/<pid>/exe; QueryFullProcessImageNameW) and matches the
   folder and its bin/, not argv[0] against the updater's directory.
4. update/update.lock is held from the recovery to the end of an update or rollback; a second one stops at once, and a
   --check beside it lists without recovering.
5. A stopped update is put back only once its build job (the queue's update-... ticket) has ended too.
6. A tree other than this checkout gets its build environment from its own devtools (build.environment and
   windows_prebuilt in a process of its own), so an older commit builds with its own tools.lock.
tests/test_dev_update.py: a launcher-shaped folder put back whole after a half-done build, backups and rollback per
folder, the lock, recovery waiting for the job, the running check by path, the tree's own environment (31 cases; the
new ones fail on main).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
BeanBot left a comment

Recommendation: Request changes. Per-folder backups and executable-path checks address real updater bugs. Recovery can still overwrite a live build, and a failed backup can hide the last usable rollback.

The updater keeps more of each installation, selects backups by game folder, and builds older commits with their own tools. This improves the developer workflow, but it adds substantial disk I/O and still leaves gaps in what a rollback restores.

Does it help: Yes for the reported Windows cases. The author reports nine new or changed cases failing with main's updater and 31 passing on the PR, plus one 4.3-minute real update and a 60-second headless smoke run. That run copied 14 paths totaling 1.6 GB, or about 4.8 GB at three backups of that size per folder. Linux cancellation and recovery remain unproven, and the added backup and restore time has no base comparison.
Other systems: The source change affects the developer CLI and its GUI subprocesses. The builder still runs shader preparation on the local GPU, and rollback can leave its cache outputs behind. Windows with NVIDIA has one reported smoke run. Linux, including Steam Deck and AMD configurations that use this workflow, lacks end-to-end evidence. Launcher-built folders and the installed-file note are covered by a mocked Windows failure case. No game runtime, renderer, save-format, audio, or input code changed.
Switches: No CLI options or production environment switches added, changed, or removed. The test sets the existing LONGSHOT_QUEUE_DIR to a temporary directory.

Reviewed: 06988e9b06 against 80bb1ccc18: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, docs/dev/standards.md, the commit and diff, both changed Python files, and the changed documentation sections. Traced the relevant builder, queue, lock, process enumeration, and launcher layout code. Read the testing summary and checklist. The rest of the builder and documentation was read selectively. No review-checklist file or sibling Tooling checkout was present. There were no comments, earlier reviews, or separate run logs.; nothing run (a code review).
Checked and fine:

  • The Conventional Commit title and diff stay on the updater follow-up. The commit records AI assistance.
  • The diff contains no game data, build output, generated files, third-party edits, or new dependency. Renderer ABI, shader generation, and menu checks are inapplicable.
  • The Windows image-path query uses the wide API, limited process-query rights, and closes the handle. The path comparison covers both the game root and bin.
  • The lock covers the ordinary update and explicit rollback paths. The mocked test also checks that a concurrent listing leaves the pending record in place.
  • The older-tree environment helper uses isolated Python, imports from the selected tree, and has a game-free test for both delegation and a missing devtools tree.

Blocking (to change before merge)

  1. scripts/devtools/update.py:425: Queue tickets do not establish that this particular build has stopped. If the updater dies after spawning a delegated --build-here and before that process writes its ticket, the next command can restore the folder and reuse the worktree while the old child is still starting. A build invoked inside an existing queue job can also run without an update ticket. Persist a per-invocation lifetime guard before the updater can be interrupted and keep it held until the build and its writers exit.
  2. scripts/devtools/update.py:440: Recovery checks every update-prefixed ticket in the current queue instead of identifying the pending build. An unrelated update using a different LONGSHOT_DEV_HOME can block recovery and be named as the job to cancel. Conversely, a build using LONGSHOT_QUEUE_DIR from dev_build.json's build environment can be invisible to recovery. Record the pending build's exact identity and coordination location, and identify that job in the diagnostic.
  3. scripts/devtools/update.py:447: Automatic recovery skips the running-game check and runs before an explicit rollback checks its target. Checking folder B can therefore restore folder A while A is being played after an interrupted update. Linux can end up with an old process reading newly replaced assets, and Windows can fail midway on a locked executable. Resolve and check the pending backup's own destination before changing it, and retain the pending record if that game is running.
  4. scripts/devtools/update.py:605: A check allowed past the lock still fetches into the same repository and reads FETCH_HEAD. A check of branch B between the updater's fetch and rev-parse can make an update requested for branch A build and record branch B. Give each fetch an independent result or coordinate the fetch and ref read separately from the long-running update lock.
  5. scripts/devtools/update.py:589: settings(a) writes dev_build.json before the lock. Two invocations changing --game can race on the shared dev_build.json.tmp, and even a rejected rollback can change the target remembered by the next command. Keep listing read-only when it bypasses the lock and serialize writes to remembered settings.
  6. scripts/devtools/update.py:371: An interrupted or disk-full backup leaves a directory that backups() treats as complete. The next rollback picks it and fails on missing backup.json even when a usable snapshot exists. Publish only completed snapshots, exclude staging directories from listing and pruning, and order completed backups correctly when multiple snapshots share a timestamp.
  7. scripts/devtools/update.py:394: A pending update written by #1932 points to a backup with game.txt. Upgrading the checkout after a stop makes every recovery attempt throw on missing backup.json. Existing completed backups also disappear from rollback. Support the legacy format for the correct folder, at least for pending recovery, and document how to recover old snapshots safely before recommending deletion.
  8. scripts/devtools/update.py:345: An FFmpeg DLL staged for the first time exists only as avcodec-61.dll.new. The scanner skips that name and the manifest never saw its base DLL, so rollback leaves the staged copy behind. Discover staged DLL names as well and add a case that stops before the first FFmpeg swap.
  9. scripts/devtools/update.py:75: The manifest misses builder writes beyond the listed binaries. For example, --romfs/--exefs can populate romfs and replace .longshot_exefs before compilation fails, and finish can move a loose pipeline list into cache and overwrite it. Restore the affected installation files or explicitly scope the guarantee and isolate writes outside it. Test a failed build from an unpacked dump as well as a finish failure.
  10. scripts/devtools/update.py:412: Restore copies directly into live files and ignores failed directory removals. A full drive can leave image.bin truncated during manual rollback, and a failed removal of a newly added prompts directory can still report success. Stage replacements before swapping them in, propagate removal errors, and keep a recovery record for interrupted manual rollbacks.
  11. scripts/devtools/update.py:412: Manual rollback restores the snapshot's options and environment unconditionally. A developer who changed a controller or graphics setting after a successful update loses that edit even if the build never touched the setting. The old manual rollback left those files alone. Preserve post-update user edits on explicit rollback and restore build-induced settings changes during failed-update recovery.
  12. tests/test_dev_update.py:433: The launcher fixture expects bin/longshot_vk.dll.new to disappear on Linux, where the manifest tracks longshot_vk.so. The assertion will fail on Linux. Use the platform's renderer filename and exercise FFmpeg DLL staging in a Windows-specific case.

Waiting on the author (a run, a measurement or a decision; no edit does it)

  • The reported 1.6 GB snapshot establishes the copy size, but the new full snapshot adds disk I/O on every update and rollback. Measure backup and restore time against the base on the same installation and report the peak and retained disk use, including a representative slower drive.
  • Record the promised Linux update, rollback, and GUI Stop results, including a stop during a real build and confirmation that recovery waits for its writers. The reported changed-only checks include a skip. The checklist requires the full suite result or named base failures, plus CI on the reviewed head before merge.

Suggestions (the author may take or leave)

  • Put the reported base-failing and head-passing test counts in Measurements, with the revisions used, alongside the backup cost.

Testing: Static review only. The author reports 31 passing Windows unit cases, five passing changed-file checks with one GCC-dependent skip, and one Windows update and smoke run. Linux end-to-end results, a full suite result, and head CI were absent from the supplied evidence.
Overlaps and merge order: This follows merged #1932. The author used #1915 and #1929 as update inputs. No merge dependency is apparent in the supplied material.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Per-folder backups and executable-path checks address real updater bugs. Recovery can still overwrite a live build, and a failed backup can hide the last usable rollback. The updater keeps more of each installation, selects backups by game folder, and builds older commits with their own tools. This improves the developer workflow, but it adds substantial disk I/O and still leaves gaps in what a rollback restores. **Does it help:** Yes for the reported Windows cases. The author reports nine new or changed cases failing with main's updater and 31 passing on the PR, plus one 4.3-minute real update and a 60-second headless smoke run. That run copied 14 paths totaling 1.6 GB, or about 4.8 GB at three backups of that size per folder. Linux cancellation and recovery remain unproven, and the added backup and restore time has no base comparison. **Other systems:** The source change affects the developer CLI and its GUI subprocesses. The builder still runs shader preparation on the local GPU, and rollback can leave its cache outputs behind. Windows with NVIDIA has one reported smoke run. Linux, including Steam Deck and AMD configurations that use this workflow, lacks end-to-end evidence. Launcher-built folders and the installed-file note are covered by a mocked Windows failure case. No game runtime, renderer, save-format, audio, or input code changed. **Switches:** No CLI options or production environment switches added, changed, or removed. The test sets the existing LONGSHOT_QUEUE_DIR to a temporary directory. **Reviewed:** 06988e9b061f against 80bb1ccc182d: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, docs/dev/standards.md, the commit and diff, both changed Python files, and the changed documentation sections. Traced the relevant builder, queue, lock, process enumeration, and launcher layout code. Read the testing summary and checklist. The rest of the builder and documentation was read selectively. No review-checklist file or sibling Tooling checkout was present. There were no comments, earlier reviews, or separate run logs.; nothing run (a code review). **Checked and fine:** - The Conventional Commit title and diff stay on the updater follow-up. The commit records AI assistance. - The diff contains no game data, build output, generated files, third-party edits, or new dependency. Renderer ABI, shader generation, and menu checks are inapplicable. - The Windows image-path query uses the wide API, limited process-query rights, and closes the handle. The path comparison covers both the game root and bin. - The lock covers the ordinary update and explicit rollback paths. The mocked test also checks that a concurrent listing leaves the pending record in place. - The older-tree environment helper uses isolated Python, imports from the selected tree, and has a game-free test for both delegation and a missing devtools tree. **Blocking** (to change before merge) 1. scripts/devtools/update.py:425: Queue tickets do not establish that this particular build has stopped. If the updater dies after spawning a delegated --build-here and before that process writes its ticket, the next command can restore the folder and reuse the worktree while the old child is still starting. A build invoked inside an existing queue job can also run without an update ticket. Persist a per-invocation lifetime guard before the updater can be interrupted and keep it held until the build and its writers exit. 2. scripts/devtools/update.py:440: Recovery checks every update-prefixed ticket in the current queue instead of identifying the pending build. An unrelated update using a different LONGSHOT_DEV_HOME can block recovery and be named as the job to cancel. Conversely, a build using LONGSHOT_QUEUE_DIR from dev_build.json's build environment can be invisible to recovery. Record the pending build's exact identity and coordination location, and identify that job in the diagnostic. 3. scripts/devtools/update.py:447: Automatic recovery skips the running-game check and runs before an explicit rollback checks its target. Checking folder B can therefore restore folder A while A is being played after an interrupted update. Linux can end up with an old process reading newly replaced assets, and Windows can fail midway on a locked executable. Resolve and check the pending backup's own destination before changing it, and retain the pending record if that game is running. 4. scripts/devtools/update.py:605: A check allowed past the lock still fetches into the same repository and reads FETCH_HEAD. A check of branch B between the updater's fetch and rev-parse can make an update requested for branch A build and record branch B. Give each fetch an independent result or coordinate the fetch and ref read separately from the long-running update lock. 5. scripts/devtools/update.py:589: settings(a) writes dev_build.json before the lock. Two invocations changing --game can race on the shared dev_build.json.tmp, and even a rejected rollback can change the target remembered by the next command. Keep listing read-only when it bypasses the lock and serialize writes to remembered settings. 6. scripts/devtools/update.py:371: An interrupted or disk-full backup leaves a directory that backups() treats as complete. The next rollback picks it and fails on missing backup.json even when a usable snapshot exists. Publish only completed snapshots, exclude staging directories from listing and pruning, and order completed backups correctly when multiple snapshots share a timestamp. 7. scripts/devtools/update.py:394: A pending update written by #1932 points to a backup with game.txt. Upgrading the checkout after a stop makes every recovery attempt throw on missing backup.json. Existing completed backups also disappear from rollback. Support the legacy format for the correct folder, at least for pending recovery, and document how to recover old snapshots safely before recommending deletion. 8. scripts/devtools/update.py:345: An FFmpeg DLL staged for the first time exists only as avcodec-61.dll.new. The scanner skips that name and the manifest never saw its base DLL, so rollback leaves the staged copy behind. Discover staged DLL names as well and add a case that stops before the first FFmpeg swap. 9. scripts/devtools/update.py:75: The manifest misses builder writes beyond the listed binaries. For example, --romfs/--exefs can populate romfs and replace .longshot_exefs before compilation fails, and finish can move a loose pipeline list into cache and overwrite it. Restore the affected installation files or explicitly scope the guarantee and isolate writes outside it. Test a failed build from an unpacked dump as well as a finish failure. 10. scripts/devtools/update.py:412: Restore copies directly into live files and ignores failed directory removals. A full drive can leave image.bin truncated during manual rollback, and a failed removal of a newly added prompts directory can still report success. Stage replacements before swapping them in, propagate removal errors, and keep a recovery record for interrupted manual rollbacks. 11. scripts/devtools/update.py:412: Manual rollback restores the snapshot's options and environment unconditionally. A developer who changed a controller or graphics setting after a successful update loses that edit even if the build never touched the setting. The old manual rollback left those files alone. Preserve post-update user edits on explicit rollback and restore build-induced settings changes during failed-update recovery. 12. tests/test_dev_update.py:433: The launcher fixture expects bin/longshot_vk.dll.new to disappear on Linux, where the manifest tracks longshot_vk.so. The assertion will fail on Linux. Use the platform's renderer filename and exercise FFmpeg DLL staging in a Windows-specific case. **Waiting on the author** (a run, a measurement or a decision; no edit does it) - The reported 1.6 GB snapshot establishes the copy size, but the new full snapshot adds disk I/O on every update and rollback. Measure backup and restore time against the base on the same installation and report the peak and retained disk use, including a representative slower drive. - Record the promised Linux update, rollback, and GUI Stop results, including a stop during a real build and confirmation that recovery waits for its writers. The reported changed-only checks include a skip. The checklist requires the full suite result or named base failures, plus CI on the reviewed head before merge. **Suggestions** (the author may take or leave) - Put the reported base-failing and head-passing test counts in Measurements, with the revisions used, alongside the backup cost. **Testing:** Static review only. The author reports 31 passing Windows unit cases, five passing changed-file checks with one GCC-dependent skip, and one Windows update and smoke run. Linux end-to-end results, a full suite result, and head CI were absent from the supplied evidence. **Overlaps and merge order:** This follows merged #1932. The author used #1915 and #1929 as update inputs. No merge dependency is apparent in the supplied material. --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -68,0 +72,4 @@
_BESIDE = ("longshot", "longshot_vk.so", "libSDL2-2.0.so.0", "renhdrum.so") if not common.WINDOWS else \
("longshot.exe", "longshot_vk.dll", "SDL2.dll", "SDL3.dll", "renhdrum.dll")
BUILT = _BESIDE + tuple(os.path.join("bin", n) for n in _BESIDE) + (
"image.bin", ".longshot_installed.json", "exefs_patches.txt", "longshot_shaders.bin",
Member

The builder also writes romfs and .longshot_exefs in unpacked-input mode and can move or replace pipeline caches. Cover those writes or isolate them and narrow the documented guarantee.

The builder also writes romfs and .longshot_exefs in unpacked-input mode and can move or replace pipeline caches. Cover those writes or isolate them and narrow the documented guarantee.
@ -309,3 +369,3 @@
n += 1
d = os.path.join(part("backups"), "%s-%s-%d" % (stamp, tag, n))
d = os.path.join(root, "%s-%s-%d" % (stamp, tag, n))
os.makedirs(d)
Member

A failed snapshot is visible to rollback before backup.json exists. Publish completed snapshots atomically and prune only completed snapshots.

A failed snapshot is visible to rollback before backup.json exists. Publish completed snapshots atomically and prune only completed snapshots.
@ -331,1 +409,4 @@
shutil.copytree(src, dst, symlinks=True)
else:
os.makedirs(os.path.dirname(dst), exist_ok=True)
shutil.copy2(src, dst)
Member

A full disk can truncate the live image during restore, and ignored removal errors can leave new files behind. Stage replacements and keep failed restores recoverable.

A full disk can truncate the live image during restore, and ignored removal errors can leave new files behind. Stage replacements and keep failed restores recoverable.
Member

Explicit rollback reverts options and environment edits made since the update. Preserve those user edits even when failed-update recovery needs to restore settings.

Explicit rollback reverts options and environment edits made since the update. Preserve those user edits even when failed-update recovery needs to restore settings.
@ -301,0 +342,4 @@
names = os.listdir(os.path.join(game, d) if d else game)
except OSError:
continue
found += [os.path.join(d, n) if d else n for n in sorted(names) if n.startswith(("av", "sw")) and n.endswith(".dll")]
Member

A first-time avcodec-61.dll.new has no base DLL for tracked() to discover. Include staged FFmpeg names and test a stop before the swap.

A first-time avcodec-61.dll.new has no base DLL for tracked() to discover. Include staged FFmpeg names and test a stop before the swap.
@ -355,3 +444,4 @@
jobs[0].get("name")))
if os.path.isdir(p.get("backup", "")):
say("the update to %s did not finish: the game folder is put back as it was" % p.get("commit", "?")[:8])
put_back(p["backup"])
Member

Checking folder B can restore folder A while A is running. Check the backup's own destination before any restore.

Checking folder B can restore folder A while A is running. Check the backup's own destination before any restore.
@ -331,0 +391,4 @@
"""The folder as the backup found it: what it had copied back, what it didn't have removed (a build's new files, a
half-done finish's too). Returns the folder"""
with open(os.path.join(d, "backup.json"), encoding="utf-8") as f:
b = json.load(f)
Member

Pending records from #1932 still reference game.txt backups. Handle that format so an interrupted update can recover after upgrading the checkout.

Pending records from #1932 still reference game.txt backups. Handle that format so an interrupted update can recover after upgrading the checkout.
@ -345,0 +422,4 @@
def build_jobs():
"""The job queue's live update builds (names update-...): a build an updater left running when it was killed"""
s = jobqueue.settings()
return [t for t in jobqueue.read_tickets(jobqueue.queue_dir(s), clean=False)
Member

A delegated child can still be starting before it publishes a ticket, and nested queue builds may never publish one. Track the build lifetime from handoff through the last writer.

A delegated child can still be starting before it publishes a ticket, and nested queue builds may never publish one. Track the build lifetime from handoff through the last writer.
@ -352,12 +437,24 @@ def recover():
start = procs.proc_start(p.get("pid", 0))
if start is not None and start == p.get("start"):
die("an update is running (process %s): wait for it, or stop it first" % p.get("pid"))
jobs = build_jobs()
Member

A global update-* match can block on an unrelated folder or miss a build that uses another queue directory. Save and check the pending build's exact identity.

A global update-* match can block on an unrelated folder or miss a build that uses another queue directory. Save and check the pending build's exact identity.
@ -469,4 +587,3 @@
if a.build_here: # (run_build's step, in the tree being built)
return build_here(ROOT, os.path.abspath(a.game), a.commit)
recover()
s = settings(a)
Member

settings(a) writes the remembered destination and shared temp file before the lock. Serialize those writes and keep lock-bypassing checks read-only.

settings(a) writes the remembered destination and shared temp file before the lock. Serialize those writes and keep lock-bypassing checks read-only.
@ -482,0 +602,4 @@
except BlockingIOError:
if not (a.check or a.list_json):
die("another dev.py update is running on this PC: wait for it, or stop it first")
lock = None # (a check while an update runs: it lists, and leaves the recovery to the update)
Member

This concurrent check still overwrites the shared FETCH_HEAD. Isolate each fetch result so an update cannot pick up the check's branch.

This concurrent check still overwrites the shared FETCH_HEAD. Isolate each fetch result so an update cannot pick up the check's branch.
@ -405,0 +430,4 @@
self.assertEqual(self.read("bin/longshot_vk.dll"), "old renderer")
self.assertEqual(self.read(".longshot_installed.json"), "old note")
self.assertEqual(self.read("texts/en.txt"), "old text")
for gone in ("bin/avcodec-61.dll", "prompts", "image.bin", "bin/longshot_vk.dll.new", update.MARK):
Member

Linux tracks longshot_vk.so, so this staged DLL assertion fails there. Use the platform renderer name and cover DLL staging in a Windows-specific case.

Linux tracks longshot_vk.so, so this staged DLL assertion fails there. Use the platform renderer name and cover DLL staging in a Windows-specific case.
GummiNaomi force-pushed fix/dev-update-review from 06988e9b06
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
PR description / Description follows the template (pull_request_target) Successful in 13s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 17s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Third-party parts / As their notes say (pull_request) Successful in 18s
CI / Website build and checks (pull_request) Failing after 13s
to e4930e6683
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
Third-party parts / As their notes say (pull_request) Successful in 21s
PR description / Description follows the template (pull_request_target) Successful in 11s
CI / Website build and checks (pull_request) Failing after 1m16s
2026-11-21 05:52:20 +00:00
Compare
Author
Member

Thanks for the second review (of 06988e9b). Each blocking point, at e4930e66 (rebased onto main @ 2b3de5b2):

  1. The build's lifetime: the delegated --build-here child is started with Popen and its pid and start time go into the pending record before it can write anything; recovery waits for it as well as for the updater. A build run inside an existing queue job runs in the updater or that child, so the two pid checks cover it.
  2. The pending build's identity: the record now names its job (update-<commit>) and the queue folder it was queued in; recovery checks only that ticket, in that folder.
  3. The running game: recovery resolves the backup's own folder and checks its game; while it runs, the record is kept and the command says so. An explicit rollback checks its own target as before.
  4. FETCH_HEAD: each fetch writes a private ref (--no-write-fetch-head, +refs/heads/<branch>:refs/dev-update/fetch-<pid>-<ns>), reads it and deletes it. A test interleaves another branch's fetch between the two and reads the right commit (it fails on 06988e9b).
  5. Remembered settings: settings() is read only; remember() runs only with the update lock held, through a per-process temp file. A check beside a running update writes nothing.
  6. Half-made backups: made in .partial-… and renamed when complete; backups() lists only folders with backup.json and orders them by their creation time; the next backup removes stale partials.
  7. #1932's format: pending records and backups with game.txt are still put back (for their own folder) and listed for --rollback.
  8. A first FFmpeg DLL staged as .dll.new: tracked, so a restore removes it (in the launcher-folder test).
  9. Writes beyond the build's outputs: scoped rather than covered: the docs and the module notes now say a backup does not cover romfs/, .longshot_exefs/ or cache/, which the next build or the game's first start makes again.
  10. Restores into live files: every file is copied beside the live one and swapped in (directories renamed away, then removed); removal and copy errors stop the restore with the error. One more found in a real run: a rollback right after an update stopped on longshot.exe, which Windows held for a moment, after it had already put back the folder's marks. Each swap now retries for up to 20 s, the marks and the installed-file note go back last, and a restore that still stops says which file held it (a recovery keeps its record; a rollback can be run again). Re-run the same way on this PC, it completes.
  11. Settings on rollback: an explicit --rollback leaves longshot_options.ini and longshot_env.txt as they are now; a failed update's recovery still restores them.
  12. The Linux assertion: the test uses the platform's renderer name.

Waiting on the author:

  • Backup and restore cost: the full backup was 1.62 GB in 1.6 s on this PC's C: drive (its type not checked; a slower drive isn't measured here). Retained: three backups a folder, ~1.6 GB each.
  • Linux: still to test, by hand by someone with Linux, as listed.
  • Tests: 40 cases in test_dev_update.py; run_all.py --changed: 5 pass, test_oot_state_tap skipped for want of gcc here.
Thanks for the second review (of 06988e9b). Each blocking point, at e4930e66 (rebased onto main @ 2b3de5b2): 1. **The build's lifetime:** the delegated `--build-here` child is started with Popen and its pid and start time go into the pending record before it can write anything; recovery waits for it as well as for the updater. A build run inside an existing queue job runs in the updater or that child, so the two pid checks cover it. 2. **The pending build's identity:** the record now names its job (`update-<commit>`) and the queue folder it was queued in; recovery checks only that ticket, in that folder. 3. **The running game:** recovery resolves the backup's own folder and checks *its* game; while it runs, the record is kept and the command says so. An explicit rollback checks its own target as before. 4. **FETCH_HEAD:** each fetch writes a private ref (`--no-write-fetch-head`, `+refs/heads/<branch>:refs/dev-update/fetch-<pid>-<ns>`), reads it and deletes it. A test interleaves another branch's fetch between the two and reads the right commit (it fails on 06988e9b). 5. **Remembered settings:** `settings()` is read only; `remember()` runs only with the update lock held, through a per-process temp file. A check beside a running update writes nothing. 6. **Half-made backups:** made in `.partial-…` and renamed when complete; `backups()` lists only folders with `backup.json` and orders them by their creation time; the next backup removes stale partials. 7. **#1932's format:** pending records and backups with `game.txt` are still put back (for their own folder) and listed for `--rollback`. 8. **A first FFmpeg DLL staged as `.dll.new`:** tracked, so a restore removes it (in the launcher-folder test). 9. **Writes beyond the build's outputs:** scoped rather than covered: the docs and the module notes now say a backup does not cover `romfs/`, `.longshot_exefs/` or `cache/`, which the next build or the game's first start makes again. 10. **Restores into live files:** every file is copied beside the live one and swapped in (directories renamed away, then removed); removal and copy errors stop the restore with the error. One more found in a real run: a rollback right after an update stopped on `longshot.exe`, which Windows held for a moment, *after* it had already put back the folder's marks. Each swap now retries for up to 20 s, the marks and the installed-file note go back last, and a restore that still stops says which file held it (a recovery keeps its record; a rollback can be run again). Re-run the same way on this PC, it completes. 11. **Settings on rollback:** an explicit `--rollback` leaves `longshot_options.ini` and `longshot_env.txt` as they are now; a failed update's recovery still restores them. 12. **The Linux assertion:** the test uses the platform's renderer name. Waiting on the author: - **Backup and restore cost:** the full backup was 1.62 GB in 1.6 s on this PC's C: drive (its type not checked; a slower drive isn't measured here). Retained: three backups a folder, ~1.6 GB each. - **Linux:** still to test, by hand by someone with Linux, as listed. - **Tests:** 40 cases in `test_dev_update.py`; `run_all.py --changed`: 5 pass, `test_oot_state_tap` skipped for want of gcc here.
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
Third-party parts / As their notes say (pull_request) Successful in 21s
PR description / Description follows the template (pull_request_target) Successful in 11s
CI / Website build and checks (pull_request) Failing after 1m16s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/dev-update-review:GummiNaomi-fix/dev-update-review'
git switch 'GummiNaomi-fix/dev-update-review'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1945
No description provided.