startup: implement XUserAddAsync and XUserAddResult in xgameruntime #2193

Merged
tedin7 merged 2 commits from upstream-pr/2201 into main 2026-11-25 05:39:38 +00:00
tedin7 commented 2026-11-25 04:21:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:21:21Z.


Part of #1334

What this unblocks: startup code that signs in the default user through XUserAddAsync / XUserAddResult on a manual task queue can now complete in the xgameruntime stand-in instead of hitting E_NOTIMPL.

Builds on #2179 (manual queue and async slot table) and #2170 (completion-port contract). Public docs: https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xuseraddasync?view=gdk-2604

Contract:

  • Accepted options: AddDefaultUserSilently or AddDefaultUserAllowingUI, alone. Anything else (None, AllowGuests, combinations) returns E_NOTIMPL.
  • Queue: a live manual queue from XTaskQueueCreate. Null or foreign queues return E_NOTIMPL. A null block returns E_INVALIDARG. All refusals leave the block and capacity untouched.
  • XUserAddResult returns E_PENDING before XTaskQueueDispatch (without consuming), then S_OK with one valid XUserHandle, claimed once. Untracked block, second claim, or a game-save block: E_INVALIDARG.
  • No free user handle: E_OUTOFMEMORY, slot and block released.
  • The async slot table is shared with XGameSaveInitializeProviderAsync (kind-tagged); that path is refactored onto the same helpers with unchanged behavior.
  • XUserAddResult is a new table row; xgameruntime_table_check.py now requires both rows as implemented. The thunk/identity/PLS tests keep XUserAddAsync(None) as an E_NOTIMPL control; the thunk test no longer lists it as a stub.

New test: xgameruntime_user_async (both options, early vs. after-dispatch result, in-callback claim, null callback and in-flight reuse, option/queue/null refusals, wrong-kind result, close guard, user-table exhaustion and recovery).

Verification (Linux):

  • python3 -B tests/xgameruntime_table_check.py -> PASS
  • python3 -B tests/docs_links_check.py -> PASS
  • python3 -B tests/run_checks_parallel_check.py -> ok
  • mingw-w64 build of the shim and the xgameruntime test executables, run under Wine on Linux: xgameruntime_user_async, _gamesave_async, _identity, _thunks, _contracts, _pls_xpackage all PASS (not a Windows result).

Win2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP), commit 86939d7d, 3-slot pool:

  • python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2201 --force --regex "^xgameruntime_"
  • Debug ctest --preset dev -R "^xgameruntime_": 8/8 passed, 0 skipped.
  • Release ctest --preset release -R "^xgameruntime_": 8/8 passed, 0 skipped.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6597139939 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2201). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:21:21Z. --- Part of #1334 What this unblocks: startup code that signs in the default user through `XUserAddAsync` / `XUserAddResult` on a manual task queue can now complete in the xgameruntime stand-in instead of hitting `E_NOTIMPL`. Builds on #2179 (manual queue and async slot table) and #2170 (completion-port contract). Public docs: https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xuser/functions/xuseraddasync?view=gdk-2604 Contract: - Accepted options: `AddDefaultUserSilently` or `AddDefaultUserAllowingUI`, alone. Anything else (`None`, `AllowGuests`, combinations) returns `E_NOTIMPL`. - Queue: a live manual queue from `XTaskQueueCreate`. Null or foreign queues return `E_NOTIMPL`. A null block returns `E_INVALIDARG`. All refusals leave the block and capacity untouched. - `XUserAddResult` returns `E_PENDING` before `XTaskQueueDispatch` (without consuming), then `S_OK` with one valid `XUserHandle`, claimed once. Untracked block, second claim, or a game-save block: `E_INVALIDARG`. - No free user handle: `E_OUTOFMEMORY`, slot and block released. - The async slot table is shared with `XGameSaveInitializeProviderAsync` (kind-tagged); that path is refactored onto the same helpers with unchanged behavior. - `XUserAddResult` is a new table row; `xgameruntime_table_check.py` now requires both rows as implemented. The thunk/identity/PLS tests keep `XUserAddAsync(None)` as an `E_NOTIMPL` control; the thunk test no longer lists it as a stub. New test: `xgameruntime_user_async` (both options, early vs. after-dispatch result, in-callback claim, null callback and in-flight reuse, option/queue/null refusals, wrong-kind result, close guard, user-table exhaustion and recovery). Verification (Linux): - `python3 -B tests/xgameruntime_table_check.py` -> PASS - `python3 -B tests/docs_links_check.py` -> PASS - `python3 -B tests/run_checks_parallel_check.py` -> ok - mingw-w64 build of the shim and the xgameruntime test executables, run under Wine on Linux: `xgameruntime_user_async`, `_gamesave_async`, `_identity`, `_thunks`, `_contracts`, `_pls_xpackage` all PASS (not a Windows result). Win2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP), commit 86939d7d, 3-slot pool: - `python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2201 --force --regex "^xgameruntime_"` - Debug `ctest --preset dev -R "^xgameruntime_"`: 8/8 passed, 0 skipped. - Release `ctest --preset release -R "^xgameruntime_"`: 8/8 passed, 0 skipped. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 05:04:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T04:50:09Z.

