HLE: reject duplicate blob changes in one save update #590

Open
Quat3rnion wants to merge 1 commit from upstream-pr/590 into main
Quat3rnion commented 2026-11-24 05:14:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T05:14:58Z.


What

XGameSave permits only one write or delete of a blob per update. WriteBlob
and DeleteBlob accepted repeated changes and submit silently kept the
last one, so a title could pass locally and then fail the same transaction on
a console. A second change to a blob already in the update is now refused
with E_INVALIDARG, keeping the first. The existing save test that relied on
write-then-delete was corrected to expect the refusal.

An AI tool wrote part of this change.

Evidence

The one-change rule is documented in the public API reference: "you can only write one modification/deletion per blob in an update context" (XGameSaveSubmitBlobWrite remarks) and "a single blob can only have one modification to it per update" (XGameSave API overview), both at https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/game-save/xgamesave . The references do not name a specific HRESULT for a repeated change; this module returns E_INVALIDARG for other invalid update arguments, so the guard follows that convention.

Tested

  • Linux: cargo test --workspace: 164 passed, 0 failed, 3 ignored. The save fixture now checks that both a delete and a second write of the same blob fail in one update, and verifies the committed blob set.
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. No Windows host here.
  • cargo xtask policy passes (150 files ok). No game files or data from them were added.

Checklist

  • Workspace tests and Windows cross-check pass.
  • cargo xtask policy passes. No game files or data from them were added.
  • AI authorship is disclosed above.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5466544535 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-24T05:14:58Z. --- ## What XGameSave permits only one write or delete of a blob per update. `WriteBlob` and `DeleteBlob` accepted repeated changes and `submit` silently kept the last one, so a title could pass locally and then fail the same transaction on a console. A second change to a blob already in the update is now refused with `E_INVALIDARG`, keeping the first. The existing save test that relied on write-then-delete was corrected to expect the refusal. An AI tool wrote part of this change. ## Evidence The one-change rule is documented in the public API reference: "you can only write one modification/deletion per blob in an update context" (XGameSaveSubmitBlobWrite remarks) and "a single blob can only have one modification to it per update" (XGameSave API overview), both at https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/game-save/xgamesave . The references do not name a specific HRESULT for a repeated change; this module returns `E_INVALIDARG` for other invalid update arguments, so the guard follows that convention. ## Tested - Linux: `cargo test --workspace`: 164 passed, 0 failed, 3 ignored. The save fixture now checks that both a delete and a second write of the same blob fail in one update, and verifies the committed blob set. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. No Windows host here. - `cargo xtask policy` passes (150 files ok). No game files or data from them were added. ## Checklist - [x] Workspace tests and Windows cross-check pass. - [x] `cargo xtask policy` passes. No game files or data from them were added. - [x] AI authorship is disclosed above.
LAKSHYA-cmd-tech commented 2026-11-24 05:16:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T05:16:13Z.

Review: APPROVED


Verified on Windows 11:

  • All 5 \xgamesave\ unit and integration tests pass.
  • Duplicate blob changes within a single save transaction are correctly refused with \E_INVALIDARG, preserving the initial change and matching Xbox console semantics.
  • Asset policy passes (150 files checked, 0 violations).
<!-- greyfinch-sync:Marvisak/VIctory:review:6034074702 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590#pullrequestreview-6034074702). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T05:16:13Z. **Review:** APPROVED --- Verified on Windows 11: - All 5 \xgamesave\ unit and integration tests pass. - Duplicate blob changes within a single save transaction are correctly refused with \E_INVALIDARG\, preserving the initial change and matching Xbox console semantics. - Asset policy passes (150 files checked, 0 violations).
mercuryVM commented 2026-11-24 11:33:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:33:41Z.

Review: APPROVED


Tested 32e0690 on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 87 passed, including the updated save fixture. Clippy's 1 warning is the existing field_reassign_with_default at xmem.rs:747.

  • Both WriteBlob and DeleteBlob now check update.changes for the name before recording, and the first change is kept. That matches the GDK rule that a blob takes one write or delete per update, and a title that breaks it now fails here as it would on a console instead of passing silently.
  • Linear scan over changes is fine at the GDK's per-update blob limit.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038452516 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590#pullrequestreview-6038452516). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:33:41Z. **Review:** APPROVED --- Tested 32e0690 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` 87 passed, including the updated save fixture. Clippy's 1 warning is the existing `field_reassign_with_default` at xmem.rs:747. - Both `WriteBlob` and `DeleteBlob` now check `update.changes` for the name before recording, and the first change is kept. That matches the GDK rule that a blob takes one write or delete per update, and a title that breaks it now fails here as it would on a console instead of passing silently. - Linear scan over `changes` is fine at the GDK's per-update blob limit. AI-assisted (Claude Code).
