Skip to content

sessions: add replay consistency harness for session memory summary#177

Open
xiaoyvhuv wants to merge 1 commit into
trpc-group:mainfrom
xiaoyvhuv:fix/issue-89-replay-consistency
Open

sessions: add replay consistency harness for session memory summary#177
xiaoyvhuv wants to merge 1 commit into
trpc-group:mainfrom
xiaoyvhuv:fix/issue-89-replay-consistency

Conversation

@xiaoyvhuv

@xiaoyvhuv xiaoyvhuv commented Jul 13, 2026

Copy link
Copy Markdown

概述

本 PR 实现了 Issue #89 所需的 Session / Memory / Summary 多后端 replay 一致性测试框架。

该实现默认走轻量、确定性测试路径,覆盖:

  • InMemory 后端
  • SQLite SQL 后端
  • 可选 SQL URL 集成测试
  • 可选 Redis 集成测试

本 PR 不引入生产依赖,不修改存储 schema,也不修改公开运行时 API,主要通过测试侧 harness 完成验证。

Fixes #89

主要改动

Replay 一致性测试框架

新增 tests/sessions/replay_consistency/,包含:

  • 确定性的 replay case 定义
  • InMemory、SQLite、SQL URL、Redis backend adapter
  • session、event、state、memory、summary 的 canonical snapshot
  • 字段级规范化
  • 结构化 semantic diff
  • 显式 allowed_diff 规则
  • mutation operator 注册与检测
  • semantic oracle 检查
  • JSON report schema 与报告生成
  • 持久化后端 restart / rebuild 验证
  • 环境变量控制的 integration tests

默认覆盖范围

默认 lightweight 测试覆盖:

  • event 顺序与内容一致性
  • state 浅层更新语义
  • memory 在 user/session 维度的隔离
  • summary 创建与替换行为
  • summary session 归属校验
  • summary coverage 校验
  • 持久化后端重建后一致性
  • 已知缺陷模式的 mutation 检出能力

同时加入 replay case manifest 和 acceptance matrix,让覆盖范围可审查、可追踪。

Summary 专项缺陷检测

本 PR 明确覆盖 Issue 要求的 summary 缺陷类型:

  • summary 丢失
  • 旧 summary 错误覆盖新 summary
  • summary 归属到错误 session
  • summary covered event set 错误
  • derived summary version 错误

这些缺陷通过 mutation tests 和 semantic diff 自动验证。

可选集成测试

Redis 和 SQL URL 集成测试默认不运行,只有显式配置环境变量时才启用。

Redis:

RUN_REPLAY_REDIS_INTEGRATION=1
REDIS_URL=redis://...

This change adds a test-side replay consistency harness for Session, Memory, and Summary behavior across InMemory, SQLite, SQL URL, and Redis backends. It includes deterministic replay cases, canonical snapshots, semantic oracle checks, mutation detection, restart validation, structured JSON reports, and env-gated integration tests.

Fixes trpc-group#89

RELEASE NOTES: NONE
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@xiaoyvhuv

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@e113610). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             main        #177   +/-   ##
==========================================
  Coverage        ?   87.58815%           
==========================================
  Files           ?         467           
  Lines           ?       44103           
  Branches        ?           0           
==========================================
  Hits            ?       38629           
  Misses          ?        5474           
  Partials        ?           0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xiaoyvhuv

Copy link
Copy Markdown
Author

recheck

@xiaoyvhuv

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Rook1ex added a commit to trpc-group/cla-database that referenced this pull request Jul 13, 2026
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 多后端回放一致性测试框架

1 participant