Review: COMMENTED


The default-user options and refusal cases fit the synthetic-user scope. This shares the async table with #2200. Please keep this candidate on hold until the two status queries distinguish operation completion from callback dispatch and the combined fixture can verify the user-handle result size. One useful cross-kind control is to complete save and user-add blocks on one manual queue, observe their separate status/size before dispatch, then claim each typed Result exactly once after dispatch. The existing unsupported options and queue refusals should still leave both blocks untouched.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052018552 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2201#pullrequestreview-6052018552). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T04:50:09Z. **Review:** COMMENTED --- The default-user options and refusal cases fit the synthetic-user scope. This shares the async table with #2200. Please keep this candidate on hold until the two status queries distinguish operation completion from callback dispatch and the combined fixture can verify the user-handle result size. One useful cross-kind control is to complete save and user-add blocks on one manual queue, observe their separate status/size before dispatch, then claim each typed Result exactly once after dispatch. The existing unsupported options and queue refusals should still leave both blocks untouched.
chatgpt-codex-connector[bot commented 2026-11-25 05:04:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T04:30:57Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T04:34:21.024994Z 86939d7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152912414 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2201#issuecomment-7152912414). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T04:30:57Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"86939d7dc9495e72754b41efc9073f8585b53c95","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T04:34:21.024994Z">2026-11-25T04:34:21.024994Z</relative-time> | `86939d7` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-25 06:01:25 +00:00
R0Y00 commented 2026-11-25 06:01:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T05:35:59Z.

Review: APPROVED


Re-reviewed the current author implementation and restored the two additional controls on 769f509a. One Manual/Manual queue carries a user-add block and a save-provider block at the same time. Both status/size queries succeed before dispatch. The callbacks are ordered, each typed Result rejects the other block, and each handle can be claimed once. Strict package preflight still refuses the remaining unimplemented package-mount import. Windows Release xgameruntime suite passed 9/9 with zero skips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052365370 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2201#pullrequestreview-6052365370). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T05:35:59Z. **Review:** APPROVED --- Re-reviewed the current author implementation and restored the two additional controls on 769f509a. One Manual/Manual queue carries a user-add block and a save-provider block at the same time. Both status/size queries succeed before dispatch. The callbacks are ordered, each typed Result rejects the other block, and each handle can be claimed once. Strict package preflight still refuses the remaining unimplemented package-mount import. Windows Release xgameruntime suite passed 9/9 with zero skips.
tedin7 commented 2026-11-25 06:01:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:31:18Z.


Rebased onto merged #2200 (XAsyncGetStatus/XAsyncGetResultSize); head a9ea7b62. Win2025 (MSVC 14.44, D3D12 WARP) python3 x2w_pipe.py win2025 2201 --force --regex "^xgameruntime_": dev 9/9 and release 9/9 passed, zero skips.
AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153854579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2201#issuecomment-7153854579). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:31:18Z. --- Rebased onto merged #2200 (`XAsyncGetStatus`/`XAsyncGetResultSize`); head `a9ea7b62`. Win2025 (MSVC 14.44, D3D12 WARP) `python3 x2w_pipe.py win2025 2201 --force --regex "^xgameruntime_"`: dev 9/9 and release 9/9 passed, zero skips. AI-assisted; commands listed were executed locally.
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!2193
No description provided.