refactor: migrate threads index from YAML to ocas variable (Phase 4b) #17
Reference in New Issue
Block a user
Delete Branch "refactor/threads-to-ocas-variable"
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
Migrate active thread state from
threads.yamlto ocas VariableStore.Why
Phase 4b of issue #11 — the biggest piece of the data layer migration.
Variable design
@uwf/thread/<thread-id>suspendedRole,suspendMessage(only when suspended)Changes
loadAllThreads,getThread,setThread,deleteThreadloadThreadsIndex/saveThreadsIndex(full YAML read/write)thread.ts,step.ts,shared.tsworkflow-util-agent:getActiveThreadEntryreads from variable storethreads.yaml→ variables, renames to.migratedseedThread/seedThreadsVerification
bun run check✅bun run test✅Ref #11
LGTM ✅
Threads 迁移干净,核心设计合理:
新 API 清晰:
getThread/setThread/deleteThread/loadAllThreads,粒度从全量 YAML 读写降到单条 variable 操作Suspend metadata 用 tags:
suspendedRole/suspendMessage作为 variable tags 存储,比 YAML 对象嵌套更扁平迁移逻辑:与 registry 一致(检测 YAML → 导入 → rename
.migrated),在createUwfStore统一触发setThread中varStore.remove再set:注释说明了原因(head 可能是不同 schema 的 CAS node),合理Non-blocking 观察:
workflow-util-agent/storage.ts的getActiveThreadEntry每次调用创建新的createFsStore+createVariableStore,agent adapter 调用频率低所以 OK,但如果未来 agent 需要高频查询可以考虑缓存。