-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Introduce conditional logic to the Yantra::Workflow#run DSL to allow steps or entire downstream branches, which are defined and persisted initially, to be either skipped or pruned (deleted) based on runtime conditions evaluated after prerequisite steps complete. This could be implemented via new options like run_if: ->(outputs) { condition } or if_condition: ->(outputs) { condition }, condition_mode: :skip | :prune. The primary motivation is to avoid executing unnecessary steps in patterns like "try batch, fallback to individual", and optionally remove their persisted records (prune mode) to keep the database clean. Implementation requires storing the condition, evaluating it when prerequisites finish (using parent outputs or workflow globals), and triggering new orchestration logic to either update the state of descendant steps to skipped or initiate a bulk deletion (pruning) of the descendant step records and their dependencies. This feature needs careful consideration regarding how skipped/pruned steps affect downstream dependencies, especially finalizer steps.