save: keep the last complete version when a newer one is missing blobs (D3D12-SAVE-FALLBACK-MISSING-BLOB) #3082

Closed
lgtlgt0015-code wants to merge 1 commit from upstream-pr/3082 into main
lgtlgt0015-code commented 2026-12-02 10:26:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lgtlgt0015-code on 2026-12-02T10:26:21Z.


Claimed in the coordination issue as: D3D12-SAVE-FALLBACK-MISSING-BLOB

What and why

A readable manifest can name a missing blob or a directory. The current loader promotes that version and removes older candidates. Verify each manifest-listed blob is a file before selecting or pruning versions; keep unexpected metadata I/O errors visible.

Tested

an_unreadable_newer_version_does_not_cost_the_save adds missing-blob and directory-blob fixtures and checks the older save is still available and subsequent saves can commit.

Windows, Rust 1.98.1. The targeted case fails with the original behavior and passes with the fix. The regression cases ran together in a local verification checkout based on 80910637.

GPUs tested: n/a. The regression uses synthetic inputs and needs no game files or GPU.

AI-assisted: yes. GPT-6 (Codex) for implementation and testing, GPT-6.2 Sol for independent read-only diff review.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption. scripts/check_no_game_data.py passed on all changed files.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5604545912 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3082). Originally posted by [lgtlgt0015-code](https://github.com/lgtlgt0015-code) on 2026-12-02T10:26:21Z. --- Claimed in the coordination issue as: [D3D12-SAVE-FALLBACK-MISSING-BLOB](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7341891593) ### What and why A readable manifest can name a missing blob or a directory. The current loader promotes that version and removes older candidates. Verify each manifest-listed blob is a file before selecting or pruning versions; keep unexpected metadata I/O errors visible. ### Tested `an_unreadable_newer_version_does_not_cost_the_save` adds missing-blob and directory-blob fixtures and checks the older save is still available and subsequent saves can commit. Windows, Rust 1.98.1. The targeted case fails with the original behavior and passes with the fix. The regression cases ran together in a local verification checkout based on `80910637`. GPUs tested: n/a. The regression uses synthetic inputs and needs no game files or GPU. AI-assisted: yes. GPT-6 (Codex) for implementation and testing, GPT-6.2 Sol for independent read-only diff review. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. `scripts/check_no_game_data.py` passed on all changed files.
Kal0s-design commented 2026-12-02 10:30:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T10:30:22Z.


Windows 11, MSVC toolchain 1.98.1. Head 37d55d7e2 merged into current main 80910637f: the merge is clean.

  • cargo test -p leonida-hle --lib --locked: 248 passed, 0 failed, 2 ignored.
  • Red/green. With the new blob check removed from load(), an_unreadable_newer_version_does_not_cost_the_save panics at xgamesave.rs:1038, and the rest of xgamesave passes (10 of 11). With the check it passes.
  • cargo clippy -p leonida-hle --lib --tests: no warning in xgamesave.rs.

From reading commit(): the manifest is written into the staged folder with the blobs, before the folder is made a version. So a complete version can't fail the new check while its folder is being made.

Not checked: the game's own saves.

GPUs tested: n/a (CPU unit tests)

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342568474 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3082#issuecomment-7342568474). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T10:30:22Z. --- Windows 11, MSVC toolchain 1.98.1. Head `37d55d7e2` merged into current `main` `80910637f`: the merge is clean. - `cargo test -p leonida-hle --lib --locked`: 248 passed, 0 failed, 2 ignored. - **Red/green.** With the new blob check removed from `load()`, `an_unreadable_newer_version_does_not_cost_the_save` panics at `xgamesave.rs:1038`, and the rest of `xgamesave` passes (10 of 11). With the check it passes. - `cargo clippy -p leonida-hle --lib --tests`: no warning in `xgamesave.rs`. From reading `commit()`: the manifest is written into the staged folder with the blobs, before the folder is made a version. So a complete version can't fail the new check while its folder is being made. Not checked: the game's own saves. GPUs tested: n/a (CPU unit tests) AI-assisted: yes (Claude Code).
lixonik commented 2026-12-02 11:14:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T11:14:36Z.


Verified locally on Windows 10 x64, PR head 37d55d7e2 merged cleanly onto main a252854a2:

  • Red -> Green proof (modules::xgamesave::tests::an_unreadable_newer_version_does_not_cost_the_save):
    • With main's load() + the PR's expanded strays cases (missing blob, blob is a directory): FAILED (rc=101, panicked at xgamesave.rs:1038).
    • With PR #3082 (37d55d7e2): PASSED (1 passed; 0 failed).
  • Targeted unit suite: cargo test -p leonida-hle --locked --lib save -- 11 passed, 0 failed.
  • Clean-room check: python -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/xgamesave.rs -- exit 0.
  • Code review: load() checks std::fs::metadata(dir.join(index.to_string())) for every manifest-declared blob (0..blobs.len()), returning Ok(None) on NotFound or non-regular files (such as a directory) so version selection cleanly falls back to the last complete version while still propagating unexpected I/O errors.

Result: PASS.

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7343633933 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3082#issuecomment-7343633933). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T11:14:36Z. --- Verified locally on Windows 10 x64, PR head `37d55d7e2` merged cleanly onto `main` `a252854a2`: - **Red -> Green proof (`modules::xgamesave::tests::an_unreadable_newer_version_does_not_cost_the_save`):** - With `main`'s `load()` + the PR's expanded `strays` cases (`missing blob`, `blob is a directory`): **FAILED** (`rc=101`, panicked at `xgamesave.rs:1038`). - With PR `#3082` (`37d55d7e2`): **PASSED** (`1 passed; 0 failed`). - **Targeted unit suite:** `cargo test -p leonida-hle --locked --lib save` -- **11 passed, 0 failed**. - **Clean-room check:** `python -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/xgamesave.rs` -- exit `0`. - **Code review:** `load()` checks `std::fs::metadata(dir.join(index.to_string()))` for every manifest-declared blob (`0..blobs.len()`), returning `Ok(None)` on `NotFound` or non-regular files (such as a directory) so version selection cleanly falls back to the last complete version while still propagating unexpected I/O errors. Result: **PASS**. AI-assisted: yes (Antigravity).
MoonEyes commented 2026-12-02 18:02:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:02:19Z.


Code review only, not built (leonida-hle is in the Windows workspace). Ready.

  • Head: 37d55d7e2, merge base 80910637f, 179 behind current main 45dc41f95. A trial merge is clean.
  • CI: the runs on this head are waiting for maintainer approval (action_required).
  • Already verified on this exact head, with no commits since:
    • Kal0s-design (10:30): Windows 11 run.
    • lixonik (11:14): red/green by source revert. an_unreadable_newer_version_does_not_cost_the_save fails with main's load() plus the new cases and passes with the PR. cargo test -p leonida-hle --lib save gives 11 passed.

Review of d3d12/crates/leonida-hle/src/modules/xgamesave.rs:

  • load() now treats a version whose manifest names a blob that is missing, or not a regular file, as incomplete (Ok(None)). Version selection then falls back to the last complete version. This is the root cause: the newest version was chosen on its manifest alone.
  • NotFound and non-file entries return None. Any other I/O error propagates, so a permission problem is not mistaken for "incomplete".
  • The cost is one metadata call per blob, only when a save container is loaded. That is not a hot path.
  • The test extends the existing table with "missing blob" and "blob is a directory", which are the two new branches.

Verdict: ready.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353883077 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3082#issuecomment-7353883077). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:02:19Z. --- **Code review only, not built (`leonida-hle` is in the Windows workspace). Ready.** - Head: `37d55d7e2`, merge base `80910637f`, 179 behind current `main` `45dc41f95`. A trial merge is clean. - CI: the runs on this head are waiting for maintainer approval (`action_required`). - Already verified on this exact head, with no commits since: - Kal0s-design (10:30): Windows 11 run. - lixonik (11:14): red/green by source revert. `an_unreadable_newer_version_does_not_cost_the_save` fails with `main`'s `load()` plus the new cases and passes with the PR. `cargo test -p leonida-hle --lib save` gives 11 passed. **Review of `d3d12/crates/leonida-hle/src/modules/xgamesave.rs`:** - `load()` now treats a version whose manifest names a blob that is missing, or not a regular file, as incomplete (`Ok(None)`). Version selection then falls back to the last complete version. This is the root cause: the newest version was chosen on its manifest alone. - `NotFound` and non-file entries return `None`. Any other I/O error propagates, so a permission problem is not mistaken for "incomplete". - The cost is one `metadata` call per blob, only when a save container is loaded. That is not a hot path. - The test extends the existing table with "missing blob" and "blob is a directory", which are the two new branches. Verdict: **ready**. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_

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