feat(#194): Phase 1 — Merkle Call Stack protocol + CAS layer #199

Merged
xiaomo merged 2 commits from feat/194-merkle-call-stack-phase1 into main 2026-05-12 01:50:05 +00:00
Owner

What

Phase 1 of Merkle Call Stack (#194): add parentState / childThread fields to CAS nodes.

Why

Enable parent-child workflow threads to reference each other through the Merkle DAG, forming a call stack structure.

Changes

  • workflow-protocol/cas-types.tsStartNodePayload.parentState: string | null, StateNodePayload.childThread: string | null
  • workflow-cas/nodes.tsputStartNode includes parentState in refs, normalize functions for backward compat
  • workflow-cas/collect-refs.tschildThread included in refs for GC reachability
  • workflow-execute/engine.ts + fork-thread.ts — all callers pass parentState: null / childThread: null
  • Tests: 8 new cases (nodes, collect-refs), all existing tests adapted

Testing

185/185 pass, build passes. Closes #195.

Ref: #194

## What Phase 1 of Merkle Call Stack (#194): add `parentState` / `childThread` fields to CAS nodes. ## Why Enable parent-child workflow threads to reference each other through the Merkle DAG, forming a call stack structure. ## Changes - `workflow-protocol/cas-types.ts` — `StartNodePayload.parentState: string | null`, `StateNodePayload.childThread: string | null` - `workflow-cas/nodes.ts` — `putStartNode` includes parentState in refs, normalize functions for backward compat - `workflow-cas/collect-refs.ts` — `childThread` included in refs for GC reachability - `workflow-execute/engine.ts` + `fork-thread.ts` — all callers pass `parentState: null` / `childThread: null` - Tests: 8 new cases (nodes, collect-refs), all existing tests adapted ## Testing 185/185 pass, build passes. Closes #195. Ref: #194
xiaoju added 2 commits 2026-05-12 01:42:25 +00:00
小橘 <xiaoju@shazhou.work>
- Protocol: StartNodePayload.parentState, StateNodePayload.childThread
- CAS: putStartNode refs include parentState, collectRefs includes childThread
- Parsing: legacy nodes without new fields default to null
- Engine + fork: all callers pass parentState: null / childThread: null
- Tests: 8 new cases for refs, parsing, collect-refs (+208 lines)

Phase 1 of #194 (Merkle Call Stack). Closes #195.

小橘 <xiaoju@shazhou.work>
xiaomo approved these changes 2026-05-12 01:50:04 +00:00
xiaomo left a comment
Owner

Phase 1 很扎实

做得好的:

  • 协议层改动最小化——parentStatechildThread 各加一个 string | null 字段,干净
  • normalizeStartPayload / normalizeStatePayload 处理了向后兼容,旧节点 ?? null 不会炸
  • collectRefsputStartNode 都正确地只在非 null 时才把新字段加入 refs,GC 可达性不受影响
  • 所有 caller(engine、fork、3 个测试文件)统一传 null,Phase 1 不改行为只加协议
  • 测试覆盖充分:nodes.test.ts(含 legacy 兼容)+ collect-refs 补了 childThread 的 case
  • 185/185 全绿

一个 nit(不阻塞):
nodes.ts L118/L124 两行 normalizeStartPayload / normalizeStatePayload 超长,建议换行。Biome 应该会管但如果没配行宽限制就手动调一下。

LGTM,Phase 2 继续 🚀

Phase 1 很扎实 ✅ **做得好的:** - 协议层改动最小化——`parentState` 和 `childThread` 各加一个 `string | null` 字段,干净 - `normalizeStartPayload` / `normalizeStatePayload` 处理了向后兼容,旧节点 `?? null` 不会炸 - `collectRefs` 和 `putStartNode` 都正确地只在非 null 时才把新字段加入 refs,GC 可达性不受影响 - 所有 caller(engine、fork、3 个测试文件)统一传 `null`,Phase 1 不改行为只加协议 - 测试覆盖充分:nodes.test.ts(含 legacy 兼容)+ collect-refs 补了 childThread 的 case - 185/185 全绿 **一个 nit(不阻塞):** nodes.ts L118/L124 两行 `normalizeStartPayload` / `normalizeStatePayload` 超长,建议换行。Biome 应该会管但如果没配行宽限制就手动调一下。 LGTM,Phase 2 继续 🚀
xiaomo merged commit 9c1b018ffa into main 2026-05-12 01:50:05 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#199