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

Open
github-bot wants to merge 1 commit from github-bot/gh-590 into main AGit
Owner

@⁠Quat3rnion on GitHub · 2026-11-24 05:14 UTC · original
Quat3rnion:victory-save-duplicates → main · +18 −3 · 1 files · 1 commits · open

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.

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.
**@⁠Quat3rnion** on GitHub · 2026-11-24 05:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/590) `Quat3rnion:victory-save-duplicates` → `main` · +18 −3 · 1 files · 1 commits · open ## 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. ## 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.
XGameSave permits only one write or delete per blob in an update. WriteBlob and DeleteBlob accepted repeats and submit silently kept the last one, so a title could pass locally but fail on a console. Refuse a second change to a blob already in the update, update the existing test that relied on write-then-delete, and keep the first change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:25 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 12:53 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 12:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/590#issuecomment-7132063631) ## 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.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:23 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/590#issuecomment-7149497843) <!-- 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)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/590/head:github-bot/gh-590'
git switch 'github-bot/gh-590'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-590'
git switch 'github-bot/gh-590'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-590'
git switch 'github-bot/gh-590'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-590'
git switch 'main'
git merge --squash 'github-bot/gh-590'
git switch 'main'
git merge --ff-only 'github-bot/gh-590'
git switch 'main'
git merge 'github-bot/gh-590'
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!590
No description provided.