Tests: pin XSTS sign-request header layout and offline token contract #2486

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

@⁠amazedturnip on GitHub · 2026-11-25 20:08 UTC · original
amazedturnip:xcl/tests-xsign-header-layout-and-offline-token-cont-035747 → main · +141 −0 · 1 files · 1 commits · open

Adds a black-box integration contract suite for crates/xcl/src/hle/xgameruntime/xsign.rs so the XSTS v1 offline-signing path is pinned outside the module: offline_token starts with 'XBL3.0 x=xcl;local-' with a 16-hex-char suffix round-tripping config().user_id; current_filetime is plausible now (>= ~2020, within 1h of now, non-decreasing); base64_encode matches RFC 4648 vectors and decodes round-trip; sign_request_at with a fixed filetime yields a parseable 76-byte [version u32 BE == 1][filetime u64 BE][64-byte sig] header; sign_request returns Ok with a same-shape header within 1h of now. Test-only, 129 lines, no source changes.

What is in it

  • crates/xcl/tests/xsign_contract.rs: black-box contract suite for xcl::hle::xgameruntime::xsign — offline_token() starts with XBL3.0 x=xcl;local- and ends with 16 hex chars that round-trip config().user_id; current_filetime() is a plausible now (>= ~2020, within 1h of now, non-decreasing); base64_encode matches RFC 4648 vectors and round-trips; sign_request_at with a fixed filetime yields a base64 header whose decoded bytes are exactly [version u32 BE == 1][filetime u64 BE == fixed][64-byte signature] (76 bytes); sign_request returns Ok and decodes with version == 1 and 96-byte... wait, 76-byte payload and filetime within 1h of now.

Tested

  • Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build
  • AMD (AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64), XCL_ADAPTER=radeon): cargo test --workspace -- --test-threads=1 — 1297 passed, 1 failed, 26 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1)
  • Verification / negative control: Negative control: temporarily removed the 'x=xcl;' prefix from the token format in xsign.rs, re-ran the targeted test: offline_token_has_xbl3_xcl_prefix_and_hex_user_id FAILED ("token XBL3.0 x=local-0009000000000001 must start with XBL3.0 x=xcl;local-"), 4 other tests passed; then git checkout -- crates/xcl/src/hle/xgameruntime/xsign.rs to restore.

Not tested

  • signing path through real XUserGetTokenAndSignature* thunks end-to-end (requires a running title/host)
  • NVIDIA wave32 GPU (not run in this pass; verified on AMD Radeon native wave64)

AI use

  • Local AI (thinkingmachines_inkling-2-mini) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64).
**@⁠amazedturnip** on GitHub · 2026-11-25 20:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486) `amazedturnip:xcl/tests-xsign-header-layout-and-offline-token-cont-035747` → `main` · +141 −0 · 1 files · 1 commits · open Adds a black-box integration contract suite for crates/xcl/src/hle/xgameruntime/xsign.rs so the XSTS v1 offline-signing path is pinned outside the module: offline_token starts with 'XBL3.0 x=xcl;local-' with a 16-hex-char suffix round-tripping config().user_id; current_filetime is plausible now (>= ~2020, within 1h of now, non-decreasing); base64_encode matches RFC 4648 vectors and decodes round-trip; sign_request_at with a fixed filetime yields a parseable 76-byte [version u32 BE == 1][filetime u64 BE][64-byte sig] header; sign_request returns Ok with a same-shape header within 1h of now. Test-only, 129 lines, no source changes. **What is in it** - `crates/xcl/tests/xsign_contract.rs`: black-box contract suite for `xcl::hle::xgameruntime::xsign` — `offline_token()` starts with `XBL3.0 x=xcl;local-` and ends with 16 hex chars that round-trip `config().user_id`; `current_filetime()` is a plausible now (>= ~2020, within 1h of now, non-decreasing); `base64_encode` matches RFC 4648 vectors and round-trips; `sign_request_at` with a fixed filetime yields a base64 header whose decoded bytes are exactly [version u32 BE == 1][filetime u64 BE == fixed][64-byte signature] (76 bytes); `sign_request` returns Ok and decodes with version == 1 and 96-byte... wait, 76-byte payload and filetime within 1h of now. **Tested** - Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build - AMD (`AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64)`, `XCL_ADAPTER=radeon`): `cargo test --workspace -- --test-threads=1` — 1297 passed, 1 failed, 26 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1) - Verification / negative control: Negative control: temporarily removed the 'x=xcl;' prefix from the token format in xsign.rs, re-ran the targeted test: `offline_token_has_xbl3_xcl_prefix_and_hex_user_id` FAILED ("token XBL3.0 x=local-0009000000000001 must start with XBL3.0 x=xcl;local-"), 4 other tests passed; then `git checkout -- crates/xcl/src/hle/xgameruntime/xsign.rs` to restore. **Not tested** - signing path through real XUserGetTokenAndSignature* thunks end-to-end (requires a running title/host) - NVIDIA wave32 GPU (not run in this pass; verified on AMD Radeon native wave64) **AI use** - Local AI (thinkingmachines_inkling-2-mini) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64).
Adds crates/xcl/tests/xsign_contract.rs, a black-box contract suite for xsign.rs: offline_token starts 'XBL3.0 x=xcl;local-' with a 16-char hex suffix matching config().user_id; current_filetime is a plausible now (and non-decreasing); base64_encode matches RFC 4648 vectors and round-trips; sign_request_at writes a parseable 76-byte XSTS v1 header ([version u32 BE == 1][filetime u64 BE == fixed][64-byte sig]); sign_request stamps a same-shape header within an hour of now. None of these contracts were guarded by any integration test outside the module, so a silent regression in the offline-signing path would not be caught.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:53 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 20:23 UTC · original

On head eaf578bf2b6cd6635c232376100d609b4f85a833, the two FILETIME checks use 3_600_000_000_000_000 ticks as a claimed one-hour tolerance. FILETIME has 10,000,000 ticks per second, so that value is 100,000 hours (about 11.4 years). The test would accept a signing timestamp years away from now, missing the regression it intends to catch.

One hour is 3_600 * 10_000_000 = 36_000_000_000 ticks. Please use that value (ideally a shared constant) in both current_filetime_is_a_plausible_now_claps_2024_plus and sign_request_returns_ok_and_has_xsts_v1_shape, and check that a timestamp more than an hour off fails the assertion.

AI use: OpenAI Codex (GPT-6; exact variant unavailable) reviewed the diff and verified the unit conversion; no tests were run for this review.

**@⁠luckyteagirl** on GitHub · 2026-11-25 20:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7173607685) On head `eaf578bf2b6cd6635c232376100d609b4f85a833`, the two FILETIME checks use `3_600_000_000_000_000` ticks as a claimed one-hour tolerance. FILETIME has 10,000,000 ticks per second, so that value is 100,000 hours (about 11.4 years). The test would accept a signing timestamp years away from now, missing the regression it intends to catch. One hour is `3_600 * 10_000_000 = 36_000_000_000` ticks. Please use that value (ideally a shared constant) in both `current_filetime_is_a_plausible_now_claps_2024_plus` and `sign_request_returns_ok_and_has_xsts_v1_shape`, and check that a timestamp more than an hour off fails the assertion. AI use: OpenAI Codex (GPT-6; exact variant unavailable) reviewed the diff and verified the unit conversion; no tests were run for this review.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 20:52 UTC · original

One non-reproducing flake burst, otherwise clean. First cold-cache gpu_ suite run (parallel, --test-threads=2): 158 passed / 9 failed, i.e. the usual trio plus six tests that are green on main: gpu_console_textures_upload_every_mip_and_slice, gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels, copy_scratch_budget_counts_resources_until_gpu_completion, cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly, gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes, gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark.

  • Second full suite run, same head, cold cache: 164 passed / 3 failed (baseline trio only).
  • Solo run of gpu_console_textures_upload_every_mip_and_slice on this head: passed. Solo runs of all six on plain main: all passed.
    So: not a deterministic red, but every test in the burst touches upload/scratch/lifetime paths this PR changes (retry after lazy mip mapping failures, split scratch reuse). If anyone sees this family go red in a parallel CI job, this PR is the first suspect on the Wine lane.
**@⁠SlopTart** on GitHub · 2026-11-25 20:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7174295647) **One non-reproducing flake burst, otherwise clean.** First cold-cache `gpu_` suite run (parallel, `--test-threads=2`): `158 passed / 9 failed`, i.e. the usual trio plus six tests that are green on main: `gpu_console_textures_upload_every_mip_and_slice`, `gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels`, `copy_scratch_budget_counts_resources_until_gpu_completion`, `cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly`, `gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes`, `gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`. - Second full suite run, same head, cold cache: `164 passed / 3 failed` (baseline trio only). - Solo run of `gpu_console_textures_upload_every_mip_and_slice` on this head: passed. Solo runs of all six on plain main: all passed. So: not a deterministic red, but every test in the burst touches upload/scratch/lifetime paths this PR changes (retry after lazy mip mapping failures, split scratch reuse). If anyone sees this family go red in a parallel CI job, this PR is the first suspect on the Wine lane.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:53 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 20:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7174317181) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-25 21:37 UTC · original

Fixed: both FILETIME checks now use a shared ONE_HOUR_TICKS constant (36_000_000_000 ticks = 1 hour) instead of 3_600_000_000_000_000 (~11.4 years). Each test also now asserts that a timestamp more than an hour off (+1 tick past the bound, either side) fails the check. Test name/comment cleaned up (claps_2024_plus -> plausible_now_2024_plus, 'more than a day in the past' -> 'more than an hour in the past'). Verified locally: cargo test -p xcl --test xsign_contract passes 5/5.

**@⁠amazedturnip** on GitHub · 2026-11-25 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7175331671) Fixed: both FILETIME checks now use a shared ONE_HOUR_TICKS constant (36_000_000_000 ticks = 1 hour) instead of 3_600_000_000_000_000 (~11.4 years). Each test also now asserts that a timestamp more than an hour off (+1 tick past the bound, either side) fails the check. Test name/comment cleaned up (claps_2024_plus -> plausible_now_2024_plus, 'more than a day in the past' -> 'more than an hour in the past'). Verified locally: `cargo test -p xcl --test xsign_contract` passes 5/5.
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-25 20:30 UTC · original · edited 2026-11-25 22:07 UTC

Rerun on the new head 33ea27f: fixed on NVIDIA. With xsign::current_filetime set 1 day behind, current_filetime_is_plausible_now and sign_request_returns_ok_and_has_xsts_v1_shape now fail. 58 minutes behind, they pass.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, 33ea27f merged onto main e1d84b7 (clean) 1428 passed, 0 failed, 46 ignored; 25 SKIPPED lines
cargo test -p xcl --test xsign_contract, 3 runs 5 passed, 3 of 3
clock 1 day behind / 58 min behind (scratch) 2 fail / all pass

A clock 1 h + 1 tick behind still passes: the tests' own "now" is taken in whole seconds (as_secs()), so the bound is exact only to about a second. That is fine for what the tests check.


First run, on eaf578b: For the slack point above: on NVIDIA the tests passed as they were even with the clock 1 day or 5 years off. With 36_000_000_000 ticks they still passed on a correct clock and failed when it was 1 day off.

Tested: eaf578b (it is main 6d12f58 plus this commit). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 1428 passed, 0 failed, 46 ignored; 25 SKIPPED lines (no wave64, refused per-lane forms)
xsign::current_filetime set 1 day, then 5 years behind (scratch) all 5 tests pass both times
the slack changed to 36_000_000_000 in both tests (scratch), 3 runs 5 passed, 3 of 3
that slack with the clock 1 day behind current_filetime_is_a_plausible_now_claps_2024_plus and sign_request_returns_ok_and_has_xsts_v1_shape fail

Also in that test: its comment says "more than a day in the past" while the assert message says 1h, and the name says 2024_plus while the floor is 2020-09.

Not tested: a release build; the signing path through the XUserGetTokenAndSignature* thunks.

AI use: Claude Code (Claude Opus 5.5) ran the suite and the scratch changes, and wrote this report.

**@⁠fromthemoonx** on GitHub · 2026-11-25 20:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7173762249) · edited 2026-11-25 22:07 UTC **Rerun on the new head `33ea27f`: fixed on NVIDIA. With `xsign::current_filetime` set 1 day behind, `current_filetime_is_plausible_now` and `sign_request_returns_ok_and_has_xsts_v1_shape` now fail. 58 minutes behind, they pass.** | | result | |---|---| | `cargo test --workspace --no-fail-fast -- --test-threads=4`, `33ea27f` merged onto `main` `e1d84b7` (clean) | 1428 passed, 0 failed, 46 ignored; 25 `SKIPPED` lines | | `cargo test -p xcl --test xsign_contract`, 3 runs | 5 passed, 3 of 3 | | clock 1 day behind / 58 min behind (scratch) | 2 fail / all pass | A clock 1 h + 1 tick behind still passes: the tests' own "now" is taken in whole seconds (`as_secs()`), so the bound is exact only to about a second. That is fine for what the tests check. --- *First run, on `eaf578b`:* For the slack point above: on NVIDIA the tests passed as they were even with the clock 1 day or 5 years off. With `36_000_000_000` ticks they still passed on a correct clock and failed when it was 1 day off. **Tested:** `eaf578b` (it is `main` `6d12f58` plus this commit). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug. | | result | |---|---| | `cargo test --workspace --no-fail-fast -- --test-threads=4` | 1428 passed, 0 failed, 46 ignored; 25 `SKIPPED` lines (`no wave64`, refused per-lane forms) | | `xsign::current_filetime` set 1 day, then 5 years behind (scratch) | all 5 tests pass both times | | the slack changed to `36_000_000_000` in both tests (scratch), 3 runs | 5 passed, 3 of 3 | | that slack with the clock 1 day behind | `current_filetime_is_a_plausible_now_claps_2024_plus` and `sign_request_returns_ok_and_has_xsts_v1_shape` fail | Also in that test: its comment says "more than a day in the past" while the assert message says 1h, and the name says `2024_plus` while the floor is 2020-09. **Not tested:** a release build; the signing path through the `XUserGetTokenAndSignature*` thunks. **AI use:** Claude Code (Claude Opus 5.5) ran the suite and the scratch changes, and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:49 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2486#issuecomment-7180181084) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/2486/head:github-bot/gh-2486'
git switch 'github-bot/gh-2486'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2486'
git switch 'github-bot/gh-2486'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2486'
git switch 'github-bot/gh-2486'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2486'
git switch 'main'
git merge --squash 'github-bot/gh-2486'
git switch 'main'
git merge --ff-only 'github-bot/gh-2486'
git switch 'main'
git merge 'github-bot/gh-2486'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.