Phase 1 Testing: Workflow schema registration (@uncaged/json-cas-workflow) #7

Closed
opened 2026-05-18 02:02:58 +00:00 by xiaoju · 0 comments
Owner

验证目标

在 json-cas 中注册全部 11 个 workflow schema,验证 schema 体系自洽。

前置

json-cas core + fs + cli 已完成(Phase 1-4 of #1)

工作内容

新建 packages/json-cas-workflow/@uncaged/json-cas-workflow

定义 11 个 JSON Schema + TypeScript types:

定义层 (4):

  • agent — { package, version, config }
  • role-schema — JSON Schema for role meta extraction
  • role — { name, description, systemPrompt, extractPrompt, schema: cas_ref }
  • workflow — { name, description, roles: Record<string, cas_ref>, moderator: [{ from, to, when }] }

执行层 (4):

  • thread-start — { workflow: cas_ref, input, depth, parentThread: cas_ref|null, agents: Record<string, cas_ref> }
  • thread-step — { role, meta, content: cas_ref, react: cas_ref, start: cas_ref, previous: cas_ref|null }
  • thread-end — { returnCode, summary, start: cas_ref, lastStep: cas_ref }
  • content — { text: string }

React 层 (3):

  • react-session — { agent: cas_ref, role, turns: cas_ref[], totalTokens, durationMs }
  • react-turn — { input: cas_ref, output: cas_ref, toolCalls: cas_ref[], tokens: { input, output }, latencyMs }
  • react-tool-call — { name, arguments: cas_ref, result: cas_ref, durationMs }

导出:

  • registerWorkflowSchemas(store) → 注册所有 schema,返回 { agent: Hash, role: Hash, ... } type hash map
  • TypeScript type for each schema's payload

测试步骤

  • Step 1: 全部 11 个 schema 注册成功
    registerWorkflowSchemas(store) 返回 11 个 hash,均为 13-char Crockford Base32

  • Step 2: 示例节点 put + validate
    用每个 schema 的 type hash put 一个示例节点,validate(store, node) 全部通过

  • Step 3: 非法 payload 被拒绝
    故意传错误 payload(缺字段、类型错),validate 返回 false

  • Step 4: cas_ref 提取正确
    对含 cas_ref 字段的节点调用 refs(store, node),返回正确的 hash 列表(跳过 null)

  • Step 5: 完整 DAG 遍历
    构造一条完整链:thread-start → thread-step → content + react-session → react-turn → react-tool-call
    walk(store, threadStartHash) 遍历所有节点

  • Step 6: 幂等注册
    两次调用 registerWorkflowSchemas → 返回相同 hash map

验证完成标准

所有 checkbox 打勾
bun test 全过
biome check 无 error

Ref: uncaged/workflow#294

## 验证目标 在 json-cas 中注册全部 11 个 workflow schema,验证 schema 体系自洽。 ## 前置 json-cas core + fs + cli 已完成(Phase 1-4 of #1) ## 工作内容 新建 `packages/json-cas-workflow/` → `@uncaged/json-cas-workflow` 定义 11 个 JSON Schema + TypeScript types: **定义层 (4)**: - `agent` — { package, version, config } - `role-schema` — JSON Schema for role meta extraction - `role` — { name, description, systemPrompt, extractPrompt, schema: cas_ref } - `workflow` — { name, description, roles: Record<string, cas_ref>, moderator: [{ from, to, when }] } **执行层 (4)**: - `thread-start` — { workflow: cas_ref, input, depth, parentThread: cas_ref|null, agents: Record<string, cas_ref> } - `thread-step` — { role, meta, content: cas_ref, react: cas_ref, start: cas_ref, previous: cas_ref|null } - `thread-end` — { returnCode, summary, start: cas_ref, lastStep: cas_ref } - `content` — { text: string } **React 层 (3)**: - `react-session` — { agent: cas_ref, role, turns: cas_ref[], totalTokens, durationMs } - `react-turn` — { input: cas_ref, output: cas_ref, toolCalls: cas_ref[], tokens: { input, output }, latencyMs } - `react-tool-call` — { name, arguments: cas_ref, result: cas_ref, durationMs } 导出: - `registerWorkflowSchemas(store)` → 注册所有 schema,返回 `{ agent: Hash, role: Hash, ... }` type hash map - TypeScript type for each schema's payload ## 测试步骤 - [ ] **Step 1: 全部 11 个 schema 注册成功** `registerWorkflowSchemas(store)` 返回 11 个 hash,均为 13-char Crockford Base32 - [ ] **Step 2: 示例节点 put + validate** 用每个 schema 的 type hash put 一个示例节点,`validate(store, node)` 全部通过 - [ ] **Step 3: 非法 payload 被拒绝** 故意传错误 payload(缺字段、类型错),`validate` 返回 false - [ ] **Step 4: cas_ref 提取正确** 对含 cas_ref 字段的节点调用 `refs(store, node)`,返回正确的 hash 列表(跳过 null) - [ ] **Step 5: 完整 DAG 遍历** 构造一条完整链:thread-start → thread-step → content + react-session → react-turn → react-tool-call `walk(store, threadStartHash)` 遍历所有节点 - [ ] **Step 6: 幂等注册** 两次调用 `registerWorkflowSchemas` → 返回相同 hash map ## 验证完成标准 ✅ 所有 checkbox 打勾 ✅ `bun test` 全过 ✅ biome check 无 error Ref: uncaged/workflow#294
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#7