Skip to content

test(sessions): add Session/Memory/Summary multi-backend replay consistency framework#1

Open
coder-mtj wants to merge 26 commits into
mainfrom
feat/issue-89-replay-consistency
Open

test(sessions): add Session/Memory/Summary multi-backend replay consistency framework#1
coder-mtj wants to merge 26 commits into
mainfrom
feat/issue-89-replay-consistency

Conversation

@coder-mtj

Copy link
Copy Markdown
Owner

Description | 描述

This PR adds a comprehensive Session/Memory/Summary multi-backend replay consistency test framework.

4-stage pipeline: load → replay → normalize → compare → report

Key Features | 核心特性

  • 20 deterministic replay cases: 10 core + 10 enhanced (Chinese, emoji, nested payloads, large batches, state scoping, event filtering)
  • Deterministic summarizer: Overrides _compress_session_to_summary() for stable output without LLM
  • Recursive comparator: dict-by-sorted-keys, list-by-position, structured DiffEntry with field-level location
  • JSONPath-based allowed_diff: [*] wildcard, mandatory reason, governance limits (≤8 per case, ≤10% ratio)
  • Jaccard semantic similarity: Token-set comparison for summary text (pure stdlib, threshold ≥0.80)
  • Three-category summary detection: loss / overwrite / affiliation at 100% detection rate
  • Two-layer mutation injection: snapshot layer + end-to-end backend layer (SQL row / Redis key)
  • Schema v3 report: backend_statuses, per-case diffs, field-level DiffEntry, FPR/mutation summaries

Backend Coverage | 后端覆盖

Backend Status
InMemory Always available
SQLite Always available (tmp_path)
External SQL Gated by TRPC_AGENT_REPLAY_SQL_URL
Redis Gated by TRPC_AGENT_REPLAY_REDIS_URL

Test Results | 测试结果

  • 57 tests, all passing
  • InMemory baseline: 0 unexpected diffs (20 cases)
  • Cross-backend (InMemory vs SQLite): FPR < 5%
  • Summary fault detection: 100% (loss/overwrite/affiliation)
  • Lightweight mode: ~2 seconds (SLO: ≤ 30s)

Design Documentation | 设计文档

See docs/issue-89-replay-consistency/design.md for normalization strategy, summary comparison strategy, allowed_diff rules, and backend integration.

Related Issue | 关联 Issue

Fix trpc-group#89

Change Type | 修改类型

  • New feature | 新功能
  • Test coverage | 测试覆盖
  • Documentation update | 文档更新

Test Coverage | 测试覆盖

Test File Tests Coverage
test_replay_unit.py 34 normalizer, comparator, allowed_diff, summary_checks
test_summary_checks.py 8 loss, overwrite, affiliation, Jaccard
test_replay_consistency.py 3 baseline, cross-backend, performance SLO
test_replay_injections.py 12 snapshot injection, summary fault injection, FPR

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过 (57/57 tests pass)
  • No existing features affected | 无影响现有功能 (zero production code changes)
  • Lightweight mode ≤ 30s | 轻量模式 ~2s

weimch and others added 26 commits July 6, 2026 19:12
- 原因:没有移除思考内容及做中间轮工具调用Event的检测
- 解决方案:使用Event.is_final_response保证是LLM最后一个结果,然后移除最后一个结果的思考内容
Allow the Runner's app identity to differ from the A2A service_name by
adding an optional app_name parameter. Falls back to service_name when
not provided, preserving existing behavior for all current callers.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ion (trpc-group#145)

list_sessions 的 user_id 参数改为可选,传 None 时返回指定 app 下
所有用户的会话列表(不含 events)。InMemory/SQL/Redis/EvalSessionService
实现统一调整,并补充中英文文档用法说明及单元测试。
- Fix pip install command by enclosing extras in double quotes
- Remove extra spaces and normalize casing in extra packages list
- Ensure command works correctly for installing optional dependencies
- Removed extra spaces within the optional dependencies list
- Added quotes around the dependency list to ensure proper bash parsing
- Corrected capitalization for consistency in package names
- 在模型支持重试的特性支持里,把这个信息打印给移除了,现在修复这个问题
* AI review prompt

* Extend example_timeout_second in all_example_test
Feature:
- 参考claude code 的工具设计、提示词设计进行框架plan mod能力的设计与实现。
- 支持模型主动进入plan 模式 & 用户主动选择plan模式。
- 支持agui 解析 toolset能力

BugFix:
- 修复agui协议传递state数据无法有效更新问题。

Doc:
- 支持plan mod指引文档。
- 单独列出todowrite、task、goal的指引文档。
- 接入tavily到websearch及webfetch工具
- 补充单测及文档
…stency framework

Add a comprehensive replay consistency test harness for Session,
Memory, and Summary backends (closes trpc-group#89).

Key components:
- 20 deterministic replay cases (10 core + 10 enhanced:
  Chinese, emoji, nested payloads, large batches, etc.)
- 4-stage pipeline: load -> replay -> normalize -> compare -> report
- Deterministic summarizer (no LLM dependency)
- Recursive comparator with structured DiffEntry
- JSONPath-based allowed_diff with governance limits
- Jaccard semantic similarity for summary text comparison
- Two-layer mutation injection (snapshot + end-to-end backend)
- Schema v3 diff report with field-level location

Tests: 57 tests covering normalizer, comparator, allowed_diff,
summary_checks, E2E replay, and fault injection.
Lightweight mode (InMemory vs SQLite): ~2s, well within 30s SLO.

Files:
- tests/sessions/replay_consistency/ (11 modules)
- tests/sessions/test_replay_consistency.py
- tests/sessions/test_replay_injections.py
- tests/sessions/test_replay_unit.py
- tests/sessions/test_summary_checks.py
- docs/issue-89-replay-consistency/ (design + usage)

Signed-off-by: coder-mtj <coder-mtj@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

构建 Session / Memory 多后端回放一致性测试框架

10 participants