runtime: add XUser and XGameSave contracts #1062

Merged
lambirou merged 2 commits from upstream-pr/1069 into main 2026-11-24 01:06:25 +00:00
lambirou commented 2026-11-24 00:14:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T00:14:10Z.


Change

Make the XUser and XGameSave representative calls observable in the fixture-only XGameRuntime
shim.

  • The X-macro table now carries three states: stub, implemented_hr and
    implemented_void. Stubs keep the bounded log and E_NOTIMPL; implemented entries return
    their result and record a deterministic success entry.
  • XUser provides XUserFindUserById, XUserGetId, XUserDuplicateHandle and
    XUserCloseHandle with the fixed synthetic XUID 0x0009000000000001.
  • XGameSave provides an in-memory provider, four containers, four updates and four 1,024-byte
    blobs, then XGameSaveSubmitBlobWrite, XGameSaveSubmitUpdate and
    XGameSaveReadBlobData with their close paths. It does not persist to disk or sync with Xbox.
  • Container data is keyed by provider scope and container name, not by an open handle. A second
    handle for the same named container sees the same blobs, and reopening it after closing both
    handles still reads the committed data. Independent names on one provider stay isolated.
  • Updates bind to the parent container identity. After the parent closes and its slot is reused
    by another container, submitting the old update returns E_GS_HANDLE_EXPIRED
    (0x8083000D) and leaves the new container unchanged.
  • XUserAddAsync and XGameSaveInitializeProviderAsync remain named, logged stubs: the
    public XAsyncBlock, result structures and queue/callback semantics are not available without
    a GDK header, so they are not simulated.
  • tests/xgameruntime_contracts_check.cpp is the synthetic title. It calls XUser and
    XGameSave, checks exact values and asserts the log contains no E_NOTIMPL for those calls.
    Negative controls call XPackage and XGame functions and require E_NOTIMPL plus log entries.

Verification

  • cmake --build --preset dev --target xgameruntime_shim xgameruntime_shim_check xgameruntime_contracts_check xgameruntime_preflight_exe xmem_shim d3d12_xs_shim
    • Passed with MSVC 19.44.
  • ctest --preset dev --no-tests=error -R '^xgameruntime_' -V
    • 3/3 passed: xgameruntime_thunks, xgameruntime_contracts and
      xgameruntime_preflight_stub_refused.
    • Contracts output:
      xgameruntime contracts: user=implemented game-save=implemented reopen=ok stale=E_GS_HANDLE_EXPIRED negative=E_NOTIMPL x2 PASS.
  • python -B tests/xgameruntime_table_check.py
    • exports=20 classes=XAsync,XGame,XGameSave,XPackage,XSystem,XTaskQueue,XUser states=implemented_hr=9,implemented_void=4,stub=7 duplicate_control=detected PASS.
  • docs_links_check.py: Self-test passed., Checked 15 Markdown files and 238 links..
  • git diff --check origin/main...HEAD: clean.
  • Not run: the full CTest suite, the release preset and Windows CI for this branch.

Evidence and follow-up

