startup: implement XGameSaveInitializeProviderAsync and its result in xgameruntime #2171
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2179"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:00:45Z.
Part of #1334
What this unblocks: a title-like caller can start the game-save provider through
XGameSaveInitializeProviderAsyncon an explicit queue contract and claim it withXGameSaveInitializeProviderResultinstead of gettingE_NOTIMPL.What changed:
block.queue == nullptrcalls back once, inline, before the call returns. A manual queue made by the shim's ownXTaskQueueCreate(Manual/Manual) fires ZERO callbacks untilXTaskQueueDispatch(queue, completion port), which then runs exactly one. Any other non-null queue (or a non-manualXTaskQueueCreatemode) returnsE_NOTIMPLbefore the block or provider capacity is touched.XTaskQueueDispatchandXTaskQueueCloseHandleare new; closing a queue with a waiting callback is refused. Thread-pool and immediate queues are not modeled.XGameSaveInitializeProviderResulthands the provider over exactly once (second claim isE_INVALIDARG).E_ILLEGAL_STATE_CHANGE; exhausted provider storage returnsE_OUTOFMEMORYand consumes no async state.XAsyncGetStatus,XUserAddAsync,XPackageMountWithUiAsyncstayE_NOTIMPLstubs.xgameruntime_gamesave_asyncnow covers: manual queue with zero callbacks before dispatch, one callback that claims the provider after dispatch, an inline early-callback negative control, and an unsupported queue that leaves the block and all four provider slots untouched.xgameruntime_thunksandxgameruntime_table_check.pyupdated. Docs updated. This is a queue-contract fixture only, separate from the #870 startup trace.Verification:
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-fsyntax-onlyon the shim and both touched tests -> clean69132806, default 3-slot pool):python3 x2w_pipe.py win2025 2179 --targets xgameruntime_shim,xgameruntime_shim_check,xgameruntime_contracts_check,xgameruntime_pls_xpackage_check,xgameruntime_identity_check,xgameruntime_gamesave_async_check --regex "^xgameruntime_"-> dev 5/5 PASS, release 5/5 PASS (incl.xgameruntime_gamesave_async)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:32:57Z.
Review: CHANGES_REQUESTED
Windows Release passed the six registered xgameruntime checks at
69132806, but a source-built variation of the manual-queue case found a lost completion. Start on Manual/Manual, retrieve the completed provider before pumping, then dispatch. The result was S_OK with a provider, followed by dispatch=0, callbacks=0. Result clears the whole slot while its callback is still pending. Please preserve the queued completion if early result retrieval succeeds, or refuse early retrieval without deleting it in this intentionally restricted implementation. In either case test that one callback still dispatches, the provider is delivered at most once, and the second dispatch finds nothing. Closing or recycling a queue while a start is in flight also needs a lifetime check, since a reserved slot does not set callback_pending until after synchronous initialization returns.A null block queue selects the process task queue in the public API. It cannot be treated as an inline queue for real callers. For the first slice, refuse null before touching block or provider state unless the default is modeled, and keep an early-callback mutant in the test instead. XTaskQueueDispatch also has an observable timeout argument. Please exercise a finite wait and make its behavior explicit before exposing this as a general runtime implementation. XAsyncBlock queue contract · XTaskQueueDispatch
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:36:40Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
6913280656ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:09:42Z.
The save-provider result path is worth pursuing. The current inline callback still needs an explicit queue contract before this can cover an application caller. It ignores the supplied completion port, so a manual queue receives a callback on the caller's stack before it has been dispatched. That is exactly the distinction the source-built manual queue from #2170 demonstrates on the installed runtime.
Please reuse the existing async completion service where present, or narrow the first implementation to a queue configuration you can actually recognize and support. Exercise a manual queue with zero callbacks before completion-port dispatch, one callback that claims the provider after dispatch, and an early-callback negative control. If this slice returns unsupported for that queue, check that it leaves the block and provider capacity untouched. Keep the report separate from the actual #870 startup trace.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:27:20Z.
Thanks, this is addressed in
69132806.Queue contract: no queue calls back once, inline. A manual queue made by the shim's
XTaskQueueCreate(Manual/Manual) fires zero callbacks untilXTaskQueueDispatchon the completion port, which runs exactly one. Any other queue value returnsE_NOTIMPLbefore the block or provider capacity is touched. The shim has no other queue service to reuse, so it models only this manual queue, and thread-pool and immediate modes are out of scope.Tests in
xgameruntime_gamesave_async:E_NOTIMPL, no async state, and all four provider slots still freeThe report is a queue-contract fixture and stays separate from the #870 startup trace.
Win2025, default 3-slot pool, head
69132806:x2w_pipe.py win2025 2179 --targets xgameruntime_shim,xgameruntime_shim_check,xgameruntime_contracts_check,xgameruntime_pls_xpackage_check,xgameruntime_identity_check,xgameruntime_gamesave_async_check --regex "^xgameruntime_". Dev 5/5 passed, release 5/5 passed. Linux: table check, docs links and run_checks_parallel all pass.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:27:31Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
6913280ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:42:12Z.
Thanks, the lost completion reproduces and is fixed at
27d59718.Root cause and changes:
XGameSaveInitializeProviderResultcleared the whole slot, which also droppedcallback_pendingand the queue link. It now returnsE_PENDING(output cleared, nothing consumed) while the completion callback still waits forXTaskQueueDispatch. After the callback runs, the provider is delivered exactly once.XTaskQueueCloseHandlenow refuses (E_ILLEGAL_STATE_CHANGE) when any slot on the queue is reserved but not yet completed, or has a callback waiting. This covers the window beforecallback_pendingis set.XAsyncBlock.queueis refused withE_NOTIMPLbefore any block or provider state is touched. The inline-callback path is gone.XTaskQueueDispatchignores its timeout on purpose, because every start completes before it returns. This is documented in the source and indocs/experiments.md.Regression tests in
xgameruntime_gamesave_async:E_PENDINGwith a null provider and no callback. Close is refused, then one dispatch runs one callback, the second dispatch finds nothing, the result then returns the provider once and a repeat givesE_INVALIDARG.Not covered by a test: the in-flight close window itself, since the synchronous init cannot be paused from outside. It is covered by the close rule above.
Verification:
python3 -B tests/xgameruntime_table_check.py: PASSpython3 -B tests/docs_links_check.py: PASS (18 files, 404 links)x2w_pipe.py win2025 2179 --targets xgameruntime_shim,xgameruntime_shim_check,xgameruntime_contracts_check,xgameruntime_pls_xpackage_check,xgameruntime_identity_check,xgameruntime_gamesave_async_check,xgameruntime_preflight_exe --regex "^xgameruntime_": dev 7/7 and release 7/7 passed, includingxgameruntime_gamesave_async. (xgameruntime_preflight_exewas added to the target list becausexgameruntime_preflight_stub_refusedneeds it.)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:36:41Z.
Code review location:
docs/experiments.md; line 11184For a caller using a shim-created Manual/Manual queue,
XTaskQueueCreatenow succeeds and the provider callback remains pending until completion-port dispatch. This section instead calls queue creation a stub and dispatch unmodeled, while the preceding sentence promises an inline callback for every operation. These reproduction notes therefore omit the pump required by the new fixture and describe a different completion contract; update the public capability documentation as required byAGENTS.md.AGENTS.md reference: AGENTS.md:L236-L237
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:36:41Z.
Code review location:
src/xgameruntime_shim.cpp; line 934When a manual-queue operation is initialized successfully and its result is claimed before the completion port is pumped, resetting the entire slot also deletes
callback_pendingand the queue/block association.task_queue_dispatchthen finds no entry, returns false, and never calls the registered completion routine, despite the operation having promised one deferred callback. Preserve the pending notification independently of the result claim, and only recycle the slot after both are finished.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:36:41Z.
Code review location:
src/xgameruntime_shim.cpp; line 997If one thread closes the queue while another is in
game_save_initialize_provider_asyncbetween reserving the async slot and publishingcallback_pending, this condition lets the close mark the queue dead. The initializer subsequently returnsS_OKwith a pending callback, but dispatch rejects the closed queue, so the callback is stranded or can be picked up by a later queue reusing that slot. Count the in-flight reservation as a queue user before dropping the initialization lock, rather than protecting only callbacks that are already pending.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T04:07:36Z.
Review: APPROVED
The exact revised source passed all six Windows Release runtime checks and 20 repeated async runs. The shim now refuses the unmodeled default queue, preserves the result across an early E_PENDING, and waits for work or a finite deadline as requested. A poll-only mutation failed both the empty-port expiry and delayed-completion assertions. This remains a source-built Manual/Manual result with no new application startup claim.