Skip to content

Runtime 读模型契约

Read model 是 UI hydration、sidebars、tabs、timeline 和 evidence review 的性能边界。

ThreadReadModel

json
{
  "schemaVersion": "0.1",
  "runtimeId": "lime_runtime_local",
  "sessionId": "sess_123",
  "threadId": "thread_123",
  "status": "running",
  "activeTurnId": "turn_123",
  "pendingActions": [],
  "toolCalls": [],
  "queuedTurns": [],
  "incidents": [],
  "diagnostics": [],
  "lastOutcome": null,
  "historyCursor": "cursor_123"
}

要求

要求原因
有 schema version 和 correlation ids让 UI、evidence、review 可 join。
有 current status 和 active turn支持恢复 active run。
pending actions 独立列出不靠遍历历史找审批卡片。
tool calls 有 summary/ref不阻塞首屏。
history cursor 明确支持 timeline pagination。
incidents/diagnostics 分离不污染用户正文。

SessionSnapshot

应包含 session shell、threads、recent messages/process refs、task summary、artifact/evidence summary 和 recovery cursor。

TaskSnapshot

应包含 objective、status、current run、attempts、parent/dependency edges、progress、outputs、artifacts、evidence refs 与 delivery state。

json
{
  "schemaVersion": "0.1",
  "runtimeId": "lime_runtime_local",
  "sessionId": "sess_123",
  "taskId": "task_123",
  "objective": "生成内容包",
  "status": "running",
  "parentTaskId": null,
  "currentRunId": "run_123",
  "attemptIds": ["attempt_1"],
  "dependencies": [],
  "subagents": [],
  "progress": {
    "completedSteps": 2,
    "totalSteps": 5
  },
  "artifactRefs": [],
  "evidenceRefs": [],
  "eventCursor": "evt_124"
}

SubagentSnapshot

多执行实体必须进入 TaskSnapshot 或相关 read model,不能只靠临时事件流恢复。

字段要求
subagentId子代理稳定 identity。
taskId所属任务。
parentTaskId / parentRunIdlineage,缺失时必须标 degraded。
roleplanner、researcher、writer、reviewer、executor 或 custom。
statusqueued、running、waiting、completed、failed、cancelled。
channelIds协作通道引用。
artifactRefs / evidenceRefs子代理交付与证据引用。

完整语义见 Subagents 标准

Hydration 流程

text
readThread/readTask
  -> hydrate ProjectionState
  -> subscribe RuntimeEvent
  -> apply events by sequence
  -> detect gap
  -> mark stale
  -> read model repair
  -> reconcile projection

Projection 可以从 read model 恢复可见状态,但 read model 不是 event stream 的替代品。恢复完成后,后续事实仍应继续从 RuntimeEvent 进入。

Snapshot reconciliation

情况必需行为
event stream 完整按 event apply,read model 只作首屏和分页辅助。
sequence gapProjection 标记 stale,client 读取 read model repair。
final text 与 delta 不一致model.completed 或 read model final part 修正,不重复追加。
pending action 已解决必须看到 action.resolved 或 read model pending list 移除。
artifact/evidence ref 缺失标记 degraded,不从正文猜测 ref。

降级状态

Read model 可以标记 stalerepairingunavailable,但不能返回看似完整的假数据。

Lime Agent Workbench 是面向 Lime AgentRuntime 与 AgentUI 的治理优先标准。