Checklist

  • One synthetic-title behavior: XUser and XGameSave representative contracts.
  • Positive values, no E_NOTIMPL for those calls, and XPackage/XGame negative controls.
  • Fixture-only DLL, explicit load path and unchanged preflight refusal.
  • No game files, dumps, logs or secrets.
  • Public GDK provenance and named async limitation.
  • AI-assisted (Codex).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6571606461 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1069). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T00:14:10Z. --- ## Change Make the XUser and XGameSave representative calls observable in the fixture-only XGameRuntime shim. - The X-macro table now carries three states: `stub`, `implemented_hr` and `implemented_void`. Stubs keep the bounded log and `E_NOTIMPL`; implemented entries return their result and record a deterministic success entry. - XUser provides `XUserFindUserById`, `XUserGetId`, `XUserDuplicateHandle` and `XUserCloseHandle` with the fixed synthetic XUID `0x0009000000000001`. - XGameSave provides an in-memory provider, four containers, four updates and four 1,024-byte blobs, then `XGameSaveSubmitBlobWrite`, `XGameSaveSubmitUpdate` and `XGameSaveReadBlobData` with their close paths. It does not persist to disk or sync with Xbox. - Container data is keyed by provider scope and container name, not by an open handle. A second handle for the same named container sees the same blobs, and reopening it after closing both handles still reads the committed data. Independent names on one provider stay isolated. - Updates bind to the parent container identity. After the parent closes and its slot is reused by another container, submitting the old update returns `E_GS_HANDLE_EXPIRED` (`0x8083000D`) and leaves the new container unchanged. - `XUserAddAsync` and `XGameSaveInitializeProviderAsync` remain named, logged stubs: the public `XAsyncBlock`, result structures and queue/callback semantics are not available without a GDK header, so they are not simulated. - `tests/xgameruntime_contracts_check.cpp` is the synthetic title. It calls XUser and XGameSave, checks exact values and asserts the log contains no `E_NOTIMPL` for those calls. Negative controls call XPackage and XGame functions and require `E_NOTIMPL` plus log entries. ## Verification - `cmake --build --preset dev --target xgameruntime_shim xgameruntime_shim_check xgameruntime_contracts_check xgameruntime_preflight_exe xmem_shim d3d12_xs_shim` - Passed with MSVC 19.44. - `ctest --preset dev --no-tests=error -R '^xgameruntime_' -V` - 3/3 passed: `xgameruntime_thunks`, `xgameruntime_contracts` and `xgameruntime_preflight_stub_refused`. - Contracts output: `xgameruntime contracts: user=implemented game-save=implemented reopen=ok stale=E_GS_HANDLE_EXPIRED negative=E_NOTIMPL x2 PASS`. - `python -B tests/xgameruntime_table_check.py` - `exports=20 classes=XAsync,XGame,XGameSave,XPackage,XSystem,XTaskQueue,XUser states=implemented_hr=9,implemented_void=4,stub=7 duplicate_control=detected PASS`. - `docs_links_check.py`: `Self-test passed.`, `Checked 15 Markdown files and 238 links.`. - `git diff --check origin/main...HEAD`: clean. - Not run: the full CTest suite, the release preset and Windows CI for this branch. ## Evidence and follow-up - Branch `runtime/xuser-xgamesave`, head `7182b78`, based on `d33845b` (includes XCL-04). `a891097` adds the contracts; `7182b78` fixes the XGameSave data lifetimes after review. - Public sources: [XUserFindUserById](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xuserfinduserbyid?view=gdk-2610), [XUserGetId](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xusergetid?view=gdk-2610), [XUserDuplicateHandle](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xuserduplicatehandle?view=gdk-2604), [XUserCloseHandle](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xuserclosehandle?view=gdk-2604), [XGameSaveInitializeProvider](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesaveinitializeprovider?view=gdk-2604), [XGameSaveCreateContainer](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavecreatecontainer?view=gdk-2604), [XGameSaveCreateUpdate](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavecreateupdate?view=gdk-2610), [XGameSaveSubmitBlobWrite](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavesubmitblobwrite?view=gdk-2604), [XGameSaveSubmitUpdate](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavesubmitupdate?view=gdk-2610), [XGameSaveReadBlobData](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavereadblobdata?view=gdk-2604). - The async stubs cite the public `XUserAddAsync` and `XGameSaveInitializeProviderAsync` pages. The missing async contract is a named limitation, not a silent stub. - The PR is larger than the 400-line guide because it adds the table state machine, the provider-scoped container store and the synthetic title for the two classes grouped by XCL-05. The async surface remains unimplemented and explicitly logged. - No game files, dumps, shader bytes, title paths or secrets are included. ## Checklist - [x] One synthetic-title behavior: XUser and XGameSave representative contracts. - [x] Positive values, no E_NOTIMPL for those calls, and XPackage/XGame negative controls. - [x] Fixture-only DLL, explicit load path and unchanged preflight refusal. - [x] No game files, dumps, logs or secrets. - [x] Public GDK provenance and named async limitation. - [x] AI-assisted (Codex).
upstream-sync closed this pull request 2026-11-24 06:46:07 +00:00
R0Y00 commented 2026-11-24 06:46:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:25:02Z.

Review: CHANGES_REQUESTED


Windows Release passed all three existing XGameRuntime tests. A second source-built check found two data lifetime problems:

  • Create slot-a, commit a player blob, then create another handle for slot-a on the same provider. The first handle reads the blob with S_OK and count 1. The second handle, and a handle opened after closing both, return 0x80070490 and count 0. The published CreateContainer operation also opens an existing named container. Keep process-local storage keyed by provider scope and container name, independently of open handles. Microsoft CreateContainer reference
  • Keep the original update while closing its container and creating a different container, slot-b, in the reused slot. Submitting the old update returns S_OK and writes the pending blob into slot-b. Bind each update to its intended container identity for its entire lifetime, or reject it after parent close. Add a control that proves slot-b remains unchanged.

Please add those cases, plus independent names on one provider. The fixture can remain in memory, with an explicit scope for provider identity.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6031718392 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1069#pullrequestreview-6031718392). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T00:25:02Z. **Review:** CHANGES_REQUESTED --- Windows Release passed all three existing XGameRuntime tests. A second source-built check found two data lifetime problems: - Create slot-a, commit a player blob, then create another handle for slot-a on the same provider. The first handle reads the blob with S_OK and count 1. The second handle, and a handle opened after closing both, return 0x80070490 and count 0. The published CreateContainer operation also opens an existing named container. Keep process-local storage keyed by provider scope and container name, independently of open handles. [Microsoft CreateContainer reference](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesave/functions/xgamesavecreatecontainer) - Keep the original update while closing its container and creating a different container, slot-b, in the reused slot. Submitting the old update returns S_OK and writes the pending blob into slot-b. Bind each update to its intended container identity for its entire lifetime, or reject it after parent close. Add a control that proves slot-b remains unchanged. Please add those cases, plus independent names on one provider. The fixture can remain in memory, with an explicit scope for provider identity.
R0Y00 commented 2026-11-24 06:46:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:50:17Z.

Review: APPROVED


The revised storage separates named data from open handles and expires updates on container close. I reran the three Windows Release fixture tests on 7182b787. Opening the same name and reopening it both find the committed data, while a stale update returns E_GS_HANDLE_EXPIRED and leaves the other container unchanged. The strict preflight control also still refuses the unimplemented async path. This clears my previous review on the fixture scope.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6031927667 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1069#pullrequestreview-6031927667). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T00:50:17Z. **Review:** APPROVED --- The revised storage separates named data from open handles and expires updates on container close. I reran the three Windows Release fixture tests on 7182b787. Opening the same name and reopening it both find the committed data, while a stale update returns E_GS_HANDLE_EXPIRED and leaves the other container unchanged. The strict preflight control also still refuses the unimplemented async path. This clears my previous review on the fixture scope.
lambirou commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T00:40:15Z.


Fixed in 7182b78. Container data is now a provider-scoped store keyed by container name, independent of open handles: a second handle and a reopened handle both read the original blob, and slot-a/slot-b stay isolated on one provider. Updates bind to the parent container handle id, provider scope and store id; after the parent closes and its slot is reused, XGameSaveSubmitUpdate returns E_GS_HANDLE_EXPIRED (0x8083000D) and slot-b is unchanged. Added those controls; 3/3 xgameruntime tests pass, table check passes, docs_links passes with 15 files/238 links.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118310190 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1069#issuecomment-7118310190). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T00:40:15Z. --- Fixed in 7182b78. Container data is now a provider-scoped store keyed by container name, independent of open handles: a second handle and a reopened handle both read the original blob, and slot-a/slot-b stay isolated on one provider. Updates bind to the parent container handle id, provider scope and store id; after the parent closes and its slot is reused, XGameSaveSubmitUpdate returns E_GS_HANDLE_EXPIRED (0x8083000D) and slot-b is unchanged. Added those controls; 3/3 xgameruntime tests pass, table check passes, docs_links passes with 15 files/238 links.
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
R0Y00/Xbox2Windows!1062
No description provided.