Skip to content

Conditional branches - #19

Open
kriben wants to merge 4 commits into
mainfrom
conditional-branches
Open

kriben wants to merge 4 commits into
mainfrom
conditional-branches

Conversation

@kriben

@kriben kriben commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #16.

Add SwitchTask/ConditionTask, when= guards and first_of() joins so a
workflow can choose a branch at run time. Tasks whose guard does not
match are skipped (TaskStatus.SKIPPED, on_task_skip hook); skips
propagate, collect() drops skipped members, and a skipped result task
fails the job with ResultTaskSkippedError.

Supported in the builder API, YAML (when:, first_of:), Mermaid (switch
diamonds, dashed guard edges), describe JSON and the editable
definition round-trip. Adds conditional_if and conditional_switch
examples and documentation.
ContextFlag is a ConditionTask that is true when the context value
under its configured key is truthy. Runner.run checks that every
configured key is registered before any task runs and raises
WorkflowDefinitionError otherwise; the CLI reports this as a
configuration error. Adds ExecutionContext.has().
…eneric switch bases

Add tests for the remaining uncovered error branches and edge cases in
conditional execution, bringing line coverage to 100%.

Fix SwitchTask label resolution so a concrete subclass of a generic
switch base (e.g. MySwitch[Literal["a", "b"]]) gets its branches and
output model; previously it silently ended up with no labels.
Register condition.compare, condition.is_true and condition.path_exists
as ready-made ConditionTasks for use in workflows and UIs.
@kriben
kriben force-pushed the conditional-branches branch from 705ac7c to c516be8 Compare October 28, 2026 11:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add possibility to conditionally switch to different branch in the workflow

1 participant