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
This commit is contained in:
Kevin
2026-04-30 14:11:46 +08:00
parent ac436b87a2
commit 71fbd39e32
53 changed files with 953 additions and 2448 deletions

View File

@@ -131,18 +131,17 @@ Playground 的结构化摘要里,后端会给出一份 `gate`
## 回忆录评审可追溯证据闭包lineage
**产品与 tier 口径strict / partial / fallback、synthetic vs library 分表、PM 对齐规则、backlog** 见同目录 **[traceable-memoir-lineage.md](./traceable-memoir-lineage.md)**。
**严格闭包口径、synthetic vs library 分表** 见同目录 **[traceable-memoir-lineage.md](./traceable-memoir-lineage.md)**。
手动 `/judge/memoir-chapters` 与历史自动化 run 的 `judge_bundle_json` 已按 **artifact 绑定证据** 组 prompt而不再默认拼接「最近 N 个会话全文」:
- **`lineage_tier`**`strict` / `partial` / `fallback`(章节:**有可解析 transcript 链 + 结构化记忆为 strict****仅有结构化记忆、无绑定 segment/transcript = partial**,与标注口径一致)。故事侧以 `StoryEvidenceLink` 与章节推导为主;`fallback` = 显式降级最近会话 transcript避免静默当 strict。
- **`evidence_trace`**bundle 完整 JSONsegment / conversation / chunk / fact / timeline / summary、`notes` 等)。内审计一般够用;若需按类型深链 UI 再排期。
- **`format_meta`**`truncated``dropped_sections``included_token_estimate`区分「prompt 裁掉」与「库中无 lineage」。
- **生产侧**:叙事流水线在每次 Story 写入后覆盖 `story_evidence_links`,并在当前 `story_versions.prompt_meta.memoir_retrieval` 写入本轮检索到的稳定 id`story_pipeline_sync._persist_story_lineage_sync`)。
- **章节快照 Phase C**`chapter_evidence_snapshots` + `chapter_evidence_links``chapters.current_evidence_snapshot_id` 指向当前版本;`evidence_bundle_json` 仍为镜像。评测读取顺序:表快照 → JSON → 现场 `source_segments`(不一致时 `notes` 提示)。刷新见 `memoir/chapter_evidence_snapshot.py`。历史库可选 `uv run python scripts/backfill_chapter_evidence_snapshots.py`(旧数据不强制)
- **章节快照 Phase C**`chapter_evidence_snapshots` + `chapter_evidence_links``chapters.current_evidence_snapshot_id` 指向当前版本;评测只读当前快照。刷新见 `memoir/chapter_evidence_snapshot.py`
- **对话 memory tracePhase 八)**:访谈路由下,`conversation_messages.memory_retrieval_trace_json` 在配对 **AI** 消息上写入本轮 `HybridRetriever` 命中的 chunk/fact/timeline/summary/story 等 id`memory/retrieval_trace.py`)。
历史数据可无 link:评测仍可用 partial/fallback 跑通;可选离线 backfill 须在 job 中显式打标,不冒充 strict
历史数据 link / snapshot 时不可评测,需先通过正式流水线重新物化
## Fixture 详情扩展
@@ -150,4 +149,3 @@ Playground 的结构化摘要里,后端会给出一份 `gate`
- `source_user_id`:导出抬头中的 User ID
- `memoir_sections``## 回忆录章节(生成正文)` 下按标题切分的基线正文(已去掉 `{{IMAGE:...}}` 占位)