Gate the wake word on the scheduler's single slot being free: a wake that
fires while the current request is still running is ignored (traced
voice_wake_blocked), so a second command cannot start mid-run. The gate is
GatewayService.input_ready (False while a run executes, True when idle or
paused for the user's answer), handed to adapters via set_input_ready; the
voice adapter passes it to VoiceDaemon.input_ready.
Endpointing fix. The wake detector usually fires inside the wake phrase,
so the first speech captured after it is the phrase's tail (plus the cue
beep echoing back through the mic), not the command. A fixed 500 ms
trailing-silence endpoint then ended the capture during the natural pause
before the command: the utterance held 240-400 ms of speech and STT
returned empty. In a recorded session 18 of 30 wakes dropped the command
that way (only 10 transcribed).
The endpoint now uses a longer silence tolerance (vad.initial_silence_ms,
default 1500) until vad.min_command_ms (default 700) of speech is in
hand, then reverts to vad.silence_ms, so a pause before the command is
tolerated while a real command still ends promptly.
Front-end hardening (the ways it was silently dying or losing work):
- Utterances run on a worker thread, not the audio thread, and a task
error is traced and spoken rather than propagated, so one bad command
cannot stop the mic or take the front end down.
- Capture-stream watchdog: read with a timeout and close/reopen the input
after a sustained stall, so a wedged PortAudio/ALSA callback recovers
instead of hanging the gateway (traced voice_stream_stalled/reopened).
- faulthandler enabled (CLI + unit) so a fatal signal dumps every
thread's stack to the journal.
- The scheduler's answer-side entry points (answer, answer_question,
resolve_repair, answer_approval) are guarded like submit_request: an
EngineUnavailable is fatal-and-reported and any other resume/repair
error returns a reply instead of propagating into a front end.
Add trace boundaries and timings so the last-word -> first-audio latency can
be split by section:
- voice_transport: emit `voice_speech_end` (the last VAD-speech frame, i.e. the
true "last word"), `voice_speak_start`, `voice_tts_synth` (Piper duration +
audio length), and `voice_playback_start` (the instant the first reply
samples reach the device).
- trace: `TraceLog.append` accepts an explicit `ts` so an event records when it
happened, not when it was written.
- gateway/voice: trace `gateway_reply_dequeued` at the outbound pump.
- gateway/service: trace `humanize` (duration) and `gateway_reply_queued`; a
best-effort `_trace` helper tolerates test doubles with no trace log.
- log: persist the engine's per-decision `input_tokens`/`forward_seconds`/
`total_seconds` (already computed by the backend, previously discarded) into
the decision row's `extra.timing`.
scripts/voice-latency.py reads data/runs.jsonl and prints a per-interaction
breakdown (endpointing, STT, each SemIf guard, act/assess, humanize, TTS,
playback) plus aggregates.