Preserve ambiguous legacy XGameSave migrations (FIND-23) #2720

Open
github-bot wants to merge 2 commits from github-bot/gh-2720 into main AGit
Owner

@⁠leftmove on GitHub · 2026-11-25 18:49 UTC · original
leftmove:fix/find-23-xgamesave-migration → main · +236 −1 · 1 files · 2 commits · open

Summary

On main, migrate() treats an old-layout folder beside a committed save as the leftover from an interrupted migration and removes it. The two can legitimately differ. On Windows, a legacy blob opened without read or delete sharing can be skipped during migration. VIctory commits the other blobs to v1, then fails to remove the locked file. After the handle closes, the legacy folder still contains a blob that never made it into v1.

A selected v1 clears the old folder only when the display metadata, decoded names, and payloads match. A later commit with readable listed blobs takes precedence, preserving its intentional deletions. An unreadable committed version that produces InvalidData also takes the preservation path.

Preserved data lives in numbered slots under <container>/.legacy. VIctory does not read the backed-up files. Deleting the container removes its .legacy directory along with the active save. Each move reserves a fresh slot, so existing backups stay intact and cannot block deletion. If a legacy folder is still in the provider root when the title deletes the container, deletion moves it into a fresh slot before retiring the whole container, preventing its re-import on the next open.

This branch is based on current main. A scratch merge with #2675 was clean and exercised that PR's missing-blob loader behavior. Coordination claim

Verification

  • Rust 1.98.1 built the Windows test binaries with cargo test -p victory-hle --locked --target x86_64-pc-windows-gnullvm --no-run. Windows-target Clippy passed for all targets and features with -D warnings.
  • The temporary Linux checkout gated unrelated Windows-only code. cargo test -p victory-hle --locked --lib xgamesave passed all 15 tests on this branch and all 17 on the scratch merge with #2675. The full Linux library run had 82 passes and two Windows-specific kernel failures that also reproduced on current main.
  • cargo xtask policy passed for 191 files. The tests used synthetic saves. Gameplay and physical GPU behavior remain unverified.

Native Windows CI passed the workspace test suite and both strict Clippy runs. This included all 16 XGameSave tests, 157 HLE unit tests, and both HLE integration tests. Windows CI

Written with AI assistance (Codex).

**@⁠leftmove** on GitHub · 2026-11-25 18:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720) `leftmove:fix/find-23-xgamesave-migration` → `main` · +236 −1 · 1 files · 2 commits · open ## Summary On `main`, `migrate()` treats an old-layout folder beside a committed save as the leftover from an interrupted migration and removes it. The two can legitimately differ. On Windows, a legacy blob opened without read or delete sharing can be skipped during migration. VIctory commits the other blobs to v1, then fails to remove the locked file. After the handle closes, the legacy folder still contains a blob that never made it into v1. A selected v1 clears the old folder only when the display metadata, decoded names, and payloads match. A later commit with readable listed blobs takes precedence, preserving its intentional deletions. An unreadable committed version that produces `InvalidData` also takes the preservation path. Preserved data lives in numbered slots under `<container>/.legacy`. VIctory does not read the backed-up files. Deleting the container removes its `.legacy` directory along with the active save. Each move reserves a fresh slot, so existing backups stay intact and cannot block deletion. If a legacy folder is still in the provider root when the title deletes the container, deletion moves it into a fresh slot before retiring the whole container, preventing its re-import on the next open. This branch is based on current `main`. A scratch merge with #2675 was clean and exercised that PR's missing-blob loader behavior. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) ## Verification - Rust 1.98.1 built the Windows test binaries with `cargo test -p victory-hle --locked --target x86_64-pc-windows-gnullvm --no-run`. Windows-target Clippy passed for all targets and features with `-D warnings`. - The temporary Linux checkout gated unrelated Windows-only code. `cargo test -p victory-hle --locked --lib xgamesave` passed all 15 tests on this branch and all 17 on the scratch merge with #2675. The full Linux library run had 82 passes and two Windows-specific kernel failures that also reproduced on current main. - `cargo xtask policy` passed for 191 files. The tests used synthetic saves. Gameplay and physical GPU behavior remain unverified. Native Windows CI passed the workspace test suite and both strict Clippy runs. This included all 16 XGameSave tests, 157 HLE unit tests, and both HLE integration tests. [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/45749020586/job/139672027488) Written with AI assistance (Codex).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:44 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:59 UTC · original

Careful data-preservation logic: v1 proves the legacy folder by full content equality (display + decoded names + payload bytes), later versions only supersede when every listed blob is readable - which is exactly the guarantee needed since updates legitimately delete blobs. Ambiguous cases get renamed to .legacy rather than silently dropped, and delete() refusing while a re-importable legacy folder remains prevents the resurrect-old-save trap. Note: version.dir.ends_with("v1") is a path-component check so only v1 matches (v11, v21 don't) - correct, just easy to misread.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720#issuecomment-7171664003) Careful data-preservation logic: v1 proves the legacy folder by full content equality (display + decoded names + payload bytes), later versions only supersede when every listed blob is readable - which is exactly the guarantee needed since updates legitimately delete blobs. Ambiguous cases get renamed to .legacy rather than silently dropped, and delete() refusing while a re-importable legacy folder remains prevents the resurrect-old-save trap. Note: version.dir.ends_with("v1") is a path-component check so only v1 matches (v11, v21 don't) - correct, just easy to misread.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 19:41 UTC · original

