DOC-FULL-024 P0 | EventBuffer ack 测试 【status:todo】 #77

Closed
opened 2026-06-07 11:33:19 +08:00 by wangdl · 2 comments
Owner

push→export→ack→clear→export again→mark failed→retry,ack后不重复导出,未ack不丢失

M-DOC-FULL 里程碑 issue。详见设计文档。

## push→export→ack→clear→export again→mark failed→retry,ack后不重复导出,未ack不丢失 M-DOC-FULL 里程碑 issue。详见设计文档。
wangdl added this to the M-DOC-FULL:Document Runtime 完整阅读内核与学习事件协议 milestone 2026-06-07 11:33:19 +08:00
wangdl changed title from DOC-FULL-024 P0 | EventBuffer ack 测试 to DOC-FULL-024 P0 | EventBuffer ack 测试 【status:todo】 2026-06-07 19:15:07 +08:00
Author
Owner

审查结论:document runtime 当前有文件类型识别/MaterialType/PreviewMode/DocumentInfo(基本)/Markdown解析/Text解析/ImageMeta/Search(V1 Markdown+Text)/NoteAnchor(V1)/ReadingEvent(V1)/ReadingPosition(V1)/EventBuffer(V1基础)/iOS构建/UniFFI绑定/docs。但 V2 核心模型(ReadingSession/EventV2/ActiveTimeTracker)不存在,EventBuffer 缺 ack/failed,Position 缺 camelCase+clamp,PDF/EPUB/Office 为 stub,测试覆盖不足 V2。

本 Issue: ack 机制不存在 → 无测试。

状态: status:todo
工作类型: work:test

## 审查结论:document runtime 当前有文件类型识别/MaterialType/PreviewMode/DocumentInfo(基本)/Markdown解析/Text解析/ImageMeta/Search(V1 Markdown+Text)/NoteAnchor(V1)/ReadingEvent(V1)/ReadingPosition(V1)/EventBuffer(V1基础)/iOS构建/UniFFI绑定/docs。但 V2 核心模型(ReadingSession/EventV2/ActiveTimeTracker)不存在,EventBuffer 缺 ack/failed,Position 缺 camelCase+clamp,PDF/EPUB/Office 为 stub,测试覆盖不足 V2。 **本 Issue**: ack 机制不存在 → 无测试。 **状态**: status:todo **工作类型**: work:test
Author
Owner

完成报告

改动文件

  • crates/zx_document_core/src/events_v2.rs — 新增 2 个 buffer 生命周期测试

现有覆盖

  • test_export_ack_flow — export→ack→验证不重复导出
  • test_mark_failed_and_retry — mark_failed→retry export→ack
  • test_ack_nonexistent_no_crash — 边界 case
  • test_buffer_size_not_exceeded — 溢出驱逐

新增测试(2 个)

测试 验证内容
test_full_buffer_lifecycle push→export→验证不重复导出→partial ack e1→mark_failed e2→retry→验证 e1 已 gone 且 e2 可 retry→ack e2
test_buffer_limit_export 5 个事件,limit=2 只返回 2 个,再次 export 返回剩余 3 个

代码证据

#[test]
fn test_full_buffer_lifecycle() {
    // Step 1: push 2 events
    // Step 2: export → Exported
    // Step 3: export again → NOT re-exported
    let reexported = batch2.iter().any(|e| ...);
    assert!(!reexported, "acked events should not be re-exported");
    // Step 4: ack e1 only
    // Step 5: mark e2 failed
    // Step 6: retry → e2 re-exportable, e1 gone
    assert!(batch3.iter().any(|e| e.event_id == e2.event_id));
    assert!(!batch3.iter().any(|e| e.event_id == e1.event_id));
}

验证

cargo test events_v2 — 20 passed, 0 failed
## 完成报告 ### 改动文件 - `crates/zx_document_core/src/events_v2.rs` — 新增 2 个 buffer 生命周期测试 ### 现有覆盖 - `test_export_ack_flow` — export→ack→验证不重复导出 - `test_mark_failed_and_retry` — mark_failed→retry export→ack - `test_ack_nonexistent_no_crash` — 边界 case - `test_buffer_size_not_exceeded` — 溢出驱逐 ### 新增测试(2 个) | 测试 | 验证内容 | |---|---| | `test_full_buffer_lifecycle` | push→export→验证不重复导出→partial ack e1→mark_failed e2→retry→验证 e1 已 gone 且 e2 可 retry→ack e2 | | `test_buffer_limit_export` | 5 个事件,limit=2 只返回 2 个,再次 export 返回剩余 3 个 | ### 代码证据 ```rust #[test] fn test_full_buffer_lifecycle() { // Step 1: push 2 events // Step 2: export → Exported // Step 3: export again → NOT re-exported let reexported = batch2.iter().any(|e| ...); assert!(!reexported, "acked events should not be re-exported"); // Step 4: ack e1 only // Step 5: mark e2 failed // Step 6: retry → e2 re-exportable, e1 gone assert!(batch3.iter().any(|e| e.event_id == e2.event_id)); assert!(!batch3.iter().any(|e| e.event_id == e1.event_id)); } ``` ### 验证 ``` cargo test events_v2 — 20 passed, 0 failed ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/zhixi-document-runtime#77
No description provided.