stream-v0.1.0: the GameStream client (sans-I/O), interop unverified #3

Closed
mnovak wants to merge 0 commits from feature/client into main
Owner

The first DomiStream release for Arena Domi Play remotely Day 1: a pure, sans-I/O GameStream client written from the Wolf protocol docs and the approved permissive sources (stock ENet, tokio-enet, fec-rs), clean room (docs/CLEAN_ROOM.md).

  • pairing (4-phase PIN exchange, client cert), serverinfo / app list / launch, RTSP client + framer + SDP, ENet 1.3-compatible peer, control channel (AES-GCM, replay refusal), input and gamepad messages, RTP + Reed-Solomon FEC, video depacketizer with FEC recovery, Opus audio depacketizer (4 + 2 FEC).
  • docs: PROTOCOL.md (facts per source, UNKNOWN U1-U29), CLEAN_ROOM.md (source log), MUTATION.md, HANDOVER.md, LAB_CAPTURE.md (not run).
  • tools/lab-relay (never run), tools/vectors (OpenSSL / hashlib / .NET test vectors), tools/mutation.

Evidence

  • Tests first: QA wrote 240 tests against Unimplemented stubs, then the code. 242/242 pass (lead re-ran the suite: 242 passed, 0 failed).
  • Mutation pass: 24 of 24 reintroduced bugs caught (caps, lying lengths, ENet wrap, replay, nonce direction, GCM tag, FEC index, trusted recovered headers, audio parity keying, pairing step skip, bad signature, Instant::now, getrandom).
  • Fuzz: 25 targets x 60 s, 0 crashes; pairing_session 600 s, 574,761 runs, 0 crashes.
  • clippy -D warnings, fmt, rustdoc -D warnings clean; getrandom absent from the tree (rsa / x509-cert without default features, own DER writer for the client cert).

Self-review (critical)

  • Interop is unverified: it has never talked to a real Sunshine (Mark: no lab capture). Ten blocking unknowns (U1, U2, U4-U10, U17) are settled live on Day 1; a stream-v0.1.x patch is expected. README and HANDOVER say so in the first lines.
  • Where the docs were silent, the Wolf-documented behaviour is implemented and kept easy to change; each such spot names its UNKNOWN.
  • Test keys in tests/fixtures are test-only, named so, generated by tools/vectors; no real host key anywhere.
  • The audio FEC waits for the jitter budget before rebuilding, so a late packet comes out as sent (PROTOCOL.md 6.4 note).
  • Bugs the tests found during implementation: audio shard lifetime, early audio rebuild, an FEC budget overflow at k+m=255, ENet ping deadline while data is only queued.
  • No AI attribution in any commit.
The first DomiStream release for Arena Domi Play remotely Day 1: a pure, sans-I/O GameStream client written from the Wolf protocol docs and the approved permissive sources (stock ENet, tokio-enet, fec-rs), clean room (docs/CLEAN_ROOM.md). - pairing (4-phase PIN exchange, client cert), serverinfo / app list / launch, RTSP client + framer + SDP, ENet 1.3-compatible peer, control channel (AES-GCM, replay refusal), input and gamepad messages, RTP + Reed-Solomon FEC, video depacketizer with FEC recovery, Opus audio depacketizer (4 + 2 FEC). - docs: PROTOCOL.md (facts per source, UNKNOWN U1-U29), CLEAN_ROOM.md (source log), MUTATION.md, HANDOVER.md, LAB_CAPTURE.md (not run). - tools/lab-relay (never run), tools/vectors (OpenSSL / hashlib / .NET test vectors), tools/mutation. ## Evidence - Tests first: QA wrote 240 tests against Unimplemented stubs, then the code. 242/242 pass (lead re-ran the suite: 242 passed, 0 failed). - Mutation pass: 24 of 24 reintroduced bugs caught (caps, lying lengths, ENet wrap, replay, nonce direction, GCM tag, FEC index, trusted recovered headers, audio parity keying, pairing step skip, bad signature, Instant::now, getrandom). - Fuzz: 25 targets x 60 s, 0 crashes; pairing_session 600 s, 574,761 runs, 0 crashes. - clippy -D warnings, fmt, rustdoc -D warnings clean; getrandom absent from the tree (rsa / x509-cert without default features, own DER writer for the client cert). ## Self-review (critical) - **Interop is unverified**: it has never talked to a real Sunshine (Mark: no lab capture). Ten blocking unknowns (U1, U2, U4-U10, U17) are settled live on Day 1; a stream-v0.1.x patch is expected. README and HANDOVER say so in the first lines. - Where the docs were silent, the Wolf-documented behaviour is implemented and kept easy to change; each such spot names its UNKNOWN. - Test keys in tests/fixtures are test-only, named so, generated by tools/vectors; no real host key anywhere. - The audio FEC waits for the jitter budget before rebuilding, so a late packet comes out as sent (PROTOCOL.md 6.4 note). - Bugs the tests found during implementation: audio shard lifetime, early audio rebuild, an FEC budget overflow at k+m=255, ENet ping deadline while data is only queued. - No AI attribution in any commit.
mnovak added 56 commits 2026-11-26 04:01:43 +01:00
tools/vectors/gen_vectors.py makes the crypto vectors with tools independent of
RustCrypto: Python hashlib (SHA-256), the OpenSSL 3.5 CLI (RSA-2048 test-only
keys, X.509 certs, PKCS#1 v1.5 SHA-256 signatures, AES-128-ECB -nopad,
AES-128-CBC) and .NET 10 AesGcm (gcm_vectors.cs). Output goes to
crates/domistream/tests/fixtures (text only); not generated in this commit.

tests/common: seeded and scripted RandomSource, fixture reader, an independent
GF(2^8)/0x11D reference with Cauchy matrices, and test hosts that packetize
video (PROTOCOL.md 5.2-5.3) and audio (6.2-6.4).

Dev-dependencies: proptest (std only, no fork/timeout) and peak_alloc (MIT,
counting allocator for the allocation-cap test).
Fails if src/ uses std::net, Instant::now, SystemTime::now, std::thread,
std::fs, processes, env reads or OS randomness (comments stripped, grouped
std imports caught). Checks forbid(unsafe_code) and that Debug never prints
rikey, the PIN or the private key.
XML reader, serverinfo, applist, launch and status answers: empty, 1 byte,
max-1, max, max+1, huge; depth bombs, element, attribute and text caps,
entities, DTD and billion laughs, namespaces. Request builders refuse bad ids
and query injection. proptest round trip of generated XML trees.
Walks every state with a recorded transcript (fixtures from tools/vectors).
Wrong PIN, wrong hash, wrong cert, rogue and flipped signatures, wrong sizes,
out-of-order, replayed and cross-session answers all end in Failed(reason);
Paired cannot be reached by skipping a step. Crypto helpers, certificates,
identities and the PIN against the same vectors.
Bad start lines, header floods, line cap, lying Content-Length (over, under,
past the cap, past u64), 64 KiB+1 in the framer, chunking invariance,
surround-params against RFC 7845, ANNOUNCE intersection, and the client state
machine with hostile answers.
Byte vectors built from the PROTOCOL.md 3.1 field definitions, every command
size, truncation, compressed and unknown commands, 32/33 commands and
4096/4097 bytes. Client: handshake, reliable sequence past 0xFFFF -> 0,
duplicates, far-future and far-past, lying fragments, retransmission,
timeout and disconnect.
Nonce layout (seq LE, 6 zero, direction, 'C'), seal against .NET AesGcm
vectors, every tampered byte, wrong direction and key, lying length fields.
ControlStream drops replayed, older, reflected and forged frames and refuses
seq 0 after u32::MAX. Host message layouts and client message encoding.
INPUT_DATA built from PROTOCOL.md 4 field tables, cross-checked against its
example bytes; encode, parse, equal for every known type; unknown types,
UNKNOWN-layout types, wrong lengths, lying length and size fields, changed
constants and out-of-range values refused.
RTP header, video packet and frame header, audio packet at every size
boundary; inconsistent FEC fields; video AES-GCM against .NET vectors and
audio AES-CBC against openssl vectors, including rikeyid + seq wrap and bad
padding. The RustCrypto test oracles are checked against the same vectors.
Every erasure pattern of size <= m for k 1..=8, m 1..=4 and the Wolf 4+2
example; k = 1..=255-m sweeps for m in 1,2,3,4,8,16,64,127,254; > m refused
with Truncated. with_parity_matrix checked byte-exact against an independent
GF(2^8) Cauchy construction and refused for non-MDS matrices.
Generated multi-block frames with random, bursty, all-parity, all-data,
last-packet loss, reordering and duplicates; RTP sequence and frame index
wraps; far-past and far-future strays; recovered shard headers deliberately
garbage (bytes 0-31 untrusted); encryption with tampering. Frames are
byte-exact or reported in FrameLost, never corrupt.
All 64 loss patterns of a 4+2 block with two different MDS matrices through
AudioFec::ParityMatrix (U16 unmeasured), encrypted and plain; FEC disabled;
sequence wrap; duplicates; reordering; far-past and far-future; hostile
parity; the loss timeout.
A counting global allocator (peak_alloc) checks that small inputs with lying
length fields and arbitrary inputs never make a parser allocate past a bound
tied to the input and its caps; depacketizers and the ENet peer stay within
their in-flight caps.
Every target now checks properties instead of only calling the parser:
parse -> encode -> parse stability (RTSP request, ENet, input), caps and
TooLarge past them, chunking invariance of the framer, XML vs status parser
agreement, seal/open round trips, no forged GCM tags. New targets for the
parsers and state machines that had none: server_cert_der, enet_client,
media_decrypt, video_depacketizer, audio_depacketizer, fec_reconstruct,
pairing_session, rtsp_client (25 targets).
Generated by tools/vectors/gen_vectors.py with Python hashlib, OpenSSL 3.5.7
(Git for Windows) and .NET 10 AesGcm. Keys and certificates are TEST-ONLY,
made fresh on this machine for these tests: RSA-2048 host, client and rogue
identities, and an EC certificate for the non-RSA refusal.
default-features = false, features = ["aes", "alloc"]: aes-gcm's default
pulls in getrandom, which would make the OS RNG reachable inside a crate whose
randomness must only come through RandomSource. Approved by the build lead.
Cargo.lock also gains the test-only dev-dependencies (proptest, peak_alloc).
Temporaries borrowed past their statement (control, media), clippy's
is_multiple_of, needless index loop and type complexity. input.rs: the
MOUSE_MOVE_ABS builder dropped the y field; the PROTOCOL.md cross-check would
have caught it at runtime.
The never-panic properties (XML, RTSP, ENet, control, input, media) and the
allocation-cap checks only asserted inside `if let Ok`, so a stub returning
Unimplemented for everything passed them. Each now also requires the parser
to answer something other than Unimplemented (common::implemented); the XML
truncation property wants Malformed or Truncated, not any error.
Per PROTOCOL.md and the Wolf docs; interop with a real host is unverified. Strict, capped parsers throughout,
shared helpers in util.rs. Where PROTOCOL.md says UNKNOWN the Wolf-documented behaviour is used. The audio
receiver waits for the jitter budget before rebuilding a missing packet, so a late packet beats a rebuilt one.
Paused at Mark's request.
xml_depth_bomb_does_not_recurse: the closed half was 300 000 tag pairs
(2.1 MB), over MAX_XML_BYTES, so its `s.len() < MAX_XML_BYTES * 2` assert
failed and the depth check under it never ran (the protocol engineer was
right). Now 100 000 opens + 100 000 closes (about 0.7 MB): within the size
cap, it must be refused as TooLarge { max: MAX_XML_DEPTH }, without
recursion. The open-tags half is unchanged.
docs/MUTATION.md: each mandatory area's bug put back into src and caught by
its tests (parser caps off by one or removed for XML, RTSP, ENet, input,
video, audio; lying lengths; the ENet 0xFFFF wrap; the control replay
check; the nonce direction byte; ignored GCM tags, control and video; a
video parity index off by one; a rebuilt video shard's header trusted;
audio parity keyed by RTP sequence; a skipped pairing step; unchecked host
signatures; Instant::now and getrandom in src). No mutation survived, so no
test was added.

tools/mutation/mutate.py: the exact edits, so the pass can be rerun
through the resource gate.

Also: pairing_session fuzzed 10 min, 574 761 runs, no crash.
Author
Owner

Merged by hand: main c21e685, pushed; HEAD == origin/main checked. Tagged stream-v0.1.0.

Merged by hand: main c21e685, pushed; HEAD == origin/main checked. Tagged stream-v0.1.0.
mnovak closed this pull request 2026-11-26 04:01:48 +01:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/DomiStream#3