RFC: Migrate workflow CAS to json-cas with full-closure schema design #294
Closed
opened 2026-05-17 15:57:16 +00:00 by xiaoju
·
2 comments
No Branch/Tag Specified
main
chore/migrate-ocas
retrospect/fix-committer-tea
retrospect/solve-issue-fixes
fix/517-expand-skill
fix/574-silent-fail-handling
fix/573-unify-cas-store
fix/571-current-role
fix/567-trim-leading-whitespace
fix/566-adapter-json-stdout
fix/544-remove-legacy-frontmatter
fix/553-edge-prompt-empty
fix/557-step-show-json-escape
fix/559-thread-show-status
fix/561-thread-start-cwd-option
fix/558-thread-edge-location
fix/531-config-mask-apikey
fix/532-config-key-validation
fix/533-double-prefix
fix/551-hermes-bin-engines
fix/549-commit-scope
feat/541-skill-developer
feat/539-skill-author
feat/538-skill-user
feat/540-skill-actor
fix/ci-skip-integration-tests
fix/535-sqlite-fallback
fix/531-532-533
fix/528-refactor-apikey
fix/526-config-subcommand
fix/522-cancelled-thread-status
fix/523-bin-entry-point
fix/519-read-session-file
fix/enum-multi-exit-validation
fix/remove-chinese-cli-output
feat/424-setup-agent-discovery
fix/hermes-integration-test-import
fix/449-reduce-dashboard-complexity
refactor/512-rename-packages
chore/510-open-source-readiness
chore/solve-issue-portable
fix/489-step-timing
fix/506-semantic-validation
feat/502-oneOf-output-instruction
feat/499-phase2-discriminated-union
feat/499-dollar-status
fix/497-update-docs
feat/490-phase3-dashboard
feat/490-phase2-yaml-migration
feat/490-status-routing
fix/487-refactor-step-read
fix/484-step-read-command
fix/480-thread-read-quota
fix/481-cas-has-exit-code
fix/474-tea-pr-worktree-fix
fix/469-step-commands-completed-threads
fix/473-first-time-role-context
fix/471-thread-list-filters
fix/466-continuation-prompt-content
chore/cleanup-cli-docs
fix/463-http-methods
fix/464-worktree-isolation
fix/461-per-agent-session-cache
fix/459-xml-tag-isolation
fix/444-biome-complexity-warnings
fix/456-thread-step-background
fix/448-reduce-complexity
fix/445-reduce-setup-complexity
fix/446-reduce-thread-complexity
docs/sync-readme
fix/447-reduce-loop-complexity
fix/439-detail-merge-and-acp
fix/440-thread-read-prompt-dedup
fix/builtin-session-lifecycle
debug/439-raw-ndjson-dump
fix/428-multi-strategy-workflow-resolution
fix/yaml-no-alias
feat/428-workflow-resolution
feat/turn-jsonl-session
feat/426-builtin-session-resume
fix/builtin-agent-system-user-split
feat/422-claude-code-detail-enrichment
feat/builtin-agent
test/418-resume-e2e-repro
chore/update-cli-reference
fix/413-log-subcommands
feat/411-process-logger
feat/405-phase2-find-last-role-index
feat/405-edge-prompt-required
feat/402-edge-prompt-session-resume
feat/398-hermes-acp-client
fix/395-worktree-hygiene
feat/391-workflow-agent-claude-code
jshang/workflow-dashboard
fix/394-forbid-extra-frontmatter-fields
feat/335-setup-validate-model
fix/389-dynamic-format-instruction
fix/388-frontmatter-dynamic-fields
fix/385-revert-output-protocol
feat/384-agent-session-protocol
feat/remove-llm-extract
feat/cas-put-text
fix/380-hermes-quiet-flag
feat/373-thread-step-count
fix/fallback-transition-validation
feat/376-first-last-jsonata
refactor/374-meta-to-frontmatter
feat/370-solve-issue-workflow
feat/369-uwf-skill-cli
chore/ignore-legacy-biome
feat/365-project-local-workflows
refactor/364-rename-role-fields
feat/359-role-four-phase
chore/rename-uwf-to-workflow
chore/repo-restructure
feat/357-thread-read-content
feat/355-uwf-frontmatter
feat/351-phase3-prompt-focus
feat/351-phase2-adapter-frontmatter
feat/351-frontmatter-markdown-phase1
feat/349-thread-read
fix/348-session-id-stderr
fix/342-parse-session-id
fix/342-fork-simplify
feat/342-thread-steps-fork
refactor/simplify-agent-context
refactor/pass-store-via-context
feat/337-agent-detail-merkle
feat/cas-reindex
refactor/use-list-by-type
refactor/merge-cas-get-cat
refactor/remove-table-format
fix/328-table-vertical
user/jiayiyan/feat_office-agent-document-template-v2
feat/328-format-option
fix/319-cas-json-output
fix/319-validate-schema-only-inline
fix/319-schema-titles
feat/319-uwf-cas-builtin
user/jiayiyan/feat_office-agent-document-template
feat/309-uwf-stateless
feat/285-phase3-x-cas-ref
chore/remove-old-templates
feat/294-phase7-cli
private/json-cas-refactor
feat/294-phase5-react-layer
feat/294-phase4-engine-migration
feat/294-phase3-workflow-json
feat/294-jsonata-moderator
docs/architecture-cards
feat/285-phase2-remove-extractrefs
feat/285-cas-ref-annotation
chore/fix-biome-complexity-warnings
refactor/agent-fn-required-opt
chore/audit-exports-cleanup
chore/remove-symlink-dead-code
chore/no-external-bundle
feat/show-system-prompt
chore/205-env-example
chore/biome-fix-and-pre-push-hook
chore/remove-parentRequired-param
fix/265-flaky-thread-rm
feat/workflow-detail-layout
chore/252-remove-text-adapter
feat/261-adapter-migration
feat/252-agent-fn
feat/graph-interactions
fix/dashboard-graph-side-handles
fix/dashboard-graph-visual-247
fix/cursor-agent-runtime-extract
refactor/serve-remove-http-tunnel
chore/slim-role-output
feat/changesets-version-management
chore/bump-0.4.0
chore/merge-publish-scripts
chore/remove-link-all
feat/merge-publish-scripts
fix/auto-discover-publish
refactor/dashboard-custom-spine-layout
fix/cli-bin-path
fix/dashboard-elk-review-feedback
feat/dashboard-elk-layout
fix/skill-author-pitfalls
fix/publish-lockfile-regen
feat/210-ws-gateway-phase2
refactor/thread-detail-side-by-side-layout
feat/210-ws-gateway-phase1
feat/222-tools-smoke-test-phase3
feat/222-react-adapter-phase2
feat/222-adapter-fn-phase1
fix/219-review-followup
feat/216-setup-and-build-scripts
fix/206-bundle-build-register
feat/197-agent-observability
feat/198-dashboard-workflow-graph
feat/194-merkle-call-stack-phase2
refactor/200-moderator-table
feat/194-merkle-call-stack-phase1
feat/cursor-agent-workspace-extract
fix/191-dashboard-thread-sort
feat/187-end-node-llm-summary
refactor/185-remove-max-rounds
refactor/180-simplify-extract-fn
feat/177-gateway-route-reorg
feat/172-declarative-moderator-table
fix/170-thread-status-detection
feat/164-cf-worker-gateway
fix/161-162-cas-content-refs
feat/155-cas-thread-phase-5
feat/155-cas-thread-phase-4
feat/155-cas-thread-phase-3
feat/155-cas-thread-phase-2
feat/155-cas-thread-phase-1
chore/rename-dashboard-folder
refactor/143-split-packages
feat/139-thread-reactor
refactor/runtime-descriptor-boundary
fix/128-dashboard-enhancements
fix/130-sse-incremental
fix/120-serve-hardening
feat/131-dashboard-sse
refactor/thread-context-runtime
feat/118-serve-write-sse
feat/118-dashboard
refactor/121-split-workflow-runtime
feat/118-serve-api
chore/bump-0.2.0
feat/110-phase3-supervisor
chore/114-remove-deprecated
feat/110-phase2-migrate-extract
docs/package-readmes
feat/110-phase1-config-layer
chore/108-cli-module-discipline
chore/106-workflow-module-discipline
chore/cleanup-cas-thread-id
refactor/102-module-folders
refactor/97-phase4-cleanup
refactor/96-phase3-split-dispatch
refactor/95-phase2-control-merge
chore/remove-build-scripts
refactor/93-phase1-directory-restructure
feat/91-reviewer-prompt
docs/88-readme-architecture-cleanup
fix/85-usage-format
fix/83-cli-ux
feat/81-skill-topics
fix/75-nits
refactor/75-merge-roles-phase1
refactor/71-auto-gen-skill-doc
feat/63-workflow-storage-root
feat/69-help-skill
refactor/cli-noun-verb-grouping
feat/59-solve-issue-refactor
feat/37-live-command
feat/58-develop-workflow
feat/36-init-command
feat/44-react-extract
feat/43-extract-provider-config
feat/42-thread-root-node
feat/41-merkle-content-cas
feat/33-workflow-as-agent
feat/32-cas-gc
feat/31-refs-tracking
feat/30-global-cas
feat/28-preparer-role
fix/26-planner-cas-cli-prompt
test/19-validate-workflow-descriptor
feat/23-phase-title-in-planner-meta
fix/21-moderator-coder-transition
fix/review-feedback-and-typecheck
fix/type-errors-and-tsbuildinfo
No results found.
Labels
No items
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
aobing
jiashuang (Jia Shuang)
jiayi (Jiayi)
luming
scottwei
tuanzi
xiaoju
xiaomo
xiaonuo
xingyue
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: uncaged/workflow#294
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking 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?
Summary
Replace
@uncaged/workflow-caswith@uncaged/json-casand redesign the CAS schema to achieve full-closure: workflow definitions, agent instances, thread execution, and ReAct-level traces all live in CAS as self-describing typed nodes.Key Design Decisions
Schema Design (11 types, 4 layers)
Layer 1: Definition (immutable templates)
agentAgent instance — a specific package + config combination. Reusable across threads.
package: npm package name. Convention:@uncaged/workflow-agent-*or any scope.version: semver range, resolved at runtime.config: agent-specific parameters. Schema defined by the package'sconfigSchemaexport.npm package contract:
role-schemaJSON Schema for a role's extracted meta output. Stored separately for reuse across roles/workflows.
roleRole definition — pure data, no agent binding.
Fields:
schema:cas_ref→role-schemanodeworkflowWorkflow definition — roles + JSONata moderator. No agent opinions.
Fields:
roles:Record<string, cas_ref>→ each value is arolenode hashmoderator: ordered transition rules. First matchingwhen(JSONata, evaluated against thread context) wins.null= FALLBACK (always matches).__start__and__end__are reserved names.Layer 2: Execution (per-thread)
thread-startCreated when a thread begins. Binds roles to agent instances.
Fields:
workflow:cas_ref→workflownodeparentThread:cas_ref | null→ parentthread-startfor sub-workflowsagents:Record<string, cas_ref>→ maps role name toagentinstance nodethread-stepOne completed role execution.
Fields:
content:cas_ref→contentnode (final agent output)react:cas_ref→react-sessionnode (execution trace)start:cas_ref→thread-startnodeprevious:cas_ref | null→ previousthread-step(linked list)thread-endThread completion record.
Fields:
start:cas_ref→thread-startlastStep:cas_ref→ finalthread-stepcontentGeneric text/data carrier. Used for agent output, prompts, tool args/results.
Layer 3: React (ReAct execution trace)
react-sessionA complete ReAct execution for one role step.
Fields:
agent:cas_ref→agentinstanceturns:cas_ref[]→ orderedreact-turnnodesreact-turnOne LLM call within a ReAct session.
Fields:
input:cas_ref→ promptcontentoutput:cas_ref→ responsecontenttoolCalls:cas_ref[]→react-tool-callnodesreact-tool-callOne tool invocation.
Fields:
arguments:cas_ref→contentnoderesult:cas_ref→contentnodeTraversal Example
From any
thread-step, you can reconstruct everything:Migration Path
@uncaged/json-cas+@uncaged/json-cas-fsas dependencies to workflow monorepoputSchemaworkflow-casusage inworkflow-executewithjson-casStoreworkflow-template-*moderator tables to JSONata-based workflow JSONworkflow-cas, bundle build pipelinenpm Package Convention for Agents
Each package exports
packageDescriptorandcreateAgent.小橘 🍊(NEKO Team)
Phase 拆分
基于依赖分析,从底向上迁移。每个 phase 可独立验证。
Phase 1: json-cas schema 注册
目标:在 json-cas 中注册全部 11 个 schema,验证 schema 体系自洽。
工作内容:
json-casrepo 新建packages/json-cas-workflow/→@uncaged/json-cas-workflowregisterWorkflowSchemas(store)→ 注册所有 schema,返回 type hash map验证步骤:
bun test— 11 个 schema 全部能putSchema,返回 hashput一个示例节点,validate通过validate失败cas_ref字段能被refs()正确提取walk()能沿 cas_ref 遍历完整链(thread-step → content → react-session → turns → tool-calls)Phase 2: JSONata moderator engine
目标:实现基于 JSONata 的 moderator 求值器,替代 JS 函数。
工作内容:
workflowrepo 新建或修改workflow-protocol中的 moderator 逻辑evaluateModerator(rules, context)→ role name | END[{ from, to, when: JSONata | null }]{ steps, start, threadId, ... }(与现有ModeratorContext兼容)验证步骤:
evaluateModerator正确路由__start__ → preparer → developer → submitter → __end__plannerAborted:$steps[role='planner'].meta.status = 'aborted'→ ENDallPhasesComplete: phases 比对逻辑 → reviewerreviewApproved:$steps[-1].meta.status = 'approved'→ testertestsPassed:$steps[-1].meta.status = 'passed'→ committerwhen: null)行为正确Phase 3: Workflow 定义 JSON 化
目标:将现有的 TypeScript workflow template 转为纯 JSON workflow 定义,存入 CAS。
工作内容:
workflow-template-solve-issue和workflow-template-develop转为 JSONloadWorkflow(store, workflowHash)→ 从 CAS 加载完整 workflow 定义registerWorkflow(store, workflowJson)→ 递归存入所有子节点(role-schema, role, workflow),返回 workflow hash验证步骤:
registerWorkflow,返回 hashregisterWorkflow,返回 hashloadWorkflow从 hash 还原完整 workflow(含所有 role 定义和 schema)walk(workflowHash)遍历所有 role 和 role-schema 节点Phase 4: Engine 迁移(CAS 替换)
目标:将 engine 从
workflow-cas切换到json-cas,thread 执行使用新 schema。工作内容:
workflow-execute中将CasStore类型替换为json-cas的Storethread-start(含 workflow hash + agents binding)thread-step(含 content hash + react session hash)thread-endputStartNode,putStateNode,putContentNodeWithRefs等旧函数验证步骤:
walk(threadStartHash)能遍历整个 thread 的所有节点get(stepHash) → get(reactHash) → get(turnHashes)链路完整Phase 5: React 层 instrumentation
目标:Reactor 执行过程记录为 react-session/turn/tool-call 节点。
工作内容:
workflow-reactor中的createThreadReactorreact-turn(prompt/response 存为 content 节点)react-tool-call(args/result 存为 content 节点)react-session节点react字段引用 session hash验证步骤:
walk(reactSessionHash)遍历所有 turns 和 tool-callsPhase 6: Agent 实例模型 + npm 约定
目标:定义 agent instance CAS 节点,重构 agent 包导出约定。
工作内容:
PackageDescriptortype(name, capabilities, configSchema)packageDescriptor导出createAgent(config)标准工厂导出验证步骤:
packageDescriptor和createAgentpackageDescriptor.configSchema是合法 JSON Schemarefs()正确提取Phase 7: CLI 适配 + 清理
目标:更新 CLI 命令,删除旧代码。
工作内容:
cli-workflow中替换所有workflow-cas用法json-cas-fs的 storeworkflow-cas包workflow-register中的 bundle 相关)workflow.yamlregistry 指向 CAS hash(而非 bundle hash)验证步骤:
uncaged-workflow cas list/get/put使用 json-cas storeuncaged-workflow thread show正确展示新格式的 threaduncaged-workflow workflow list/add操作 CAS 中的 workflow JSON@uncaged/workflow-casbun test全部通过Phase 依赖图
完成标准
小橘 🍊(NEKO Team)
Closing: Migration to json-cas completed
— 小橘 🍊(NEKO Team)