feat: finish the xgameruntime port to Rust (XPackage, XAsync race, store handles) #285

Closed
LooperSalty wants to merge 16 commits from upstream-pr/285 into rust/full
LooperSalty commented 2026-11-26 00:44:40 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T00:44:40Z.


Change

Finishes porting runtime/xgameruntime (C++) to crates/anyxboxx-xgameruntime, written by OpenAI Codex at the maintainer's request, in small commits on top of rust/full 0d5dfa16:

  • XPackage: identity and status queries, installation monitors, asynchronous installation, mounts, local package enumeration, availability and locale queries, installation subscriptions; install order handled; uninstall (not implemented) refused with E_NOTIMPL and logged (rule 3).
  • XAsync: the completion status is published before the call is released (fixes an intermittent race seen in the GDK tests).
  • XStore: closed query handles are rejected.
  • Rust runtime parity checks restored; docs/rust-full-status.md and docs/fr/rust-full-status.md updated together.

Verification (local, Windows)

  • cargo build --release --workspace, cargo test --release --workspace, clippy (-D warnings), fmt, ruff: pass.
  • GDK / runtime pytest against the Rust DLL: 89 targeted tests pass.
  • No game or game file was run or used.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL4bPjrVJiDKC8BDYfz

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6616874506 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T00:44:40Z. --- ## Change Finishes porting `runtime/xgameruntime` (C++) to `crates/anyxboxx-xgameruntime`, written by OpenAI Codex at the maintainer's request, in small commits on top of `rust/full` 0d5dfa16: - XPackage: identity and status queries, installation monitors, asynchronous installation, mounts, local package enumeration, availability and locale queries, installation subscriptions; install order handled; uninstall (not implemented) refused with `E_NOTIMPL` and logged (rule 3). - XAsync: the completion status is published before the call is released (fixes an intermittent race seen in the GDK tests). - XStore: closed query handles are rejected. - Rust runtime parity checks restored; `docs/rust-full-status.md` and `docs/fr/rust-full-status.md` updated together. ## Verification (local, Windows) - `cargo build --release --workspace`, `cargo test --release --workspace`, clippy (`-D warnings`), fmt, ruff: pass. - GDK / runtime pytest against the Rust DLL: 89 targeted tests pass. - No game or game file was run or used. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL4bPjrVJiDKC8BDYfz
chatgpt-codex-connector[bot] commented 2026-11-26 00:44:49 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T00:44:49Z.


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-26T00:46:54.640235Z e753e9a PR opened
ℹ️ 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:LooperSalty/AnyXboxX:comment:7179072365 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285#issuecomment-7179072365). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T00:44:49Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e753e9a52aacee09bf218d10fe3a15bcf4ac6539","has_any_findings":true,"has_unresolved_findings":true,"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-26T00:46:54.640235Z">2026-11-26T00:46:54.640235Z</relative-time> | `e753e9a` | PR opened | <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>
chatgpt-codex-connector[bot] commented 2026-11-26 00:46:52 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T00:46:52Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e753e9a52a

ℹ️ 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".

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".

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review:6067039411 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285#pullrequestreview-6067039411). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T00:46:52Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `e753e9a52a` <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". 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". </details>
chatgpt-codex-connector[bot] commented 2026-11-26 00:46:52 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T00:46:52Z.

Code review location: third_party/victory/crates/victory-hle/src/modules/xasync.rs; line 618

@@ -603,11 +610,21 @@ pub fn XAsyncComplete(block: *mut AsyncBlock, result: HRESULT, required_size: us
     // SAFETY: a block in flight is valid.
     let (handle, routine) = unsafe { ((*block).queue, (*block).callback) };
     let (status, size) = words(block);
-    if result < 0 || required_size == 0 {
-        release(block);
+    let release_on_completion = result < 0 || required_size == 0;
+    if release_on_completion {
+        // Keep the call discoverable while cleanup runs: a waiting GetStatus must
+        // not observe a missing call with its status still E_PENDING.
+        call.cleaning.store(true, Ordering::Release);
+        call.provider(OP_CLEANUP, block, 0, std::ptr::null_mut());

P1 Badge Prevent provider dispatch once cleanup starts

If an operation is canceled before its queued work runs, keeping it in CALLS during cleanup now allows XAsyncSchedule's work callback to find it and invoke OP_DO_WORK after OP_CLEANUP has started freeing its context. For example, save_async::provider frees its boxed Completion during cleanup, while OP_DO_WORK dereferences that same pointer. Previously, removal before cleanup caused a work callback arriving in this interval to return without invoking the provider. The new cleaning flag only guards release, not work or cancellation dispatch, so this introduces a use-after-free window. Keep status waiters able to discover the call without allowing further provider dispatch during cleanup.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4702622189 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285#discussion_r4702622189). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T00:46:52Z. **Code review location:** `third_party/victory/crates/victory-hle/src/modules/xasync.rs`; line 618 ~~~~diff @@ -603,11 +610,21 @@ pub fn XAsyncComplete(block: *mut AsyncBlock, result: HRESULT, required_size: us // SAFETY: a block in flight is valid. let (handle, routine) = unsafe { ((*block).queue, (*block).callback) }; let (status, size) = words(block); - if result < 0 || required_size == 0 { - release(block); + let release_on_completion = result < 0 || required_size == 0; + if release_on_completion { + // Keep the call discoverable while cleanup runs: a waiting GetStatus must + // not observe a missing call with its status still E_PENDING. + call.cleaning.store(true, Ordering::Release); + call.provider(OP_CLEANUP, block, 0, std::ptr::null_mut()); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Prevent provider dispatch once cleanup starts** If an operation is canceled before its queued work runs, keeping it in `CALLS` during cleanup now allows `XAsyncSchedule`'s work callback to find it and invoke `OP_DO_WORK` after `OP_CLEANUP` has started freeing its context. For example, `save_async::provider` frees its boxed `Completion` during cleanup, while `OP_DO_WORK` dereferences that same pointer. Previously, removal before cleanup caused a work callback arriving in this interval to return without invoking the provider. The new `cleaning` flag only guards `release`, not work or cancellation dispatch, so this introduces a use-after-free window. Keep status waiters able to discover the call without allowing further provider dispatch during cleanup. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 00:46:52 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T00:46:52Z.

Code review location: tests/test_rust_dlls.py; line 26

@@ -20,6 +20,11 @@
 RUST_RELEASE = REPO / "target" / "release"
 # DLL name in the runtime folder → (Rust cdylib in target/release, pytest files of the C++ DLL).
 PORTED = {
+    "xgameruntime.dll": (
+        "xgameruntime.dll",
+        [str(p.relative_to(REPO)) for pattern in ("tests/test_gdk_*.py", "tests/test_runtime_*.py")
+         for p in sorted(REPO.glob(pattern))] + ["tests/test_native_services.py"],

P2 Badge Allow expected optional-dependency skips in the parity run

On Windows machines without the system GDK runtime, the newly selected test_runtime_cpp.py intentionally skips test_unknown_interface_delegated_to_windows_fails_cleanly; test_native_services.py likewise skips cases when GameInput is unavailable. However, this wrapper asserts that the subprocess summary contains no skipped, so those supported environments fail the Rust parity check even when every runnable test passes. Account for these expected skips or select only tests whose prerequisites the parity runner guarantees.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4702622194 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285#discussion_r4702622194). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T00:46:52Z. **Code review location:** `tests/test_rust_dlls.py`; line 26 ~~~~diff @@ -20,6 +20,11 @@ RUST_RELEASE = REPO / "target" / "release" # DLL name in the runtime folder → (Rust cdylib in target/release, pytest files of the C++ DLL). PORTED = { + "xgameruntime.dll": ( + "xgameruntime.dll", + [str(p.relative_to(REPO)) for pattern in ("tests/test_gdk_*.py", "tests/test_runtime_*.py") + for p in sorted(REPO.glob(pattern))] + ["tests/test_native_services.py"], ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Allow expected optional-dependency skips in the parity run** On Windows machines without the system GDK runtime, the newly selected `test_runtime_cpp.py` intentionally skips `test_unknown_interface_delegated_to_windows_fails_cleanly`; `test_native_services.py` likewise skips cases when GameInput is unavailable. However, this wrapper asserts that the subprocess summary contains no `skipped`, so those supported environments fail the Rust parity check even when every runnable test passes. Account for these expected skips or select only tests whose prerequisites the parity runner guarantees. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
LooperSalty commented 2026-11-26 11:46:36 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T11:46:36Z.


Merged into main through #351 (rust/full into main), which contains every commit of this PR.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7191151313 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/285#issuecomment-7191151313). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T11:46:36Z. --- Merged into main through #351 (rust/full into main), which contains every commit of this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

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
LooperSalty/AnyXboxX!285
No description provided.