fix(graph): handle loop body steps in graph traversal#348
Merged
Conversation
- `internal/domain/workflow/graph.go`: Add loop body and on_complete awareness to NextDefaultStep, ExecutionOrder, and GetTransitions - `internal/domain/workflow/graph_test.go`: Add 202 lines of tests for for_each/while loop graph traversal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExecutionOrderskipped body steps entirely andNextDefaultStepignoredLoop.OnComplete, causing incorrect step ordering and reachability analysis forfor_each/whileworkflows.ExecutionOrdernow inlines loop body steps immediately after the loop step before advancing toon_complete, matching actual runtime execution order.NextDefaultStepnow prefersLoop.OnCompleteoverOnSuccessas the default continuation target for loop steps, withOnSuccessretained as fallback whenon_completeis absent.GetTransitionsnow emits body step names andon_completeas outbound edges for loop steps, so reachability analysis (FindReachableStates) correctly marks body steps and post-loop targets as reachable.Changes
Graph Traversal
internal/domain/workflow/graph.go: ExtendNextDefaultStepto checkLoop.OnCompletebeforeOnSuccess; extendExecutionOrderto inline loop body steps; extendGetTransitionsto include loop body references andon_completeas outbound edges.Tests
internal/domain/workflow/graph_test.go: Add 7 tests coveringGetTransitionsforfor_eachandwhilesteps,NextDefaultStepwith and withouton_complete,ExecutionOrderfor both loop types with body steps, andFindReachableStatesreachability through loop bodies andon_complete.Test plan
make test-unitand confirm all new graph tests pass with zero failuresmake test-raceto verify no data races in graph traversal under concurrent accessfor_eachworkflow with body steps:awf validate <workflow>should report no unreachable stepsawf run <for_each_workflow>and confirm body steps execute in the declared order before advancing toon_completeGenerated with awf commit workflow