# Speech transport diagnostics

Gateway emits metadata-only `[SPEECH_DIAG]` records through the existing service journal. No firmware update or USB connection is required. Playback, prebuffering, flow-control windows, timeouts and speech modes retain their current behavior.

Use `speech` (Gateway-generated playback ID) and `connection` (hashed connection ID) to correlate records. No reply text, target/session name, PCM/base64, credential, provider response or exception message is recorded.

- `start` and `pcm_ready`: source, complete PCM size/duration and synthesis time.
- `send_delay`: slow send/gap, at most once per second across send/progress records. Successful sends distinguish shared send-lock wait from socket-write time.
- `codec_progress`: device-reported cumulative frames written to the codec, including ACKs arriving after transmission ends. First ACK is logged, then at most once per second.
- `tx_end`: transmission outcome, stage, fixed error category, frame counts and maximum send/credit/progress gaps. `status=sent` means the Gateway sent `speech_end`; it does **not** prove receipt of all frames or continuous audible playback.
- `cancel`, `device_stop`, `disconnect`: explicit preemption reasons or observed device/connection events.

Only 32 metadata traces are retained, for at most 300 seconds each, with lazy expiry. Eviction cannot change playback or credits. Trace state is in memory; the existing journal controls log retention. Device progress is cumulative and approximately every eight frames; it is not a queue-depth or underrun counter. The final few codec frames may not produce an ACK, so a partial last ACK is not proof of lost audio. Socket send success is not proof of device arrival.

Investigate actual AUTO_REPLY: compare PCM duration, maximum chunk-send gap, send-lock/write latency, credit waiting and cumulative codec progress with disconnect/stop events. A credit wait is normal flow control; a long ACK gap alone cannot distinguish network delay from device scheduling. If server traces remain inconclusive, add device receive-queue/underrun metrics in a separately tested firmware change.
