Skip to content

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

Open
leftmove wants to merge 2 commits into
Marvisak:mainfrom
leftmove:fix/find-23-xgamesave-migration
Open

leftmove wants to merge 2 commits into
Marvisak:mainfrom
leftmove:fix/find-23-xgamesave-migration

Conversation

@leftmove

@leftmove leftmove commented Nov 25, 2026 •

Copy link
Copy Markdown

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 HLE: retain unreadable legacy save display metadata (on #2525) #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).

@kotekompotek

Copy link
Copy Markdown

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.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent WARP/CPU verification for head 7eefcfa against origin/main 13f91ca. 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).

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@leftmove
leftmove force-pushed the fix/find-23-xgamesave-migration branch from 7eefcfa to cdf2ec6 Compare November 26, 2026 03:27
@leftmove

Copy link
Copy Markdown
Author

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 HLE: retain unreadable legacy save display metadata (on #2525) #2675 passed all 17 local XGameSave tests, exercising HLE: retain unreadable legacy save display metadata (on #2525) #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants