fix(app): every stop voids waiting requests and pending addressed questions

- A voice stop also voids pending "addressed" questions, so a yes that
  arrives afterwards starts nothing.
- The core sends Stopped before the SpeakEnds of what stop() or the end
  of a session cancelled; the conversation drops its queue on it, so the
  slash command's stop no longer starts the next waiting request.
- An addressed answer after its 5 s timeout counts as no even when it is
  handled before the timer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 22:32:32 +09:00
parent f892a1dce9
commit de35573e5f
4 changed files with 85 additions and 22 deletions

View File

@@ -122,17 +122,20 @@ one request, stop all, ask "addressed", ask "rank"), so the glue is tested with
- `SpeechStart` opens the speaker's utterance; `SpeakingStopped` marks it ending.
- `Final`: a request gets the next id, `ended_at` = arrival minus the final's `wait_ms`, and goes
through call detection. Ignore closes the utterance. Stop stops all speech, runs the policy's stop and
closes the utterance. Request goes to the policy. Ask sends `addressed` to the brain; a yes becomes the
request, a no (or a failed judgement) closes the utterance, and no answer within 5 s counts as no.
through call detection. Ignore closes the utterance. Stop stops all speech, runs the policy's stop,
voids every pending "addressed" question (closing its utterance) and closes the utterance. Request
goes to the policy. Ask sends `addressed` to the brain; a yes becomes the request, a no (or a failed
judgement) closes the utterance, and no answer within 5 s counts as no, also when the answer arrives
after that but before the timer ran.
- Policy actions: `Answer` → `answer(user, text)` (the brain answers and the answer is spoken; when it
cannot be queued the answer is done at once); `StopAnswer` → `cancel` of that answer's speech;
`Rank { id }` → `rank` with id `k<id>` and the candidates' request ids; `Missed` → a debug log and
the missed list (the last 100: speaker, reason, time and length, never the text).
- `SpeakEnd` of an answer's speech is that answer's done. The end of a speech the loop already
cancelled starts nothing.
- `Left` (the bot left the voice channel): the policy's stop, and pending "addressed" questions close
their utterances.
- `Stopped` (all speech stopped from elsewhere: the slash command, `stop()`, the session ending) and
`Left`: the same stop. The core sends `Stopped` before the `SpeakEnd`s of the speech it stopped, so a
cancelled answer's end never starts the next waiting request.
- A timer wakes the loop at the policy's next deadline or the earliest "addressed" timeout.
The brain's two judgements are `src/voice_worker/judges.py` (`voice_worker.spec.md`): one short call