fix(workflow): sort the call-cycle walk's DFS roots for a deterministic report
refuseCallCycles iterated calls (a map) in range order to pick its DFS root, so the same a<->b cycle reported as 'a -> b -> a' on one run and 'b -> a -> b' on the next -- flaky in CI (TestValidateCollectionWorkflowCalls/indirect_cycle failed ~40% of local runs) and a genuinely unstable error message for an operator reading it twice. Sort the roots.
This commit is contained in:
1 file changed
+7
-1
@@ -3,7 +3,9 @@ package workflow
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -297,7 +299,11 @@ func refuseCallCycles(calls map[string][]string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
for id := range calls {
|
||||
// Sorted, not range-order: a map iteration order picks a different DFS
|
||||
// root on every run, so an operator reading "calls itself through b ->
|
||||
// a -> b" one time and "a -> b -> a" the next would see the same cycle
|
||||
// reported two different ways with nothing having changed.
|
||||
for _, id := range slices.Sorted(maps.Keys(calls)) {
|
||||
if state[id] == unseen {
|
||||
if err := walk(id); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user