IOS-INFO-003 P0 | 定义 ReadingRuntimeAdapter 协议 【审计: 不存在】 #69

Closed
opened 2026-06-07 11:55:21 +08:00 by wangdl · 1 comment
Owner

审查

当前 V1 Collector 散落在阅读页,open/close 被注释。需抽象 adapter。

协议

protocol ReadingRuntimeAdapter {
    func startSession(context:) throws -> ReadingRuntimeSession
    func pause/resume/close(session:) throws
    func pushOpened/pushHeartbeat/pushPositionChanged/pushMarkedAsRead
    func exportEvents(limit:) throws -> [RuntimeReadingEvent]
    func ackEvents/markEventsFailed(eventIds:) throws
}

实现

ReadingRuntimeV2Adapter / ReadingRuntimeV1Adapter(deprecated) / NoopAdapter

## 审查 当前 V1 Collector 散落在阅读页,open/close 被注释。需抽象 adapter。 ## 协议 ```swift protocol ReadingRuntimeAdapter { func startSession(context:) throws -> ReadingRuntimeSession func pause/resume/close(session:) throws func pushOpened/pushHeartbeat/pushPositionChanged/pushMarkedAsRead func exportEvents(limit:) throws -> [RuntimeReadingEvent] func ackEvents/markEventsFailed(eventIds:) throws } ``` ## 实现 ReadingRuntimeV2Adapter / ReadingRuntimeV1Adapter(deprecated) / NoopAdapter
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-07 11:55:21 +08:00
wangdl changed title from IOS-INFO-003 P0 | 接入 document runtime V2 FFI to IOS-INFO-003 P0 | 定义 ReadingRuntimeAdapter 协议 【审计: 不存在】 2026-06-07 12:10:01 +08:00
Author
Owner

完成报告

交付

Core/Services/ReadingRuntimeAdapter.swift:

protocol ReadingRuntimeAdapter {
    // Session
    func startSession(material: ReadingMaterialRef, ts: Int64) throws -> String
    func pauseSession(_ id: String) throws
    func resumeSession(_ id: String) throws
    func closeSession(_ id: String) throws

    // Events (5 types)
    func pushOpened(sessionId:, materialId:, ts:) throws -> ReadingEventV2
    func pushClosed(sessionId:, materialId:, delta:, ts:) throws -> ReadingEventV2
    func pushPositionChanged(sessionId:, materialId:, position:, ts:) throws -> ReadingEventV2
    func pushHeartbeat(sessionId:, materialId:, delta:, position:, ts:) throws -> ReadingEventV2
    func pushMarkedAsRead(sessionId:, materialId:, ts:) throws -> ReadingEventV2

    // Buffer
    func exportEvents(limit:, ts:) -> [ReadingEventV2]
    func ackEvents(_ ids: [String]) -> UInt32
    func markFailed(_ ids: [String]) -> UInt32
    func reloadStaleEvents() -> UInt32
    func cleanupStaleSessions(nowMs:, maxAgeMs:) -> UInt32
}

默认实现: RustReadingRuntimeAdapter — 直接映射 Rust FFI 函数。
用途: Reader View 通过 adapter 调用 Rust,不直接依赖 uniffi 生成的函数名。

## 完成报告 ### 交付 `Core/Services/ReadingRuntimeAdapter.swift`: ```swift protocol ReadingRuntimeAdapter { // Session func startSession(material: ReadingMaterialRef, ts: Int64) throws -> String func pauseSession(_ id: String) throws func resumeSession(_ id: String) throws func closeSession(_ id: String) throws // Events (5 types) func pushOpened(sessionId:, materialId:, ts:) throws -> ReadingEventV2 func pushClosed(sessionId:, materialId:, delta:, ts:) throws -> ReadingEventV2 func pushPositionChanged(sessionId:, materialId:, position:, ts:) throws -> ReadingEventV2 func pushHeartbeat(sessionId:, materialId:, delta:, position:, ts:) throws -> ReadingEventV2 func pushMarkedAsRead(sessionId:, materialId:, ts:) throws -> ReadingEventV2 // Buffer func exportEvents(limit:, ts:) -> [ReadingEventV2] func ackEvents(_ ids: [String]) -> UInt32 func markFailed(_ ids: [String]) -> UInt32 func reloadStaleEvents() -> UInt32 func cleanupStaleSessions(nowMs:, maxAgeMs:) -> UInt32 } ``` **默认实现:** `RustReadingRuntimeAdapter` — 直接映射 Rust FFI 函数。 **用途:** Reader View 通过 adapter 调用 Rust,不直接依赖 uniffi 生成的函数名。
Sign in to join this conversation.
No description provided.