Skip to content

Conformance

Conformance 用来证明一个 runtime provider、projection reducer 或 React surface 符合 Lime Agent Workbench 标准。它不是截图检查,也不是“能聊一句话”。

包级职责

必须提供
@limecloud/agent-ui-contractsschemas、fixtures、version helpers、validation errors。
@limecloud/agent-runtime-projectionreplay runner、idempotency assertions、selector snapshots。
@limecloud/agent-runtime-uisurface render fixtures、callback contract tests。
@limecloud/agent-runtime-clienttransport contract tests、error mapping、mock-free production assertions。

Fixture 格式

ts
export interface AgentUiFixture {
  id: string;
  schemaVersion: string;
  title: string;
  events: RuntimeEvent[];
  initialReadModel?: ThreadReadModel;
  finalReadModel?: ThreadReadModel;
  expected: {
    status: string;
    messagePartCount?: number;
    timelineEntryCount?: number;
    graphNodeCount?: number;
    pendingActionCount?: number;
    artifactCount?: number;
    evidenceCount?: number;
    teamWorkbench?: {
      hasTeamSurface?: boolean;
      rosterNodeCount?: number;
      workItemCount?: number;
      handoffEventCount?: number;
      reviewEventCount?: number;
      laneEventCount?: number;
    };
    diagnostics?: string[];
  };
}

Fixture 只保存 normalized facts。原生 Provider payload 必须放在 refs.kind="raw" 或 diagnostics ref 中,且不能包含 secret。

必需 fixture

Fixture覆盖
text-basiclifecycle、stream delta、final reconciliation、snapshot completed。
tool-successtool args、progress、result、output ref、timeline。
tool-failurefailure category、diagnostic、recovery action。
hitl-actionaction.required、waiting read model、action.resolved
artifact-evidenceartifact ref、evidence ref、review/replay correlation。
stream-repairsequence gap、stale、read model repair、text 不重复。
subagent-handoffparent task、child subagent、channel、handoff、review verdict。

Replay runner

ts
const result = replayAgentUiFixture(fixture, {
  projector: createAgentUiProjector(),
  validateSchema: true
});

expect(result.state).toMatchProjectionSnapshot(fixture.expected);
expect(result.diagnostics).toHaveNoUnexpectedFailures();

Replay runner 必须检查:

  1. eventId 幂等。
  2. sequence 单调或进入 repair/degraded。
  3. final text 不重复追加。
  4. missing ids 不升级为 completed。
  5. large output 通过 refs 表达。
  6. read model 可以修复 active projection。

Schema validation

contracts 包至少提供:

ts
export function validateRuntimeEvent(input: unknown): RuntimeEvent;
export function validateThreadReadModel(input: unknown): ThreadReadModel;
export function validateProjectionState(input: unknown): ProjectionState;

Validation error 要能分类:

Error code含义
schema_mismatch字段类型或必需字段不匹配。
missing_scope_idtool/action/artifact/evidence/subagent 缺少领域 id。
sequence_gapevent stream 有缺口,需要 repair。
secret_leak_riskpayload 疑似包含 secret。
large_payload_inline大输出内联到 event。
unknown_event_typeprovider 输出未注册 event family。

Runtime client conformance

Runtime client 的 transport tests 必须覆盖:

场景要求
Host bridge readystartTurn -> subscribeEvents -> readThread 成功。
Provider not ready返回 provider_not_ready,不读取产品应用 local key。
Stream interrupted抛出 stream_interrupted 或标记 stale,不切 mock。
Action responserespondAction 后等待 runtime fact,不乐观改状态。
Evidence exportexportEvidence 返回 EvidenceRefView,并保留 correlation ids。
Production no mockproduction transport 不依赖 fixture replay。

Runtime client 只证明 transport、read/action/evidence facade 和错误模型。它不能生成 AgentUiProjectionState,也不能在缺少 App Server stream 时切到 fixture replay。

Projection conformance

Projection replay 必须覆盖标准 surface 字段:

Surface field必须断言
messagesUIMessageParts 按 message scope 合并,final text 不重复。
timelineProcessTimeline 按 event sequence / createdAt 稳定排序。
graphExecutionGraph 保留 turn、task、subagent、tool、action lineage。
actionsActionRequired 只来自 unresolved action facts。
artifactsArtifactRef 只保存 refs 和轻量摘要。
evidenceEvidenceRef 保留 review / replay correlation。
teamWorkbenchTeamWorkbench 必填;solo run 输出空模型,多执行体 fixture 输出 roster/work/lane counts。

React conformance

React surfaces 用 fixture projection state 渲染,不自己跑 runtime。

Surface必须断言
MessagePartstext/reasoning/tool preview 不互相污染。
ProcessTimelinetool、action、artifact、evidence 按 sequence 展示。
ExecutionGraphtask/subagent parent-child edge 可见。
ActionRequired点击只调用 callback,不本地标记 resolved。
Artifact / Evidence lane只展示 refs,不复制大 payload。
TeamWorkbench只读取 state.teamWorkbench,不在组件内重建 roster、work board 或 handoff lane。
Diagnosticsunknown/unavailable/stale/blocked 可见。

Definition of Done

一个 SDK 切片进入 current 前,必须满足:

  1. schema validation 通过。
  2. fixture replay 通过。
  3. projection reducer 有幂等和 repair 测试。
  4. React surfaces 只消费 projection state。
  5. runtime client transport 不回退 mock。
  6. 文档写清 current / compat / deprecated / dead。

CI 建议

bash
npm run test:contracts
npm --prefix packages/agent-ui-contracts run test
npm --prefix packages/agent-runtime-projection run test
npm --prefix packages/agent-runtime-ui run test

命令名称可按 Lime 主仓实际脚本调整,但四类检查必须存在:contract、fixture replay、projection reducer、React surface。

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