Ranked Voice v2 -- integration and deployment
============================================

Player flow
-----------
Open Ranked and invite one friend. Voice joins that party automatically, using
voice activation by default. Searching/warmup/match connections use the same
Ranked session. Team membership and alive/dead/intermission policy come from
the authenticated game server. The stock search and party menus include VOICE
SETTINGS; F7 opens the same popup in a match. No voice account or Discord client
is required. The optional !link integration is unrelated to voice.

Settings stay local and are archived: microphone mute, listening/deafen,
optional push-to-talk, input/output device, sensitivity, microphone gain,
playback volume and optional noise reduction. Player mute/volume follows the
participant identity rather than a reusable game slot. The scoreboard's mute
control uses the same player mute. The local microphone test ends after 30
seconds or closing settings; its microphone audio is never transmitted.

Voice activation defaults to -58 dBFS, with 40 ms preroll and 300 ms release to
preserve soft beginnings/endings. NATURAL leaves denoising off; NOISE REDUCTION
uses RNNoise. There is no echo-cancellation claim: use headphones to prevent
game/voice playback from returning through an open microphone. Users can adjust
the activation threshold or select PTT for a noisy room. Physical mute remains
a local device control.

Media and trust
---------------
Mono 48 kHz / 10 ms Opus at 96 kbit/s constrained VBR. SRTP uses libSRTP's
AES128_CM_SHA1_80 profile and replay protection; authenticated SRTCP binds UDP
addresses and measures RTT. Keys are scoped to a lobby token and a separate
private client proof. That proof is bound at initial HTTPS registration,
required on control requests, and never put in game userinfo, dvars or server
presence files. Production control traffic requires normal, certificate-
validated HTTPS. The relay authenticates then re-encrypts packets for allowed listeners,
without decoding/transcoding. This is encryption to the trusted relay, not
end-to-end encryption against the server operator.

Only an authenticated per-server bridge can publish game GUID/token/slot/team
and communication state. A frontend claim of a GUID or team grants no game
voice authority. R2 presence is refreshed every 250 ms and must be at most one
second old. Stale server policy and expired client leases stop routing; missing
match authority never opens an all-player channel. Mute/route updates have the
bounded control/presence polling delay, rather than an instantaneous guarantee.
Brief silence during a server/map authority gap is intentional.

Windows' multimedia scheduler prioritizes the codec/mixing worker when available;
ordinary thread priority remains a fallback. Device initialization and cleanup
stay on the same owner thread. Endpoint callbacks only signal a change. Default
input/output follows Windows; an explicitly selected device stays selected.
If a microphone disappears, incoming voice continues through a playback-only
fallback. Capture retries in the background and resumes when the mic returns.
Mute, deafen or leaving cancels pending capture recovery.

Media runs independently of rendering/game frames. The output queue holds up
to 30 ms to tolerate batched Windows/Wine callbacks. Each speaker has SpeexDSP
adaptive jitter and Opus loss concealment. Speech quality and total latency
also depend on microphones, drivers and the network. The tests do not certify
Discord parity, a physical mouth-to-ear latency target, or transparent 5% loss.

The speech QA follow-up preserves preroll speech by disabling Speex's automatic
per-tick frame removal. Delay can grow at packet shortages and is bounded by
talkspurt/stall/backlog resets; this is not continuous time stretching. Encoder
and decoder restart together on each marked activation, with decoder reset at
playout rather than packet arrival, preventing quiet restart volume spikes.

Server installation
-------------------
Use the same patched Win32 DLL on clients and all game servers. Linux game
servers run it through Wine; the Python services run natively. Deploy all
scripts/mp files including ranked_system.gsc, plus both updated bridges.
Never deploy tests/native observers to a play server.

In the lobby service's Python environment:

  python -m pip install -r ranked_lobby/requirements-voice.txt
  python -m ranked_lobby.service --config /private/path/lobby.json

See ranked_lobby/service.public.example.json for the public TLS configuration.
Keep bridge/rating tokens and TLS private keys outside the player package.
The lobby needs its existing rating-service configuration and server registry.
For a current small deployment one lobby/voice relay can serve all registered
game instances. Game VPS bridges report to that backend. The voice relay is a
single configured location: choose it for players' latency; automatic regional
relay selection and multi-node relay failover are not implemented.

Public requirements:
- A DNS hostname with a valid certificate/full chain for the lobby HTTPS URL.
- TCP on the configured HTTPS port (example 8791; 443 is also supported).
- UDP on voice.port (example 29901), forwarded to the lobby/voice process.
- Existing game UDP ports; private rating service and bridge credentials.
- voice.host must be the externally reachable relay hostname/address.
- Set client_menu/servers.json lobby_url to HTTPS, the game server pool to the
  real game endpoints, and voice_allow_insecure_lan to false. Rebuild the IWD.

The explicit LAN exception needs voice.allow_insecure_lan=true on the backend
AND voice_allow_insecure_lan=true in the client pool. Clients accept plaintext
only for numeric RFC1918/loopback IPv4 endpoints. The backend checks source
addresses as well. Do not use that exception for a public reverse proxy.
The normal MS-02 test backend uses TCP 8791, game UDP 29860, voice UDP 29901.
No public VPS endpoints have been configured by this integration.

Bounds and lifecycle
--------------------
The relay allows 256 active sessions, at most 18 recipients per packet, a
1100-byte datagram limit and a 140 packet/s per-client budget with a 24-packet
burst allowance. HTTP has bounded request bodies/workers and timeouts. Python
libSRTP calls are serialized; clients use independent crypto contexts. Leaving
Ranked destroys its media session and restores legacy voice for ordinary game
servers, preserving the player's existing cl_voice preference. Late control
responses cannot reopen the party after leaving. Disabling new voice never
silently falls back to legacy
voice inside a v2 Ranked session. Old clients receive an update-required error.

Diagnostics: zv_stats prints packet counts, rejection/concealment/resyncs,
RTT, actual device rates/periods, worker/device timing and ring underruns.
These are counters, not voice recordings. Concealment includes gate/tail gaps
and timing correction; do not interpret it as a measured network loss rate.
No conversation PCM, encoded media or session keys are logged by the service.

Deployment and rollback
-----------------------
Back up the DLL, IWD, service code/config and scripts together. Stop the game
instance before replacing its DLL. Restart the lobby and its per-game bridges
after installing the dependency/config; restart the game with updated scripts.
Update player DLL and menu together; the installer embeds both plus licenses.
Installer 1.22 installs Ranked, voice, menus, settings and class setup on every
install/update/repair. Only DLC maps are optional (selected by default). The
start-game checkbox controls launching, not installation. A required component
failure prevents completion and launch. Ranked voice already defaults to the
48 kHz / 96 kbit/s Opus path; legacy sv_voiceQuality, including value 9, has no
effect on it. Existing microphone/mute/activation preferences remain local.
Installer 1.26 and corresponding native source are published on zeal.family.
Game/DLC archives also come from MS-02 through zeal.family; see DOWNLOAD-HOSTING.txt.
The relay stays on MS-02. The control channel now uses certificate-validated
HTTPS at ranked.zeal.family; media UDP is still the LAN test endpoint until
Psychz is ready for a protected forwarding route. See CENTRAL-OPERATIONS.txt.
Central staff voice timeouts suppress transmission at the relay; a modified
client cannot unmute itself around this policy. Player blocks also suppress
voice in both directions. These controls do not change local microphone settings.

To roll back, stop affected services, restore the matching saved DLL/IWD and
server scripts/service configuration, then restart. Or disable voice.enabled
in the lobby configuration to negotiate legacy behavior with the new client.
Keep new microphone preferences local; server scripts cannot set zv_* dvars.

Evidence and remaining qualification
-----------------------------------
See qa/voice-quality-20261012/REPORT.txt for the latest speech fixes, native
Windows regression tests and build hashes. The previous native device and
eight-player game checks are in qa/voice-windows-20261012/REPORT.txt; those game
sessions were not repeated by the offline speech pass. The earlier backend evidence
is retained in qa/voice-integration-20261012/REPORT.txt. Earlier isolated codec comparisons are in
qa/voice-20261012/REPORT.txt. Use real Windows headsets and a human listening
comparison before claiming equal or better clarity than Discord. Check USB and
onboard devices, hotplug, noisy rooms, WAN connections and sustained match play.
