Skip to content

TS SDK: Add multi-way branching with dag.switch - #74070

Merged
jason810496 merged 1 commit into
apache:mainfrom
guan404ming:ts-sdk-dag-switch
Oct 7, 2026
Merged

jason810496 merged 1 commit into
apache:mainfrom
guan404ming:ts-sdk-dag-switch

Conversation

@guan404ming

@guan404ming guan404ming commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Related

Why

  • TypeScript Dags cannot pick one of several branches yet.
  • ADR-0008 has switch take the deciding function, as Go's dag.Switch(pickPath) does.

How

  • Add dag.switch(fn, inputs).case(a).case(b), with the same arguments as dag.if.
  • Skip every case not chosen; fail the task when the choice is not a case.
  • Make a switch an edge endpoint, like a condition.

Was generative AI tooling used to co-author this PR?

@guan404ming guan404ming changed the title TS SDK: Add dag.switch taking a handler, as Go does TS SDK: Add dag.switch taking a handler Oct 2, 2026
@guan404ming
guan404ming force-pushed the ts-sdk-dag-switch branch 5 times, most recently from 3e735a2 to ed2ccb0 Compare October 2, 2026 07:47
@guan404ming guan404ming changed the title TS SDK: Add dag.switch taking a handler TS SDK: Add multi-way branching with dag.switch Oct 2, 2026
@guan404ming
guan404ming marked this pull request as ready for review October 2, 2026 07:55
@jason810496
jason810496 requested review from jason810496 and pierrejeambrun and removed request for pierrejeambrun October 2, 2026 15:34

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, only the first comment is my manual review concern.
Rest of them are caught by claude review.

Comment thread ts-sdk/src/sdk/dag.ts
Comment thread ts-sdk/src/sdk/dag.ts Outdated
Comment thread ts-sdk/src/sdk/dag.ts Outdated

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same task spec issue. LGTM beside Jason comments.

@guan404ming
guan404ming force-pushed the ts-sdk-dag-switch branch 2 times, most recently from 67ca836 to 12df997 Compare October 6, 2026 16:58
Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
@jason810496
jason810496 merged commit 874bc6c into apache:main Oct 7, 2026
88 of 89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants