Skip to content

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

Open
amazedturnip wants to merge 1 commit into
xcl-dev:mainfrom
amazedturnip:xcl/tests-xsign-header-layout-and-offline-token-cont-035747
Open

amazedturnip wants to merge 1 commit into
xcl-dev:mainfrom
amazedturnip:xcl/tests-xsign-header-layout-and-offline-token-cont-035747

Conversation

@amazedturnip

Copy link
Copy Markdown
Contributor

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

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

@luckyteagirl

Copy link
Copy Markdown
Contributor

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.

@fromthemoonx

fromthemoonx commented Nov 25, 2026 •

Copy link
Copy Markdown

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.

@SlopTart

Copy link
Copy Markdown

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
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.
@amazedturnip

Copy link
Copy Markdown
Contributor Author

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
amazedturnip force-pushed the xcl/tests-xsign-header-layout-and-offline-token-cont-035747 branch from eaf578b to 33ea27f Compare November 25, 2026 21:37
@DavidM1911

Copy link
Copy Markdown
Contributor

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

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2486 at head 33ea27fbb2bb40ef4ee1227e6e9d9064440d893d (1 commit; exact parent & merge-base: 6d12f58a229bc73889878a448c64dc3af25eeba0, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (33ea27fb)

Command Result
cargo test --release -p xcl --test xsign_contract -- --nocapture (3 consecutive runs) 5 passed; 0 failed; 0 ignored; 0 filtered out × 3 (0.00s × 3, 0 skipped: base64_encode_matches_rfc4648_and_decodes_roundtrip, current_filetime_is_plausible_now, offline_token_has_xbl3_xcl_prefix_and_hex_user_id, sign_request_at_produces_parseable_xsts_v1_header, sign_request_returns_ok_and_has_xsts_v1_shape)
cargo test --release -p xcl --lib xsign (3 consecutive runs) 4 passed; 0 failed; 0 ignored; 1320 filtered out × 3 (0.00s × 3, 0 skipped)
cargo build --release -p xcl Clean build (0.07s incremental after --test/--lib build, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (6d12f58a229bc73889878a448c64dc3af25eeba0, cached baseline on the same machine):

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1606 (PresentX 1606)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14004 MB

PR #2486 (33ea27fbb2bb40ef4ee1227e6e9d9064440d893d):

xcl-smoke v1
commit: 33ea27fbb2bb40ef4ee1227e6e9d9064440d893d
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14023 MB

Runtime log observations (xcl.log)

  • 9220 log lines, 0 [ERROR] / device-removal / panic lines (dxil_cache: 460 hits, 0 misses, 0 compilation failures; 228 background pipelines, 0 failures).
  • Final draw/memory telemetry in log: 19519 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14022 MB committed by the process; video memory 6115 MB local, 4683 MB non-local.

Limits of coverage

  • This PR is test-only (crates/xcl/tests/xsign_contract.rs, +141/-0, 0 production-code changes); all 5 new black-box XSTS signing/offline-token contract tests and all 4 existing hle::xgameruntime::xsign::tests unit tests passed 3/3 in --release on Windows 11.
  • The 60 s retail smoke confirms non-regression of the unchanged runtime binary at this commit (single-run frame/commit delta vs. cached parent reflects normal startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 33ea27f

@github-actions github-actions Bot added area:tests Unit, integration, e2e tests, or testtitle needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: fa20459
head: 33ea27f
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2613 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa20459: 2608 passed, 0 failed, 49 ignored. (A first run of this tree had no lib counts: the lib test binary was ended by the uma_driver fail-stop that #3187 addresses; this is the rerun.)
review: no blocking finding; tests only, all hunks read with the project's rules in mind. The token in the test is a synthetic local one and the key is the throw-away key main already makes; nothing touches the network (the URLs are plain strings) and nothing serves to get around a protection. The point from the thread about the time slack is fixed. Minor: it largely repeats unit tests the module already has and adds one more integration-test binary to link.
performance: none (tests only; a little build time).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Nov 29, 2026
@saintwolf

saintwolf commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

releasing: my merge-check claim for head 33ea27f (someone else took this slot after my claim)

@relativespace2K

relativespace2K commented Nov 30, 2026 •

Copy link
Copy Markdown

merge-check
base: 53e85fb
head: 33ea27f
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2793 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in --test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base 53e85fb alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; its five new tests passed. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.
review: no blocking finding; a new test file, crates/xcl/tests/xsign_contract.rs, every line read. It pins the offline token prefix and that its 16 hex characters round-trip state::config().user_id (read from the config, not hard-coded), the FILETIME's shape and that two readings do not go backwards, RFC 4648 base64 through the public base64_encode with an independent decoder written in the test (so it does not merely echo the module's own), and the XSTS v1 header: 76 bytes, version 1 big-endian, the FILETIME big-endian, and sign_request_at reproducing the FILETIME it was handed. Asserting that the 64-byte signature is not all zeros rather than a fixed byte string is the right trade here: it catches a signing path that returns nothing without freezing a key into the test. One note, not blocking: the 76-byte shape pins the signature to raw ECDSA P-256, so a change of curve in xsign would fail this test before the module, which is the contract it is meant to state. No duplicate: nothing else tests xsign at this level.
performance: none: tests only.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash. The first full run aborted in -p xcl --lib with 0xc0000005 (STATUS_ACCESS_VIOLATION) before that target printed a result, which is the intermittent abort under parallel scheduling (#1978); the lib target then passed twice on its own and the numbers above are the clean rerun.

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 33ea27f

No open PR adds these tests. Part of it repeats main's own unit tests in hle/xgameruntime/xsign.rs: base64_encode_matches_rfc4648_and_decodes_roundtrip uses the same RFC 4648 vectors as base64_matches_rfc4648_vectors, and sign_request_at_produces_parseable_xsts_v1_header is a weaker copy of signature_header_verifies_with_ephemeral_p256_key, which also verifies the signature. The !within_one_hour(...) asserts only test the test's own helper. What is new: the format of offline_token, the range of current_filetime, and the shape of sign_request.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tests Unit, integration, e2e tests, or testtitle off-goal Does not bear on the current goal (world loading); waits until it is reached ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants