feat: uwf — Stateless Workflow CLI #317
Reference in New Issue
Block a user
Delete Branch "feat/309-uwf-stateless"
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
Implements the stateless workflow CLI (
uwf) as described indocs/wf-stateless-design.md. Workflow is pure data (CAS nodes), execution is single-step atomic, agents are pluggable external commands.Why
Simplify the 18-package workflow engine into a minimal, composable CLI. No daemon, no AsyncGenerator, no dashboard — just CAS + YAML + shell.
New Packages (6)
@uncaged/uwf-protocol@uncaged/uwf-moderator@uncaged/cli-uwfuwfCLI — workflow + thread commands@uncaged/uwf-agent-kit@uncaged/uwf-agent-hermesCLI Commands
E2E Verified
Bug Fixed During Testing
CAS store in-memory cache didn't see nodes written by agent subprocess → reload store after spawn.
Ref
Fixes #309
Refs #310 #311 #312 #313 #314 #315 #316
Code Review — REQUEST_CHANGES
架构很好:CAS-backed 不可变 thread chain + JSONata condition engine,优雅简洁。主要问题在代码重复和一个竞态条件。
🔴 Critical
Race condition on
threads.yaml(cli-uwf/src/commands/thread.ts)cmdThreadStep在 spawn agent 前 load index,agent 执行完后写回的是 stale object。如果并发有其他进程修改 threads.yaml,数据会丢失。loadThreadsIndex,再更新保存。evaluateJsonata未 await (uwf-moderator/src/evaluate.ts:24)jsonata().evaluate()可能返回 Promise(async 表达式)。当前同步调用不会报错但会导致条件判断错误(Promise object 是 truthy)。resolveWorkflowHash永远不返回 null (cli-uwf/src/store.ts:103-108)thread.ts:63的 null check 是 dead code。实际运行时不会出错(后续isCasRef兜住了),但代码意图不清晰。⚠️ Warnings
大量代码重复:
cli-uwf/src/store.ts和uwf-agent-kit/src/storage.ts共享resolveStorageRoot、getDefaultStorageRoot、getCasDir、loadThreadsIndex等函���。建议提取到uwf-protocol或新建uwf-storage包。Chain walking 逻辑重复:
cli-uwf/thread.ts和uwf-agent-kit/context.ts各有一份walkChain。Schema 注册重复:
cli-uwf/schemas.ts和uwf-agent-kit/schemas.ts几乎相同。Commander
--alloption 类型不匹配:不传时返回undefined而非false,但类型标为boolean。加 default 或改类型。cli-uwf依赖uwf-agent-kit:CLI 依赖 agent-kit 加载 config,循环关注点。共享 config 应在独立包。💡 Suggestions
cli-uwf/src/commands/缺index.ts(folder module discipline)uwf-moderator自定义Result类型,可复用uwf-protocol的✅ Looks Good
小墨 🖊️
3 Critical 已确认修复:
LGTM 🖊️