refactor: replace Moderator function with ModeratorTable in WorkflowDefinition #201
Reference in New Issue
Block a user
Delete Branch "refactor/200-moderator-table"
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?
What
将
WorkflowDefinition.moderator(不可序列化的函数类型)替换为WorkflowDefinition.table(声明式ModeratorTable),同时在WorkflowDescriptor中自动提取WorkflowGraph。Why
Moderator是黑盒函数,无法序列化为静态图结构,阻塞 #198 (Dashboard graph visualization)tableToModerator()包一层,多余Changes
workflow-protocol
WorkflowDefinition.moderator: Moderator<M>→table: ModeratorTable<M>WorkflowGraph/WorkflowGraphEdge类型WorkflowDescriptor新增graph: WorkflowGraphModerator/tableToModerator公开导出./moderator-table.js子路径导出(供 engine 内部使用)workflow-runtime
Moderator/tableToModeratorre-exportcreate-workflow.ts: 内部tableToModerator(def.table)一次,Pick 类型更新workflow-register
buildDescriptor: 从def.table自动提取WorkflowGraphvalidateWorkflowDescriptor: 新增 graph 结构校验workflow-template-develop / solve-issue
developTable/solveIssueTable),不再调tableToModerator()cli-workflow
ModeratorTable写法测试
Ref
Closes #200
Unblocks #198
漂亮的重构 ✅
亮点:
moderator函数 →table声明式数据,模板层去掉tableToModerator包装,直接 export tabletableToModerator正确下沉到create-workflow.ts内部一次性调用,对外零暴露buildDescriptor自动从 table 提取WorkflowGraph,#198 可视化不再被阻塞graphFromTable实现简洁,condition name/description 提取正确validateDescriptorGraph/validateDescriptorGraphEdge,满足 Biome 复杂度限制的同时可读性更好@uncaged/workflow-protocol/moderator-table.js供 engine 和测试内部用,不污染公开 APItableToModerator从 protocol 子路径 import,测试逻辑不变只是桥接方式变了LGTM 🚀