geiyiliyabumo commented 2026-11-24 13:02:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T12:53:40Z.


Review: reject duplicate blob changes in one save update

Diff read: crates/victory-hle/src/modules/xgamesave.rs only, +18 / -3. Full hunks reviewed.

What it does

  • write_blob (xgamesave.rs:881-884) and delete_blob (xgamesave.rs:892-893) now reject a second change to a blob already queued in the same Update, returning E_INVALIDARG.
  • The saves_persist_across_providers test is updated: a delete of "gone" after writing it is now refused, so the container reports 3 blobs / 8 bytes instead of 2 / 7 (xgamesave.rs:1265, (2,7) ? (3,8)), and the new assertions check both the duplicate-delete and duplicate-write rejections.

Findings
No correctness or memory-safety bug.

  • The duplicate check uses exact String equality, consistent with how Update::submit merges changes (blobs.retain(|(n, _)| n != name), xgamesave.rs:444-449) and with blob names being stored as exact strings in the manifest (no case folding; cf. names_are_exact). So this does not introduce a case-sensitivity mismatch.
  • It correctly rejects all four duplicate combinations (write-then-write, write-then-delete, delete-then-write, delete-then-delete).

Behaviour change worth confirming (not a blocker)
This intentionally changes prior semantics: previously a write-then-delete in one update was applied in order in submit and netted to a deletion, and multiple writes were last-wins. Now any repeat is an error. That matches the GDK rule the PR cites ("loads only one write or delete of a blob per update"), but I could not verify that rule against the GDK headers/docs offline. The only real risk is a title that legitimately writes the same blob more than once per update (e.g. chunked/incremental writes) and previously relied on last-wins ? such a title would now fail the whole update with E_INVALIDARG. Worth a quick check against observed title behaviour.

Minor nit: write_blob copies data into a Vec (xgamesave.rs:875-880, up to 16 MiB) before the duplicate check at xgamesave.rs:881; running the guard first would avoid the copy on the rejected path. Non-blocking.

Commands actually run (proxy cleared, --locked, CARGO_INCREMENTAL=0, shared target dir):

  • cargo xtask policy ? asset policy: 154 files ok (exit 0)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings ? exit 0, no diagnostics
  • cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings ? exit 0, no diagnostics
  • cargo test -p victory-hle --locked -- xgamesave ? 7 passed; 0 failed (saves_persist_across_providers, names_are_exact, a_kill_at_any_step_leaves_old_or_new, a_full_disk_is_not_the_quota, the_old_layout_moves_over, an_empty_configuration_id_is_the_default_one, crash_child)

Verdict: approve-worthy. Correct and internally consistent; the one thing to sanity-check is the GDK "one write/delete per blob per update" rule against real title behaviour.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132063631 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590#issuecomment-7132063631). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T12:53:40Z. --- ## Review: reject duplicate blob changes in one save update **Diff read:** `crates/victory-hle/src/modules/xgamesave.rs` only, +18 / -3. Full hunks reviewed. **What it does** - `write_blob` (`xgamesave.rs:881-884`) and `delete_blob` (`xgamesave.rs:892-893`) now reject a second change to a blob already queued in the same `Update`, returning `E_INVALIDARG`. - The `saves_persist_across_providers` test is updated: a delete of `"gone"` after writing it is now refused, so the container reports 3 blobs / 8 bytes instead of 2 / 7 (`xgamesave.rs:1265`, `(2,7)` ? `(3,8)`), and the new assertions check both the duplicate-delete and duplicate-write rejections. **Findings** No correctness or memory-safety bug. - The duplicate check uses exact `String` equality, consistent with how `Update::submit` merges changes (`blobs.retain(|(n, _)| n != name)`, `xgamesave.rs:444-449`) and with blob names being stored as exact strings in the manifest (no case folding; cf. `names_are_exact`). So this does not introduce a case-sensitivity mismatch. - It correctly rejects all four duplicate combinations (write-then-write, write-then-delete, delete-then-write, delete-then-delete). **Behaviour change worth confirming (not a blocker)** This intentionally changes prior semantics: previously a write-then-delete in one update was applied in order in `submit` and netted to a deletion, and multiple writes were last-wins. Now any repeat is an error. That matches the GDK rule the PR cites ("loads only one write or delete of a blob per update"), but I could not verify that rule against the GDK headers/docs offline. The only real risk is a title that legitimately writes the same blob more than once per update (e.g. chunked/incremental writes) and previously relied on last-wins ? such a title would now fail the whole update with `E_INVALIDARG`. Worth a quick check against observed title behaviour. **Minor nit:** `write_blob` copies `data` into a `Vec` (`xgamesave.rs:875-880`, up to 16 MiB) before the duplicate check at `xgamesave.rs:881`; running the guard first would avoid the copy on the rejected path. Non-blocking. **Commands actually run** (proxy cleared, `--locked`, `CARGO_INCREMENTAL=0`, shared target dir): - `cargo xtask policy` ? `asset policy: 154 files ok` (exit 0) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` ? exit 0, no diagnostics - `cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings` ? exit 0, no diagnostics - `cargo test -p victory-hle --locked -- xgamesave` ? `7 passed; 0 failed` (`saves_persist_across_providers`, `names_are_exact`, `a_kill_at_any_step_leaves_old_or_new`, `a_full_disk_is_not_the_quota`, `the_old_layout_moves_over`, `an_empty_configuration_id_is_the_default_one`, `crash_child`) **Verdict:** approve-worthy. Correct and internally consistent; the one thing to sanity-check is the GDK "one write/delete per blob per update" rule against real title behaviour. *AI-assisted; synthetic tests only, no game files.*
Marvisak commented 2026-11-25 02:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:23:35Z.


