feat(voice_worker): record history from the app and answer reply requests with the brain

Worker (voice_worker.spec.md "History and brain"):
- --history <file> keeps the conversation history store; --brain hosts the
  jarvis reply engine (JarvisBrain, settings point ollama_base_url at /v1).
- voice_join / voice_leave / member_join / member_leave keep presence; the
  session end closes it. Non-empty finals are stored under the speaker's name
  in the current voice channel.
- chat_message / chat_edit / chat_delete keep registered chat channels.
- reply builds the asker's scoped history context, runs the brain on a thread
  (one at a time), answers reply_text, stores a voice answer, and with
  speak=true says it under the same id. memory settings in hello and
  memory_config. brain_unavailable without --brain.

App (discord_core.spec.md "History reporting"):
- WorkerClient sends the new messages; the core reports the voice channel
  and its heard members after a join, a move and every worker reconnect,
  member joins and leaves, voice_leave when a session ends, and every message
  of a readable registered channel (its own too, with `to` on replies), edits
  and deletes.
- live_discord runs the worker with --history and checks the store at the
  end: 8 finals under the speaker's name, the edited chat message only,
  Jarvis's own messages, 5 presence intervals, none left open (passed, 107.8 s).

Eval: history recall gains a chat-record case and fails a reply that reads a
record stamp out (field run with qwen2.5:7b did once in four).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 13:16:24 +09:00
parent 7a288129de
commit 864b2e7fdb
13 changed files with 775 additions and 18 deletions

View File

@@ -91,6 +91,22 @@ are dropped (not queued), and every TTS request in flight ends as failed, so pla
request the worker refuses (`tts_unavailable`) also ends as failed. TTS audio for request ids the client
did not open is ignored.
### History reporting (M3)
The core tells the worker what its history store needs (`voice_worker.spec.md`, "History and brain"):
- `voice_join` with the channel after every join or move (also when someone else moves the bot), and
`member_join` with the display name for everyone already in the channel that the bot hears (people;
bots only with `voice.listenToBots`). Again whenever the worker link becomes ready, because messages
sent while disconnected are dropped.
- `member_join` / `member_leave` as heard people enter and leave the channel.
- `voice_leave` whenever a session ends (leave, move, disconnect).
- For every message in a readable registered channel, the bot's own included: `chat_message` with
Discord's time; on the bot's own message that replies to someone, `to` is that person. Edits
(`chat_edit`), deletes and bulk deletes (`chat_delete`) follow. Chat sent while the worker is
disconnected is not recorded.
- Finals are recorded by the worker itself; the core does not echo them.
## Voice
One voice session at a time, in the configured server. Joining another channel ends the current
@@ -175,14 +191,18 @@ registered until it is removed (M5 setup).
voice channel with the real worker on the GPU. It refuses to run if a person is in the channel or
either bot is already in a voice channel, and cleans up even when a step fails. It checks command
registration, transcription of recorded sentences played into the channel, speech the other bot
hears and the STT reads back, stop, chat events, history, sending without pings, moving to a second
hears and the STT reads back, stop, chat events, history, an edit and a delete, sending without pings, moving to a second
voice channel and back (the session survives each move and only the two moves end one), the speaker
leaving and coming back three times (each a DAVE group change), and leaving. It needs a second voice
leaving and coming back three times (each a DAVE group change), and leaving. The worker runs with
`--history`; at the end the store must hold the speaker's finals under its display name and channel,
its chat message with the edit and without the deleted one, Jarvis's own messages, a presence
interval per join, and no presence left open. It needs a second voice
channel of the server (`JARVIS_LIVE_VOICE_CHANNEL_2`) and refuses if a person is in either.
Measured on this server's RTX 5050 (2026-11-11): five sentences all heard (character error rate 0%
for three, 5% and 12.5% for two), 0.71-0.90 s from the end of speech to the final, Jarvis's speech
read back at 3.4-6.9%, sound gone 0.03-0.08 s after stop, and the sentence heard exactly after each
of three rejoins.
of three rejoins. With history (2026-11-11): 8 voice records under the speaker's name, the edited
chat message only, 3 of Jarvis's own messages, 5 presence intervals, none open.
## Known risks