feat(memory): v2 conversation history store and its context in the reply prompt

- src/jarvis/memory/history.py keeps voice transcripts, Jarvis's answers,
  registered chat channel messages (with edits and deletes) and voice channel
  presence in one SQLite file. Every read is scoped to the asker: own records
  always, chat channels and others' words (only while the asker was in the
  same voice channel) behind settings, plus an optional since and off.
- Search is language-agnostic: Unicode words, prefixes keeping 60% of the
  word, rarer words weigh more, newer wins ties. 100k records search in
  24-61 ms here. context() returns the recent window and the matches cut to a
  token budget, matches at most half so chatter cannot push out the record
  the question is about.
- run_reply_engine(history=...) puts that context into the system prompt
  under "Information shared in previous conversations", fenced as data.
  evals/test_history_context_recall.py: with the block qwen2.5:7b answers the
  stored day in Korean and English (3 of 3 runs), without it the day is unknown.
- Spec history.spec.md, registry entry in CLAUDE.md, reply.spec.md,
  docs/llm_contexts.md, docs/v2/memory.md and roadmap updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 12:45:33 +09:00
parent 6b23a8adc7
commit 54a465948a
11 changed files with 774 additions and 2 deletions

View File

@@ -30,3 +30,12 @@ v2에서는 다음 두 가지를 **전부** 대화 기록 저장소(SQLite)에
- **채팅 채널**: 등록한 채널의 메시지 전체입니다. 다른 사람이 쓴 글도 포함합니다.
숫자 기본값은 M0에서 맥락 길이별 첫 토큰 시간을 재서 확정합니다.
## 검색 방식 (M3, 2026-11-11)
저장소와 검색 규칙은 [history.spec.md](../../src/jarvis/memory/history.spec.md)에 있습니다.
- 질문의 낱말이 기록에 들어 있는지로 찾습니다. 낱말 뒤쪽이 조금 달라도 찾습니다(앞부분이 60% 이상 같으면 됨, "영화를"로 "영화", "watching"으로 "watched"). 드문 낱말에 점수를 더 줍니다. 특정 언어의 낱말 목록은 쓰지 않습니다.
- 뜻으로 찾는 검색(임베딩)은 아직 넣지 않았습니다. Strata는 대화 모델만 돌려서 임베딩을 만들지 못하고, 넣으려면 음성 워커에 작은 다국어 임베딩 모델을 따로 둬야 합니다. 실제 대화에서 낱말 검색이 놓치는 경우가 보이면 그때 넣습니다.
- 참고 분량 상한 안에서 지난 기록은 절반까지만 씁니다. 최근 대화가 길어도 이번 질문과 관련된 기록이 밀려나지 않게 하기 위해서입니다.
- 기록 10만 개에서 한 번 찾는 데 24~61ms, 두뇌에 넘길 내용을 만드는 데 54ms가 걸렸습니다(이 서버 기준). 이 시간은 LLM 호출 없이 SQLite만 읽는 데 드는 시간입니다.