Phase 4: ocas variable 替代 threads.yaml / registry.yaml #11

Closed
opened 2026-06-02 11:56:02 +00:00 by xingyue · 2 comments
Owner

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 record

Sub-steps

4a: Registry — registry.yaml → ocas variable 最简单

  • loadWorkflowRegistry()varStore.list({ namePrefix: "@uwf/registry/" })
  • saveWorkflowRegistry()varStore.set("@uwf/registry/<name>", hash)
  • 4 处调用,schema 简单(name → hash)
  • 启动时自动迁移旧 registry.yaml

4b: Threads — threads.yaml → ocas variable

  • loadThreadsIndex()varStore.list({ namePrefix: "@uwf/thread/" })
  • saveThreadsIndex() → per-thread varStore.set()
  • ~20 处调用,需要用 tags 存 suspend metadata
  • 关键决策:全量 load 变成 N 次查询 vs 1 次 YAML parse
  • 需要 benchmark

4c: History — history.jsonl → ocas variable

  • appendThreadHistory()varStore.set("@uwf/history/<thread-id>", ...)
  • loadThreadHistory()varStore.list({ namePrefix: "@uwf/history/", sort: "created" })
  • 时间过滤用 ULID timestamp 从 thread-id 提取,不依赖 variable 的 created 字段
  • 需要验证性能(1000 threads 场景)

依赖

  • Phase 3 完成
  • ocas variable store 稳定(v0.1.2+

性能考虑(小墨建议)

  • 迁移前后做 benchmark(1000 threads 读写延迟)
  • threads 全量 load 是热路径,要特别注意
  • SQLite 查询 vs YAML parse 不一定更快
## 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 record ## Sub-steps ### 4a: Registry — registry.yaml → ocas variable ✅ 最简单 - `loadWorkflowRegistry()` → `varStore.list({ namePrefix: "@uwf/registry/" })` - `saveWorkflowRegistry()` → `varStore.set("@uwf/registry/<name>", hash)` - 4 处调用,schema 简单(name → hash) - 启动时自动迁移旧 registry.yaml ### 4b: Threads — threads.yaml → ocas variable - `loadThreadsIndex()` → `varStore.list({ namePrefix: "@uwf/thread/" })` - `saveThreadsIndex()` → per-thread `varStore.set()` - ~20 处调用,需要用 tags 存 suspend metadata - 关键决策:全量 load 变成 N 次查询 vs 1 次 YAML parse - 需要 benchmark ### 4c: History — history.jsonl → ocas variable - `appendThreadHistory()` → `varStore.set("@uwf/history/<thread-id>", ...)` - `loadThreadHistory()` → `varStore.list({ namePrefix: "@uwf/history/", sort: "created" })` - 时间过滤用 ULID timestamp 从 thread-id 提取,不依赖 variable 的 created 字段 - 需要验证性能(1000 threads 场景) ## 依赖 - Phase 3 完成 ✅ - ocas variable store 稳定(v0.1.2+ ✅) ## 性能考虑(小墨建议) - 迁移前后做 benchmark(1000 threads 读写延迟) - threads 全量 load 是热路径,要特别注意 - SQLite 查询 vs YAML parse 不一定更快
Owner

Review 建议

这个 phase 最大,两个注意点:

  1. history 查询模式history.jsonl 是追加日志,用 variable 替代需要想清楚查询需求。目前 thread list --after/--before 按时间过滤,variable 的 key-value 模型能否高效支持?建议先明确 query pattern 再定 variable schema。

  2. 性能基线:建议迁移前后做个简单 benchmark(比如 1000 threads 场景下读写延迟对比),有数据才好判断是否需要优化。

## Review 建议 这个 phase 最大,两个注意点: 1. **history 查询模式**:`history.jsonl` 是追加日志,用 variable 替代需要想清楚查询需求。目前 `thread list --after/--before` 按时间过滤,variable 的 key-value 模型能否高效支持?建议先明确 query pattern 再定 variable schema。 2. **性能基线**:建议迁移前后做个简单 benchmark(比如 1000 threads 场景下读写延迟对比),有数据才好判断是否需要优化。
Author
Owner

两个点都很关键 👍

  1. query pattern:目前 thread list 的时间过滤是从 thread ID 里提取 ULID timestamp,不依赖 history 存储。history.jsonl 主要用于 thread list 显示已完成 thread。variable key 可以带 timestamp prefix 支持范围查询,但确实需要先把 query pattern 列清楚再定 schema。

  2. benchmark:同意,会在迁移前后对 1000 threads 场景做读写延迟对比。

已更新 task。

两个点都很关键 👍 1. **query pattern**:目前 `thread list` 的时间过滤是从 thread ID 里提取 ULID timestamp,不依赖 history 存储。`history.jsonl` 主要用于 `thread list` 显示已完成 thread。variable key 可以带 timestamp prefix 支持范围查询,但确实需要先把 query pattern 列清楚再定 schema。 2. **benchmark**:同意,会在迁移前后对 1000 threads 场景做读写延迟对比。 已更新 task。
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#11