jason810496 opened a new pull request, #73443:
URL: https://github.com/apache/airflow/pull/73443

   # TS SDK: add conditional branching with dag.if
   
   - **Depends on the PR for `feature/ts-sdk/answer-dag-parse-request` getting 
merged first** (only the last commit is new here).
   - **Diff for early review**: 
https://github.com/jason810496/airflow/compare/feature/ts-sdk/answer-dag-parse-request...feature/ts-sdk/conditional-branching
   - **next**: `feature/ts-sdk/multi-way-branching`
   
   ## Why
   
   `airflow-core/adr/lang-sdk/0008-control-flow-constructs.md` names each 
construct after the host language's control flow. This is TypeScript's 
`if`/`else`.
   
   ## How
   
   - `dag.if(taskId, condition, branches)` registers an ordinary task returning 
a boolean, plus the task each outcome follows.
   - Nothing about the branch reaches the Dag JSON. The control edges serialize 
as ordinary order-only edges, and which side a run takes is a run-time skip the 
SDK sends, so a guarded task takes no parameter for the control edge.
   - A one-sided `if` is a branch with a single candidate, per decisions 1 and 
3 of that ADR: it skips `then` and follows nothing, rather than 
short-circuiting the whole downstream closure.
   
   The branches travel in an options object rather than `gate.then(...)` 
chaining, which is the one place TypeScript has to differ from the Go spelling: 
an object with a callable `then` is a thenable, so a gate reaching an `await` 
would be resolved as a promise. Recorded in `ts-sdk/adr/0002`.
   
   ## What
   
   - `dag.if` and the `Branches` type.
   - `skipDownstreamTasks` on the task client, the mechanism Python reaches 
through `skip()` and `skip_all_except()`.
   
   Needs the core side to honour `SkipDownstreamTasks` from a non-Python 
runtime.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes, with help of Claude Code Opus 5 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to