feat: add collectCasRefs — schema-level CAS ref annotation (Phase 1) #288
Reference in New Issue
Block a user
Delete Branch "feat/285-cas-ref-annotation"
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
Add
collectCasRefs(schema, meta)function that extracts CAS hash references from Zod v4 schemas annotated with.meta({ casRef: true }).Why
Replace manual
extractRefsfunctions on RoleDefinition with declarative schema annotations. This is Phase 1 of RFC #285 — moving WorkflowDefinition closer to pure data.Changes
packages/workflow-runtime/src/collect-cas-refs.ts— new function, recursively walks Zod schema (object, array, union, nullable/optional) collecting annotated string valuespackages/workflow-runtime/src/index.ts— export collectCasRefspackages/workflow-runtime/__tests__/collect-cas-refs.test.ts— 8 test cases (flat, nested array, discriminatedUnion, null, mixed)Testing
All 8 steps in #286 verified ✅
Refs #285, addresses #286
Replaces manual extractRefs functions with declarative schema-level casRef annotations. Walks Zod v4 schemas recursively, collecting string values from fields marked with .meta({ casRef: true }). Supports: objects, arrays, discriminatedUnion, nullable/optional. 8/8 test cases pass (flat, nested, union, null, mixed). Refs #285, addresses #286LGTM ✅ Zod v4
meta({ casRef: true })+ 递归 schema walker,覆盖 object/array/union/nullable/optional/default/pipe 等所有 wrapper 类型。测试 7 个场景全面。0133adc8afto93b7947d7c