fix(voice_worker): one person's voice and chat answers are written one at a time

The voice and chat lanes let a person's voice reply start while their chat
reply was still running. The chat delete consent counts "the very next
message" by turn number, so a message that started before the delete was
asked could pass as the confirmation, and the person's dialogue memory
was updated out of order.

- A reply takes its asker's lock, then its lane's: one person's replies
  stay one at a time in the order asked, different people's voice and
  chat answers still overlap, and a reply waiting for its asker holds no
  lane. Test: a person's voice question starts only after their chat
  answer.
- Specs and roadmap: the lanes are per person; the roadmap no longer says
  voice answers wait behind chat answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 01:27:13 +09:00
parent 2f69557e1b
commit 19f984ae73
6 changed files with 50 additions and 10 deletions

View File

@@ -15,7 +15,8 @@ from jarvis.memory.history import HistoryContext, Scope
class Brain(Protocol):
def reply(self, user: str, text: str, history: HistoryContext, chat=None) -> Optional[str]:
"""Blocking; called on a worker thread, one call at a time. ``chat``: the chat backend for
"""Blocking; called on a worker thread, one call per person at a time (a voice and a chat
reply for different people may overlap). ``chat``: the chat backend for
the chatChannels tool (voice_worker/chat_bridge.py), or None without registered channels."""
def addressed(self, user: str, text: str, names: list[str]) -> Optional[bool]:
@@ -74,8 +75,9 @@ class Muted:
The v1 reply engine and its tools print the question, the answer, tool arguments, URLs and
memory snippets (``print`` and ``debug_log``, also from helper threads such as the web fetch
pool); the worker's logs must never carry such text. Replies run one at a time; the worker's
own log (``voice_worker.log``) writes to the original stderr and is not muted.
pool); the worker's logs must never carry such text. Replies may overlap (a voice and a chat
lane); output stays muted while any of them runs. The worker's own log (``voice_worker.log``)
writes to the original stderr and is not muted.
"""
_lock = threading.Lock()