Automated triage for the maintainers.

Needs work.

What it does: write_blob and delete_blob in crates/victory-hle/src/modules/xgamesave.rs now return E_INVALIDARG when the same update already has a change to that blob. The test is updated to expect this. The check itself is consistent with how Update::submit matches names.

What it needs:

  • Evidence for the rule. This changes a runtime return value. Until now, a repeated change was applied in order (last one wins), which can't hurt a title. After this PR, a title that changes a blob twice in one update gets a failure it may not handle. Please link public documentation or describe console behaviour that shows the second change is refused, and that the result is E_INVALIDARG rather than a failure at submit time.
  • Reword the comment "GDK permits only one write or delete of a blob per update": the repo doesn't name the console SDK (rule 2). Something like "only one change per blob per update" works.
  • Minor: in write_blob, run the duplicate check before copying data (up to 16 MiB) into a Vec.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149497843 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590#issuecomment-7149497843). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:23:35Z. --- <!-- victory-triage v1 head=52ceb8f7173de3e5c378cd0c67d0c45e17fc1eff verdict=needs-work at=2026-11-25T01:23:33Z --> Automated triage for the maintainers. **Needs work.** What it does: `write_blob` and `delete_blob` in `crates/victory-hle/src/modules/xgamesave.rs` now return `E_INVALIDARG` when the same update already has a change to that blob. The test is updated to expect this. The check itself is consistent with how `Update::submit` matches names. What it needs: - **Evidence for the rule.** This changes a runtime return value. Until now, a repeated change was applied in order (last one wins), which can't hurt a title. After this PR, a title that changes a blob twice in one update gets a failure it may not handle. Please link public documentation or describe console behaviour that shows the second change is refused, and that the result is `E_INVALIDARG` rather than a failure at submit time. - **Reword the comment** "GDK permits only one write or delete of a blob per update": the repo doesn't name the console SDK (rule 2). Something like "only one change per blob per update" works. - Minor: in `write_blob`, run the duplicate check before copying `data` (up to 16 MiB) into a `Vec`. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Quat3rnion commented 2026-11-27 02:49:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-27T02:49:30Z.


@Marvisak Addressed the triage in new head f58cd1d07: the comment no longer names an SDK acronym, and the duplicate check runs before the up-to-16-MiB blob copy. I added the public documentation for the one-change-per-blob rule to the PR description; the docs do not name an HRESULT for a repeat, so E_INVALIDARG follows this module's other invalid-update paths. Clippy -D warnings passes on the Windows target.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7208468263 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/590#issuecomment-7208468263). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-27T02:49:30Z. --- @Marvisak Addressed the triage in new head `f58cd1d07`: the comment no longer names an SDK acronym, and the duplicate check runs before the up-to-16-MiB blob copy. I added the public documentation for the one-change-per-blob rule to the PR description; the docs do not name an HRESULT for a repeat, so `E_INVALIDARG` follows this module's other invalid-update paths. Clippy `-D warnings` passes on the Windows target.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/590:upstream-pr/590'
git switch 'upstream-pr/590'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/590'
git switch 'upstream-pr/590'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/590'
git switch 'upstream-pr/590'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/590'
git switch 'main'
git merge --squash 'upstream-pr/590'
git switch 'main'
git merge --ff-only 'upstream-pr/590'
git switch 'main'
git merge 'upstream-pr/590'
git push origin 'main'
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
Marvisak/VIctory!590
No description provided.