Files
life-echo/api/tests/evaluation/test_eval_trace_service_dialogue_lineage.py
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

50 lines
1.4 KiB
Python

"""EvalTraceService 在 chapter 快照路径返回 dialogue_lineage。"""
from __future__ import annotations
from types import SimpleNamespace
from unittest.mock import MagicMock
import pytest
from sqlalchemy.ext.asyncio import AsyncSession
from app.features.evaluation.eval_trace_service import EvalTraceService
from app.features.memoir.chapter_evidence_snapshot import (
EVIDENCE_SNAPSHOT_SCHEMA_VERSION,
)
@pytest.mark.asyncio
async def test_build_chapter_bundle_dialogue_lineage_from_snapshot() -> None:
msg_ln = {
"schema_version": 1,
"conversation_id": "cv1",
"turns": [
{"user_message_id": "um-99", "assistant_message_id": "as-99"},
],
}
snap = SimpleNamespace(
user_id="u1",
chapter_id="ch1",
schema_version=EVIDENCE_SNAPSHOT_SCHEMA_VERSION,
segment_ids=["s1"],
conversation_ids=["cv1"],
memory_chunk_ids=["mk1"],
memory_fact_ids=[],
timeline_event_ids=[],
summary_ids=[],
notes=[],
message_lineage_json=msg_ln,
)
chapter = SimpleNamespace(
id="ch1",
user_id="u1",
source_segments=["s1"],
current_evidence_snapshot=snap,
)
db = MagicMock(spec=AsyncSession)
svc = EvalTraceService(db)
bundle = await svc.build_chapter_bundle("u1", chapter)
assert bundle.dialogue_lineage == msg_ln
assert bundle.dialogue_lineage["turns"][0]["user_message_id"] == "um-99"