MCPcopy Create free account
hub / github.com/github/gh-aw / containsStatusFunc

Function containsStatusFunc

pkg/workflow/expression_optimizer.go:128–145  ·  view source on GitHub ↗

containsStatusFunc returns true when any node in the tree is a status function. Used to gate complement / idempotent rules that must not fire on expressions containing status functions.

(node ConditionNode)

Source from the content-addressed store, hash-verified

126// Used to gate complement / idempotent rules that must not fire on expressions
127// containing status functions.
128func containsStatusFunc(node ConditionNode) bool {
129 if isStatusFunc(node) {
130 return true
131 }
132 switch n := node.(type) {
133 case *AndNode:
134 return containsStatusFunc(n.Left) || containsStatusFunc(n.Right)
135 case *OrNode:
136 return containsStatusFunc(n.Left) || containsStatusFunc(n.Right)
137 case *NotNode:
138 return containsStatusFunc(n.Child)
139 case *DisjunctionNode:
140 return slices.ContainsFunc(n.Terms, containsStatusFunc)
141 case *FunctionCallNode:
142 return slices.ContainsFunc(n.Arguments, containsStatusFunc)
143 }
144 return false
145}
146
147// collectOrTerms recursively flattens a chain of OrNode / DisjunctionNode into
148// a flat slice of leaf terms. This allows the DisjunctionNode optimiser (which

Callers 4

termSubsumedByFunction · 0.85
optimizeOrNodeFunction · 0.85
optimizeNotNodeFunction · 0.85
TestContainsStatusFuncFunction · 0.85

Calls 1

isStatusFuncFunction · 0.85

Tested by 1

TestContainsStatusFuncFunction · 0.68