docs(test): chat turn idempotency automated test report
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
# 聊天回合幂等与项目切换隔离 测试报告
|
||||
|
||||
## 一、测试背景
|
||||
|
||||
重复消息写入与项目切换重复展示问题:后端无幂等门禁、前端 temp/server ID 对账失败、全局流状态冲突。本报告覆盖自动化回归与实现验收。
|
||||
|
||||
## 二、测试目标
|
||||
|
||||
- 同 `client_turn_id` 不重复执行 Agent
|
||||
- 本地 temp 与服务端 msg-dbId 正确合并
|
||||
- A→B→A 窗口竞态不覆盖
|
||||
- 按 session 隔离流运行态
|
||||
|
||||
## 三、测试方案与环境
|
||||
|
||||
- OS: darwin 25.6.0
|
||||
- 前端: Node test + Vitest 子集
|
||||
- 后端: Go 1.x,`internal/ctxmgr` 内存双轨(无 Postgres 依赖的单测)
|
||||
- 分支: dev
|
||||
|
||||
## 四、预期结果
|
||||
|
||||
| 用例 | 预期 |
|
||||
| :--- | :--- |
|
||||
| shouldAutoRetryChat | 恒 false |
|
||||
| messageIdentity 合并 | pendingLive=0 |
|
||||
| chat_turns 并发 acquire | 仅 1 winner |
|
||||
| 窗口 generation 竞态 | B 晚到不覆盖 A |
|
||||
|
||||
## 五、实际测试结果
|
||||
|
||||
### 5.1 前端单测
|
||||
|
||||
```
|
||||
npm test -- --run src/api/chatRetry.test.ts
|
||||
npm test -- --run src/engine/messageIdentity.test.ts
|
||||
npm test -- --run src/tests/workflow-chat-chronology.test.ts
|
||||
npm test -- --run src/hooks/useChatWindow.race.test.ts
|
||||
npm test -- --run src/hooks/useTurnRuntime.test.ts
|
||||
```
|
||||
|
||||
**判定: PASS**(全量 web test suite 145/145)
|
||||
|
||||
### 5.2 后端单测
|
||||
|
||||
```
|
||||
go test ./internal/ctxmgr/ -run ChatTurn -v
|
||||
go build ./...
|
||||
```
|
||||
|
||||
**判定: PASS**
|
||||
|
||||
- TestAcquireChatTurn_DuplicateSameBody: PASS
|
||||
- TestAcquireChatTurn_ConcurrentDuplicate: PASS (wins=1)
|
||||
- TestAcquireChatTurn_DifferentBodyRejected: PASS
|
||||
|
||||
### 5.3 真实 Agent E2E
|
||||
|
||||
**状态: 待运维环境验收**
|
||||
|
||||
需在 `agent-dev`(8080/5433)部署迁移 `2026-09-11-chat-turns.sql` 后,使用真实 pi-agent + MiniMax-M3 执行:
|
||||
|
||||
1. 项目 A 发送 → 切 B → 回 A
|
||||
2. 弱网手动重试同 turn
|
||||
3. DB 校验 `chat_turns` 单行
|
||||
|
||||
## 六、自动化测试套件汇总
|
||||
|
||||
| 套件 | 通过 |
|
||||
| :--- | :--- |
|
||||
| web npm test | 145/145 |
|
||||
| ctxmgr ChatTurn | 3/3 |
|
||||
| go build | OK |
|
||||
|
||||
## 七、结论与后续
|
||||
|
||||
- 代码层止血、身份合并、幂等门禁、session 串行、per-session 流态已实现并通过自动化测试。
|
||||
- 真实 Agent 端到端验收需在 dev 环境部署迁移后补测并更新本报告 §5.3。
|
||||
Reference in New Issue
Block a user