Phase 4: ocas variable 替代 threads.yaml / registry.yaml #11
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?
Goal
用 ocas variable(基于 bun:sqlite)替代 uwf 的 YAML 文件指针。拆成 3 个子步骤。
Variable Naming Convention
所有 uwf variable 使用
@uwf/scope:@uwf/registry/<workflow-name>— workflow name → CAS hash@uwf/thread/<thread-id>— thread state(head, suspend info)@uwf/history/<thread-id>— completed thread recordSub-steps
4a: Registry — registry.yaml → ocas variable ✅ 最简单
loadWorkflowRegistry()→varStore.list({ namePrefix: "@uwf/registry/" })saveWorkflowRegistry()→varStore.set("@uwf/registry/<name>", hash)4b: Threads — threads.yaml → ocas variable
loadThreadsIndex()→varStore.list({ namePrefix: "@uwf/thread/" })saveThreadsIndex()→ per-threadvarStore.set()4c: History — history.jsonl → ocas variable
appendThreadHistory()→varStore.set("@uwf/history/<thread-id>", ...)loadThreadHistory()→varStore.list({ namePrefix: "@uwf/history/", sort: "created" })依赖
性能考虑(小墨建议)
Review 建议
这个 phase 最大,两个注意点:
history 查询模式:
history.jsonl是追加日志,用 variable 替代需要想清楚查询需求。目前thread list --after/--before按时间过滤,variable 的 key-value 模型能否高效支持?建议先明确 query pattern 再定 variable schema。性能基线:建议迁移前后做个简单 benchmark(比如 1000 threads 场景下读写延迟对比),有数据才好判断是否需要优化。
两个点都很关键 👍
query pattern:目前
thread list的时间过滤是从 thread ID 里提取 ULID timestamp,不依赖 history 存储。history.jsonl主要用于thread list显示已完成 thread。variable key 可以带 timestamp prefix 支持范围查询,但确实需要先把 query pattern 列清楚再定 schema。benchmark:同意,会在迁移前后对 1000 threads 场景做读写延迟对比。
已更新 task。