Files
life-echo/api/docs/memory-retrieval.md
Kevin 71fbd39e32 feat(api)!: memory single chain — async MemoryService, strict eval closure
Route all memory ingest/retrieve/enrichment/compaction through async MemoryService.
Remove legacy sync memory implementations (ingest/retrieve/compaction); Celery and
memoir Phase2 call asyncio.run into MemoryService-backed helpers.

Memoir Phase1 batch ingest uses MemoryService.ingest_transcripts_batch; drop chapters.
evidence_bundle_json mirror (Alembic 0015). Evaluation uses snapshot/link-only bundles;
raise EvidenceClosureMissing instead of partial/fallback lineage tiers.

Split memoir state into NarrativeCoverageState and InterviewControlState; delete the
_interview_meta_store adapter layer. Remove rolling-query and recent-fact fallback
settings from config and evidence assembly.

Update judges, docs, tests, and PlaygroundPage alignment.

Made-with: Cursor
2026-04-30 14:11:50 +08:00

22 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 记忆检索async 单链路
Memory 运行链路只有一个入口:`MemoryService`
| 能力 | 入口 | 行为 |
| --- | --- | --- |
| ingest | `MemoryService.ingest_transcript` / `ingest_transcripts_batch` | 写入 `memory_sources``memory_chunks`、embeddingcommit 后投递 enrichment |
| retrieve | `MemoryService.retrieve` | 非空 query 做向量 chunk 检索,并合并 query 命中的 facts / timeline / session summaries / stories |
| enrichment | `MemoryService.enrich_source` | 单次 LLM 生成 session summary 与 confirmed facts |
| compaction | `MemoryService.compact_user` | 近重复 chunk 软排除并 stale 相关 facts |
## 检索语义
- 空 query 固定返回空 evidence bundle。
- facts / timeline / summaries 只按 query 命中返回;不回退最近事实、最近时间线或 rolling summary。
- `MemorySummary.summary_type="session"` 可进入 evidencerolling summary 不参与 prompt evidence。
- Celery task 只是同步入口包装 async service不再维护 sync memory 业务链路。
## 回忆录流水线
`process_memoir_phase1` 通过 `MemoryService.ingest_transcripts_batch` 批量写入记忆;`process_memoir_phase2` 先通过 `MemoryService.retrieve` 取 evidence再把 evidence 传给叙事流水线。叙事代码只消费 evidence不直接调用 memory repo。