From bcfe0f71c409d448a6d0ccfd679a9fc19143a8b5 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 26 Sep 2026 14:05:39 +1000 Subject: [PATCH] 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. --- internal/domain/workflow/workflow_call.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/domain/workflow/workflow_call.go b/internal/domain/workflow/workflow_call.go index ac33236ce..1a96235e3 100644 --- a/internal/domain/workflow/workflow_call.go +++ b/internal/domain/workflow/workflow_call.go @@ -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