OPEN-58
A loop's body is the natural loop of its loopback edge, so nested loops nest.
What was open
SG-16 computed a loop's body over the forward graph alone. An inner loop whose tail feeds only its own loopback edge is then not upstream of the outer tail, so the outer body loses it, the two bodies overlap without either containing the other, and SG-18 merges them. The most common nested loop, a ForEach inside a ForEach, therefore never started its inner loop over for each outer item, unless the author added a forward edge from the inner tail to the outer tail. Even nested, it could not start over: the run state carried one iterator, which nothing reset, and SG-7's budget counted every round the inner loop had run in the whole run.
Decision
The body of a loopback edge from tail S to head H is H plus the nodes H reaches over the forward graph that a backward walk from S reaches, the walk crossing forward edges and the loopback edges that close a cycle, and entering only nodes H reaches. Crossing other loops' loopback edges is what makes a nested loop part of the loop around it. Entering only nodes H reaches is required: without it, a node that feeds a nested loop from the outer body lets the walk escape through the outer head and its loopback edge, and the outer tail falls into the inner body. A loopback edge that closes no cycle still yields its head alone, and is left out of every walk, so it cannot pull nodes into another body. A loopback edge from a head to itself closes a cycle. Edge types excluded from execution stay excluded, bodies sharing a head are still unioned. A ForEach node's iterator belongs to the node, so two ForEach nodes never share one, even where their loops merge, and a node reads the iterator of the ForEach heading its innermost loop that has one. Resetting a nested loop (SG-18) clears the iterators of the ForEach nodes in it, and its budget counts the rounds run since its round was last 0, so a ForEach inside a ForEach goes through all its items again for each outer item. Conformance cases for the key shapes are in fixtures/loops/, with a resolve-loops operation.