外观
Day 5:消息核心链路
当日成果
完成可恢复的消息发送、分页、乐观展示、sequence、receipt、read/unread 和引用回复。
能力边界
本日聚焦消息主链路。编辑、撤回、reaction、搜索、mention 和附件在 Day 6。
能力合同
| Capability ID | API | Admin | iOS | Android | 关键证据 |
|---|---|---|---|---|---|
| MSG-001 发送与幂等 | ✓ | ✓ | ✓ | ✓ | duplicate retry |
| MSG-002 Sequence | ✓ | ✓ | ✓ | ✓ | concurrent ordering |
| MSG-003 分页时间线 | ✓ | ✓ | ✓ | ✓ | anchor retention |
| MSG-004 Read/unread | ✓ | ✓ | ✓ | ✓ | multi-device |
| MSG-005 引用回复 | ✓ | ✓ | ✓ | ✓ | target mutation |
调查提示
text
进入 MESSAGING-CORE。调查 messageSequence、Message.sequence、clientMessageId、
receipt/read state、分页 cursor、本地 optimistic/outbox 和引用目标合同。重点查并发、
重复请求、时间线锚点和服务端写入与 durable event 的事务边界。1
2
3
2
3
学员决策
- 消息排序以服务端 sequence 还是客户端时间为权威。
- pending/failed/sent 状态如何展示。
- read state 是 conversation 级还是逐消息。
- 引用目标编辑或删除后的展示语义。
Feature Goal
text
/goal 完成 MESSAGING-CORE,使多设备、并发、重复提交、断网重试和历史分页下的消息
顺序、未读和引用行为一致。以真实数据库并发测试、outbox 重放、sequence gap 检测、
iOS/Android 时间线 acceptance 为完成证据。1
2
3
2
3
跨端实施面
- API:message transaction、sequence、receipt、read state、durable event。
- Admin:只读消息元数据和运维诊断,不暴露不必要正文。
- iOS:GRDB message/outbox、虚拟时间线、锚点和 pending 状态。
- Android:Room transaction、outbox、向上分页和未读分割。
Mandatory gates
- [ ] clientMessageId 重试不产生重复消息。
- [ ] 并发发送 sequence 唯一且单调。
- [ ] write 和 durable event 同事务或可证明收敛。
- [ ] read/unread 在多设备下正确。
- [ ] 历史分页不跳动、不覆盖 pending。
- [ ] 引用目标不存在或变化时有稳定降级。
- [ ] 断网重启后 outbox 自动继续。
常见假完成
- 使用 createdAt 排序掩盖并发错误。
- 乐观消息只存在内存,进程重启丢失。
- mark-read 失败仍永久清除未读。
- 分页刷新覆盖本地 pending 消息。
Checkpoint
冻结 message ordering contract、并发证据、两端 outbox/time-line 验收和 messaging-core-green。