RFC: thread steps + thread fork #342

Closed
opened 2026-05-18 16:26:35 +00:00 by xiaoju · 1 comment
Owner

背景

当前 uwf thread 只有 start / step / show / list / kill,缺少:

  1. 查看 thread 执行历史(所有 step 节点)
  2. 从历史某个节点 fork 出新 thread

Phase 拆分

Phase 1: uwf thread steps <thread-id>

  • 沿 CAS 链从 head 回溯到 StartNode,列出所有步骤
  • 输出:按时间正序排列的步骤数组
  • 验证目标:能看到一个 thread 的完整执行历史
  • Testing issue: 待创建

Phase 2: uwf thread fork <thread-id> <step-hash>

  • 创建新 thread,head 指向指定的 step-hash
  • 不修改原 thread
  • 输出:{ thread: "new-id", forkedFrom: { thread: "original-id", step: "step-hash" } }
  • StartNode 中增加 forkedFrom 字段(可选)
  • 验证目标:能从历史步骤创建分支,继续 uwf thread step
  • Testing issue: 待创建

设计要点

  • fork > rollback:CAS 哲学一致,不改变原 thread 的 head 指针,两条路径都保留
  • walkChain 已有,Phase 1 主要是暴露为 CLI 命令 + 格式化输出
  • Phase 2 核心逻辑:验证 step-hash 属于目标 thread → 新建 ULID → 写 threads index

完成标准

  • 所有 Phase 的 testing issue 已 close
  • CI 通过
## 背景 当前 `uwf thread` 只有 `start / step / show / list / kill`,缺少: 1. 查看 thread 执行历史(所有 step 节点) 2. 从历史某个节点 fork 出新 thread ## Phase 拆分 ### Phase 1: `uwf thread steps <thread-id>` - 沿 CAS 链从 head 回溯到 StartNode,列出所有步骤 - 输出:按时间正序排列的步骤数组 - 验证目标:能看到一个 thread 的完整执行历史 - Testing issue: 待创建 ### Phase 2: `uwf thread fork <thread-id> <step-hash>` - 创建新 thread,head 指向指定的 step-hash - 不修改原 thread - 输出:`{ thread: "new-id", forkedFrom: { thread: "original-id", step: "step-hash" } }` - StartNode 中增加 `forkedFrom` 字段(可选) - 验证目标:能从历史步骤创建分支,继续 `uwf thread step` - Testing issue: 待创建 ## 设计要点 - **fork > rollback**:CAS 哲学一致,不改变原 thread 的 head 指针,两条路径都保留 - `walkChain` 已有,Phase 1 主要是暴露为 CLI 命令 + 格式化输出 - Phase 2 核心逻辑:验证 step-hash 属于目标 thread → 新建 ULID → 写 threads index ## 完成标准 - [ ] 所有 Phase 的 testing issue 已 close - [ ] CI 通过
Owner

验证通过 — build 成功,113 tests all pass。功能已实现并合入 main。

— 小墨 🖊️

验证通过 ✅ — build 成功,113 tests all pass。功能已实现并合入 main。 — 小墨 🖊️
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#342