Recover interrupted offline save updates before readback #2003

Closed
lgr123 wants to merge 1 commit from upstream-pr/2003 into main
lgr123 commented 2026-11-25 17:55:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lgr123 on 2026-11-25T17:55:54Z.


Claimed as RT-GAMESAVE-INTERRUPTED-UPDATE-RECOVERY.

A native synthetic checkpoint had two blobs at generation 1. I ended the save process after the first successful file replacement in public main. A new process reopened it via the save API and returned inventory at generation 2 with player state at generation 1. The uninterrupted control returned 2/2. The earlier rollback for an error returned by the current process remains covered.

Stage new bytes and undo data before touching live files. A same-volume journal records which operations need rollback. If an update is interrupted, restore the complete previous generation before the normal read, enumeration, quota, or next write proceeds. A completed commit retains its new generation. Recovery can be interrupted and retried. It keeps the existing container and blob paths, display metadata, and legacy backup files.

This addresses process interruption in one runtime on the same volume. It does not establish power-loss durability or synchronize multiple runtime processes and an external importer.

Reviewer check

Build the Windows xgameruntime_gamesave_test target and run it with no arguments. The test spawns synthetic child processes and uses disposable save folders. No game files or existing saves are needed.

Tested

  • Native Windows x64, MSVC, public main b9320a1 plus this patch. 156 of 156 checks passed. Coverage includes seven interruption points, interruption during rollback, first-save cleanup, blocked recovery, metadata and quota, legacy backups, and synchronous and asynchronous reads.
  • Compiled the production shim separately with test failure hooks disabled.
  • Source-only check and git diff --check passed. A local merge-tree check with #1952 found no conflict.

GPUs tested: n/a.

AI-assisted: yes.

Checklist

  • Based on public main.
  • One topic.
  • No game data, keys or protection workarounds.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496429854 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2003). Originally posted by [lgr123](https://github.com/lgr123) on 2026-11-25T17:55:54Z. --- Claimed as [RT-GAMESAVE-INTERRUPTED-UPDATE-RECOVERY](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7169739872). A native synthetic checkpoint had two blobs at generation 1. I ended the save process after the first successful file replacement in public main. A new process reopened it via the save API and returned inventory at generation **2** with player state at generation **1**. The uninterrupted control returned **2/2**. The earlier rollback for an error returned by the current process remains covered. Stage new bytes and undo data before touching live files. A same-volume journal records which operations need rollback. If an update is interrupted, restore the complete previous generation before the normal read, enumeration, quota, or next write proceeds. A completed commit retains its new generation. Recovery can be interrupted and retried. It keeps the existing container and blob paths, display metadata, and legacy backup files. This addresses process interruption in one runtime on the same volume. It does not establish power-loss durability or synchronize multiple runtime processes and an external importer. ### Reviewer check Build the Windows `xgameruntime_gamesave_test` target and run it with no arguments. The test spawns synthetic child processes and uses disposable save folders. No game files or existing saves are needed. ### Tested - Native Windows x64, MSVC, public main `b9320a1` plus this patch. **156 of 156 checks passed**. Coverage includes seven interruption points, interruption during rollback, first-save cleanup, blocked recovery, metadata and quota, legacy backups, and synchronous and asynchronous reads. - Compiled the production shim separately with test failure hooks disabled. - Source-only check and `git diff --check` passed. A local merge-tree check with #1952 found no conflict. GPUs tested: n/a. AI-assisted: yes. ### Checklist - [x] Based on public main. - [x] One topic. - [x] No game data, keys or protection workarounds.
kawaii-shakal commented 2026-11-26 13:04:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-26T13:04:15Z.

Review: APPROVED


Reviewed by Claude Code (AI-assisted) on my behalf. I read the commit and recovery paths step by step and found no
hole for a process kill. Approving.

  • Undo works from the journal alone: a write is applied when its w<i> file has been consumed, a delete when its
    b<i> exists. A restore goes through restore and keeps b<i>, so recovery can itself be interrupted and rerun.
  • The update commits when active is renamed to retired. A crash after that leaves nothing to undo. A crash after
    every op but before the retire is rolled back as a whole, and the title never saw S_OK for it, so that is correct.
  • The test kills a child process at each of the seven checkpoints, which is the right way to test this.

Non-blocking, possibly for a follow-up:

  1. Power loss: the staged blobs and prepare are never flushed (FlushFileBuffers) before the publishing rename.
    NTFS journals the rename but not the file data, so after a power cut a published blob can come back zero-filled.
    The header says power loss is out of scope; flushing the staged files and the manifest before the rename would
    close it for little cost.
  2. delete_container is still a plain remove_all, so a kill in the middle leaves a container with only some of its
    blobs. Renaming the container folder to a hidden name first, then removing it, makes the delete all-or-nothing as
    well.
  3. The branch is 417 commits behind main. It merges cleanly, but CI ran on the old base.

Not built or run here: the shim and its test are Windows-only, so this review is from reading the code.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6074605316 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2003#pullrequestreview-6074605316). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-26T13:04:15Z. **Review:** APPROVED --- Reviewed by Claude Code (AI-assisted) on my behalf. I read the commit and recovery paths step by step and found no hole for a process kill. Approving. - Undo works from the journal alone: a write is applied when its `w<i>` file has been consumed, a delete when its `b<i>` exists. A restore goes through `restore` and keeps `b<i>`, so recovery can itself be interrupted and rerun. - The update commits when `active` is renamed to `retired`. A crash after that leaves nothing to undo. A crash after every op but before the retire is rolled back as a whole, and the title never saw S_OK for it, so that is correct. - The test kills a child process at each of the seven checkpoints, which is the right way to test this. Non-blocking, possibly for a follow-up: 1. Power loss: the staged blobs and `prepare` are never flushed (`FlushFileBuffers`) before the publishing rename. NTFS journals the rename but not the file data, so after a power cut a published blob can come back zero-filled. The header says power loss is out of scope; flushing the staged files and the manifest before the rename would close it for little cost. 2. `delete_container` is still a plain `remove_all`, so a kill in the middle leaves a container with only some of its blobs. Renaming the container folder to a hidden name first, then removing it, makes the delete all-or-nothing as well. 3. The branch is 417 commits behind main. It merges cleanly, but CI ran on the old base. Not built or run here: the shim and its test are Windows-only, so this review is from reading the code. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-11-28 02:53:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:53:37Z.


Hi @lgr123, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/shims/xgameruntime_gamesave.cpp, runtime/test/xgameruntime_gamesave_test.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232661059 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2003#issuecomment-7232661059). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:53:37Z. --- Hi @lgr123, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/shims/xgameruntime_gamesave.cpp`, `runtime/test/xgameruntime_gamesave_test.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
OreoFR commented 2026-11-30 13:40:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:39Z.


Carried as #2740 because of the conflict with main after #2566; @lgr123, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7280193446 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2003#issuecomment-7280193446). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:40:39Z. --- Carried as #2740 because of the conflict with main after #2566; @lgr123, if you come back, say so and the carry is dropped.
aslan2142 commented 2026-12-01 17:24:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:24:40Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319254802 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2003#issuecomment-7319254802). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:24:40Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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!2003
No description provided.