Phase 1 Testing: Workflow schema registration (@uncaged/json-cas-workflow) #7
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
验证目标
在 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 extractionrole— { 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测试步骤
Step 1: 全部 11 个 schema 注册成功
registerWorkflowSchemas(store)返回 11 个 hash,均为 13-char Crockford Base32Step 2: 示例节点 put + validate
用每个 schema 的 type hash put 一个示例节点,
validate(store, node)全部通过Step 3: 非法 payload 被拒绝
故意传错误 payload(缺字段、类型错),
validate返回 falseStep 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