Independent WARP/CPU verification for head 7eefcfa2a42962c5a098440b040a06fea6208374 against origin/main 13f91caee2. State check: open, non-draft, clean merge-tree; no oni-swr comment found.

Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); WARP/D3D12 WARP env vars set; CARGO_TARGET_DIR=D:\victory-warp-2720-target. Fixtures are synthetic temp files.

Commands/results:

  • Baseline: cargo test --locked -p victory-hle xgamesave:: — 11 passed; cargo test --locked -p victory-hle — 146 library tests passed plus 2 integration tests passed; cargo clippy --locked -p victory-hle --all-targets -- -D warnings — pass.
  • PR: focused XGameSave command — 16 passed; full cargo test --locked -p victory-hle — 151 library tests passed plus 2 integration tests passed; strict Clippy — pass.
  • Negative control: disabled the ambiguous-legacy preservation branch; an_ambiguous_first_version_keeps_legacy_data_separate failed when the legacy data vanished.

Review: no data-loss issue found in the matching, backup, or delete-blocking paths exercised here.

Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).

**@⁠oni-swr** on GitHub · 2026-11-25 19:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720#issuecomment-7172641817) Independent WARP/CPU verification for head 7eefcfa2a42962c5a098440b040a06fea6208374 against origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. State check: open, non-draft, clean merge-tree; no oni-swr comment found. Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); WARP/D3D12 WARP env vars set; CARGO_TARGET_DIR=D:\victory-warp-2720-target. Fixtures are synthetic temp files. Commands/results: - Baseline: cargo test --locked -p victory-hle xgamesave:: — 11 passed; cargo test --locked -p victory-hle — 146 library tests passed plus 2 integration tests passed; cargo clippy --locked -p victory-hle --all-targets -- -D warnings — pass. - PR: focused XGameSave command — 16 passed; full cargo test --locked -p victory-hle — 151 library tests passed plus 2 integration tests passed; strict Clippy — pass. - Negative control: disabled the ambiguous-legacy preservation branch; an_ambiguous_first_version_keeps_legacy_data_separate failed when the legacy data vanished. Review: no data-loss issue found in the matching, backup, or delete-blocking paths exercised here. Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:42 UTC · original

Independent Windows 11 verification and review of 7eefcfa (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-hle: 151 passed, 0 failed (lib, all 5 new legacy-migration tests pass), plus fidelityfx (1) and no_dll_planting (1) clean.

Review & Merge-Ordering Notes

  • Verifying byte-for-byte identity against v1 (matches_legacy) and blob readability for v2+ before deleting old, moving ambiguous legacy folders to dir/.legacy (preserving old if .legacy already exists), and blocking delete while an unmoved legacy folder remains directly close the data-loss window where a concurrent write could otherwise cause migrate() to wipe unmigrated legacy blobs.
  • Merge compatibility & semantic interaction with #2525 / #2675:
    • Clean zero-conflict 3-way merge with #2674 and #2716.
    • Conflicts in xgamesave.rs::migrate and mod tests with #2675 (which carries #2525). Beyond the textual conflict, note a semantic interaction: #2525/#2675 changes load() to return Ok(None) when a listed blob is missing, causing current_named(&dir, name) to return Err(InvalidData). Under #2720's if let Some(version) = current_named(&dir, name).ok()?, that error short-circuits to None rather than moving old to dir/.legacy (which would break incomplete_later_version_preserves_legacy_data after merging both unless Err(InvalidData) with an existing version dir is also routed to the .legacy backup path).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720#issuecomment-7172665544) Independent Windows 11 verification and review of `7eefcfa` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-hle`: **151 passed, 0 failed** (`lib`, all 5 new legacy-migration tests pass), plus `fidelityfx` (1) and `no_dll_planting` (1) clean. ### Review & Merge-Ordering Notes - Verifying byte-for-byte identity against `v1` (`matches_legacy`) and blob readability for `v2+` before deleting `old`, moving ambiguous legacy folders to `dir/.legacy` (preserving `old` if `.legacy` already exists), and blocking `delete` while an unmoved legacy folder remains directly close the data-loss window where a concurrent write could otherwise cause `migrate()` to wipe unmigrated legacy blobs. - **Merge compatibility & semantic interaction with #2525 / #2675:** - Clean zero-conflict 3-way merge with **#2674** and **#2716**. - Conflicts in `xgamesave.rs::migrate` and `mod tests` with **#2675** (which carries #2525). Beyond the textual conflict, note a semantic interaction: #2525/#2675 changes `load()` to return `Ok(None)` when a listed blob is missing, causing `current_named(&dir, name)` to return `Err(InvalidData)`. Under `#2720`'s `if let Some(version) = current_named(&dir, name).ok()?`, that error short-circuits to `None` rather than moving `old` to `dir/.legacy` (which would break `incomplete_later_version_preserves_legacy_data` after merging both unless `Err(InvalidData)` with an existing version dir is also routed to the `.legacy` backup path).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:19 UTC · original · edited 2026-11-26 04:23 UTC

Automated triage for the maintainers.

Needs work. Thanks for working through all four points; backups now go into fresh numbered slots, delete removes the whole container, and InvalidData takes the preservation path, with tests. The remaining problem is in migrate itself (victory-hle/src/modules/xgamesave.rs): its filter_map drops any blob whose std::fs::read fails and commits v1 without it, so the title still loses it even though it is kept under .legacy. Please make migrate stop without committing when a legacy blob cannot be read (leave the old folder for the next open), with a test; then I would see this as a merge candidate.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720#issuecomment-7177406332) · edited 2026-11-26 04:23 UTC <!-- victory-triage v1 head=cdf2ec6454f335c7229c6d06b855e97a5a82bf36 verdict=needs-work at=2026-11-26T04:22:59Z --> Automated triage for the maintainers. **Needs work.** Thanks for working through all four points; backups now go into fresh numbered slots, `delete` removes the whole container, and `InvalidData` takes the preservation path, with tests. The remaining problem is in `migrate` itself (`victory-hle/src/modules/xgamesave.rs`): its `filter_map` drops any blob whose `std::fs::read` fails and commits v1 without it, so the title still loses it even though it is kept under `.legacy`. Please make `migrate` stop without committing when a legacy blob cannot be read (leave the old folder for the next open), with a test; then I would see this as a merge candidate. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠leftmove on GitHub · 2026-11-26 03:31 UTC · original

Addressed the four triage points in cdf2ec6, rebased onto main at 63bcca4.

  1. The PR description now explains how main can produce a divergent legacy folder. A Windows sharing violation can cause migration to skip a locked blob, publish v1 from the remaining blobs, and leave the locked legacy file in place when cleanup fails.
  2. Preservation reserves a fresh numbered backup slot before each move. Delete now retires any still-present legacy folder into a fresh slot and then deletes the whole container. The regression verifies that two backups coexist and that title deletion also succeeds with a third legacy folder still present. Reopening confirms it stays deleted.
  3. The description states that preserved files live under <container>/.legacy, VIctory does not read the files, and deleting the container removes them with the active save.
  4. An InvalidData result for an unreadable committed destination now takes the preservation path. incomplete_later_version_preserves_legacy_data covers both missing blobs and a missing manifest. The branch remains based on main. A clean scratch merge with #2675 passed all 17 local XGameSave tests, exercising #2675's missing-blob loader in the same regression.

Native Windows CI passed all 16 XGameSave tests, all 157 HLE unit tests, both HLE integration tests, and both strict Clippy runs. cargo xtask policy passed for 191 files. The tests used synthetic saves. Windows CI

AI-assisted with Codex.

**@⁠leftmove** on GitHub · 2026-11-26 03:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2720#issuecomment-7181790958) Addressed the four triage points in `cdf2ec6`, rebased onto `main` at `63bcca4`. 1. The PR description now explains how main can produce a divergent legacy folder. A Windows sharing violation can cause migration to skip a locked blob, publish v1 from the remaining blobs, and leave the locked legacy file in place when cleanup fails. 2. Preservation reserves a fresh numbered backup slot before each move. Delete now retires any still-present legacy folder into a fresh slot and then deletes the whole container. The regression verifies that two backups coexist and that title deletion also succeeds with a third legacy folder still present. Reopening confirms it stays deleted. 3. The description states that preserved files live under `<container>/.legacy`, VIctory does not read the files, and deleting the container removes them with the active save. 4. An `InvalidData` result for an unreadable committed destination now takes the preservation path. `incomplete_later_version_preserves_legacy_data` covers both missing blobs and a missing manifest. The branch remains based on main. A clean scratch merge with #2675 passed all 17 local XGameSave tests, exercising #2675's missing-blob loader in the same regression. Native Windows CI passed all 16 XGameSave tests, all 157 HLE unit tests, both HLE integration tests, and both strict Clippy runs. `cargo xtask policy` passed for 191 files. The tests used synthetic saves. [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/45749020586/job/139672027488) AI-assisted with Codex.
This pull request can be merged automatically.
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 origin '+refs/pull/2720/head:github-bot/gh-2720'
git switch 'github-bot/gh-2720'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2720'
git switch 'github-bot/gh-2720'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2720'
git switch 'github-bot/gh-2720'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2720'
git switch 'main'
git merge --squash 'github-bot/gh-2720'
git switch 'main'
git merge --ff-only 'github-bot/gh-2720'
git switch 'main'
git merge 'github-bot/gh-2720'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2720
No description provided.