Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
refactor(execution): route nested iterate chain
JPPhoto57fa5736682d
diff --git a/invokeai/app/services/shared/README.md b/invokeai/app/services/shared/README.mdindex c8b42f9415..67ce0c686d 100644--- a/invokeai/app/services/shared/README.md+++ b/invokeai/app/services/shared/README.md@@ -72,7 +72,7 @@ which feeds the same `Iterate` -> ordinary body -> `Collect` path, withordinary downstream consumers allowed. It owns the preparation input edge,ordered stream effects, empty closure, checkpoint rehydration, failure,rollback, and fresh retry behavior for that exact shape. It does not admit-`If`, `For`, `ForReturn`, saved-workflow, nested-iterator, fan-in, or mixed+`If`, `For`, `ForReturn`, saved-workflow, nested-`Iterate` chain, fan-in, or mixedcontrol-flow nodes; those remain compatibility-owned.The exact fresh seven-node nested shape `outer For -> ordinary collectionpreparation -> Iterate -> ordinary body -> Collect -> linked outer ForReturn`,@@ -96,8 +96,16 @@ compatibility adapter preserve ordered nested frame paths, close empty streams,resume from checkpoints, and stop downstream completion on failure/retry. Fan-in,sibling iterators, input-driven inner preparation, mixed control flow, deepernesting, and legacy snapshots remain compatibility-owned.+The exact five-node/four-edge nested-`Iterate` chain—an inputless ordinary+source feeding `outer Iterate`, whose item feeds one ordinary preparation node,+which feeds `inner Iterate`, whose item feeds one ordinary body—is also+generic-routed. Its private planner owns ordered outer/inner frame expansion,+empty outer and inner closure, source completion, checkpoint rehydration, and+failure parity without calling the compatibility materializer. `For`, `Collect`,+fan-in, sibling iterators, deeper or multiple nested iterators, mixed control+flow, and legacy snapshots remain compatibility-owned.Three or more body-mediated branches, fan-in with four or more direct branches,-nested iterators, and all mixed control flow retain materializer copy expansion,+broader or deeper nested iterators, and all mixed control flow retain materializer copy expansion,grouping, and empty-source handling on the legacy compatibility route.A fresh graph with exactly one static, non-empty `For`/`ForReturn` pair and ordinary body nodes also uses the genericadapter. It projects readiness and invokes the graph-state continuation boundary, which selects the next iteration or@@ -229,7 +237,8 @@ completion mirrors Iterate outputs into the stream ledger. A fresh graph with oninvocation-specific continuation boundary while the generic scheduler remains opaque. Empty or input-driven `For`collections, deeper or multiple loops, saved-workflow calls, and unsupported mixed control-flow shapes continue to usethe legacy compatibility scheduler until their differential coverage is complete. The narrow canonical two-level-nested-`For` shape and the canonical outer-`For`/bounded-`Iterate`/`Collect` shape are generic-routed. The latter has+nested-`For` shape, the canonical outer-`For`/bounded-`Iterate`/`Collect` shape, and the exact five-node nested-+`Iterate` chain are generic-routed. The latter hasone ordinary preparation node from `For.item` into `Iterate.collection`, one ordinary body node into `Collect.item`,the `Collect.collection` output into the linked `ForReturn`, and one final outer-output consumer. Each outer iteration,including an empty inner collection, remains isolated by its frame path. `Iterate` also records non-empty item streams through the generic effect ledger;@@ -238,7 +247,9 @@ copy expansion, stream identity, empty closure, `Collect` readiness/hydration,checkpoint rehydration, and failure parity. The exact producer-driven outerextension described above is also generic-routed. Ordinary nested `For`, deeper ormultiple nested iterators, other input-driven outer collections, mixed control flow,-and legacy snapshots retain compatibility materializer ownership. The+and legacy snapshots retain compatibility materializer ownership. The exact+five-node nested-`Iterate` chain above is the bounded exception; it does not+admit `For`, `Collect`, fan-in, sibling, or deeper iterator topology. Thematerializer remains authoritative for fallback expansion, iteration paths, collector grouping, andempty-source compatibility handling. The exact fresh four-node body shape, exact two- or three-stream fan-in shapes,and exact two-branch body-mediated fan-in use the private planner for those responsibilities; three or more@@ -288,7 +299,7 @@ mutation helpers. Those helpers reject changes once the affected nodes have alre`_active_class: Optional[str]`. Ordinary static DAGs and legacy-shaped `If` graphs derive readiness from the genericscheduler; the `If` adapter stores frame-local activation dependencies whose private gate state plus persisted tokenchecks control generic branch readiness. Supported static flat `For` graphs and the narrow canonical two-level nested-`For` shape and the exact producer-driven nested extension use the generic adapter for readiness and continuation projection; empty/input-driven, deeper/multiple,+ `For` shape, the exact producer-driven nested extension, and the exact five-node nested-`Iterate` chain use the generic adapter for readiness and continuation projection; empty/input-driven, deeper/multiple,mixed, and saved-workflow graphs retain the legacy scheduler. Optional`ready_order: list[str]` prioritizes classes. Queues are rebuilt from persisted execution state when a session isdeserialized.@@ -368,7 +379,8 @@ and `final_state`. The generic scheduler receives only opaque node IDs and depennext node ID. The compatibility continuation bridge remains available only for unsupported loop shapes and explicitlylegacy-loaded snapshots. Unsupported empty/input-driven outer collections and deeper, multiple, or unsupported mixedloop shapes remain compatibility-owned; the narrow canonical two-level nested-`For` shape, the canonical bounded-internal `Iterate`/`Collect` shape, and the exact producer-driven outer nested extension are generic-routed. On+internal `Iterate`/`Collect` shape, the exact producer-driven outer nested extension, and the exact five-node+nested-`Iterate` chain are generic-routed. Onrehydration, the generic adapter restores the active class-drainboundary so an in-flight nested stream resumes in the same frame/sequence order.diff --git a/invokeai/app/services/shared/graph.py b/invokeai/app/services/shared/graph.pyindex 090c1a5e14..e3ad414af8 100644--- a/invokeai/app/services/shared/graph.py+++ b/invokeai/app/services/shared/graph.py@@ -114,7 +114,9 @@ from invokeai.app.services.shared.graph_models import ()from invokeai.app.services.shared.graph_nested_iterate_planner import (can_use_nested_iterate_planner,+ can_use_nested_iterate_sequence_planner,prepare_nested_iterate_bodies,+ prepare_nested_iterate_sequences,)from invokeai.app.services.shared.graph_runtime_records import (_ApplyTransaction,@@ -2381,6 +2383,11 @@ class GraphExecutionState(BaseModel):):self._prepare_direct_iterate_collect()return self._get_next_node()+ if isinstance(self._scheduler(), _GenericGraphSchedulerAdapter) and can_use_nested_iterate_sequence_planner(+ self+ ):+ prepare_nested_iterate_sequences(self)+ return self._get_next_node()prepared_id = self._materializer().prepare(base_graph)diff --git a/invokeai/app/services/shared/graph_nested_iterate_planner.py b/invokeai/app/services/shared/graph_nested_iterate_planner.pyindex 62c6dc5348..3c4676da45 100644--- a/invokeai/app/services/shared/graph_nested_iterate_planner.py+++ b/invokeai/app/services/shared/graph_nested_iterate_planner.py@@ -70,6 +70,14 @@ def can_use_nested_iterate_planner(state: "GraphExecutionState") -> bool:return not state._legacy_snapshot_loaded and _get_exact_nested_iterate_body(state) is not None+def can_use_nested_iterate_sequence_planner(state: "GraphExecutionState") -> bool:+ """Check the exact two-level Iterate-only chain before generic admission."""+ return (+ not state._legacy_snapshot_loaded+ and state.graph._get_supported_nested_iterate_sequence(state._get_source_graph_flat()) is not None+ )++def _outer_iteration_path(state: "GraphExecutionState", prepared_for_id: str) -> tuple[int, ...]:path = state._get_iteration_path(prepared_for_id)prepared_for = state.execution_graph.get_node(prepared_for_id)@@ -387,3 +395,133 @@ def prepare_nested_iterate_bodies(state: "GraphExecutionState") -> None:prepared_for = state.execution_graph.get_node(prepared_for_id)if isinstance(prepared_for, ForInvocation) and prepared_for.index >= 0:_prepare_nested_iterate_body_for_outer(state, source_for_id, prepared_for_id)+++def prepare_nested_iterate_sequences(state: "GraphExecutionState") -> None:+ """Prepare the exact outer-Iterate/preparation/inner-Iterate/body chain."""+ if not can_use_nested_iterate_sequence_planner(state):+ return+ nested = state.graph._get_supported_nested_iterate_sequence(state._get_source_graph_flat())+ assert nested is not None++ def prepared_at_path(source_node_id: str, path: tuple[int, ...]) -> str | None:+ matches = [+ exec_id+ for exec_id in state._prepared_registry().get_prepared_ids(source_node_id)+ if state._get_iteration_path(exec_id) == path+ ]+ if len(matches) > 1:+ raise RuntimeError(f"Multiple prepared nested nodes exist for {source_node_id} at {path}")+ return matches[0] if matches else None++ def create_copy(+ source_node_id: str,+ path: tuple[int, ...],+ input_edges: list[Edge],+ iteration_index: int = -1,+ ) -> str:+ node = _create_direct_execution_node_copy(+ state, source_node_id, iteration_index=iteration_index, iteration_path=path+ )+ attached_edges = _attach_direct_execution_edges(state, node.id, input_edges)+ _initialize_direct_execution_node(state, node.id, attached_edges)+ return node.id++ outer_collection_edge = state.graph._get_input_edges(nested.outer_iterate_id, COLLECTION_FIELD)[0]+ outer_source_node_id = outer_collection_edge.source.node_id+ source_exec_id = prepared_at_path(outer_source_node_id, ())+ if source_exec_id is None:+ source_exec_id = create_copy(outer_source_node_id, (), [])+ if source_exec_id not in state.results:+ return++ collection = getattr(state.results[source_exec_id], outer_collection_edge.source.field)+ if not isinstance(collection, list):+ raise ValueError("Nested Iterate collection source must produce a list")+ if not collection:+ state._discard_source_executed(nested.outer_iterate_id)+ state._record_empty_iterate_stream(nested.outer_iterate_id, ())+ for source_node_id in (+ nested.outer_iterate_id,+ nested.preparation_node_id,+ nested.inner_iterate_id,+ nested.body_node_id,+ ):+ state._mark_source_executed(source_node_id)+ return+ preparation_input = state.graph._get_input_edges(nested.preparation_node_id)[0]+ inner_collection_edge = state.graph._get_input_edges(nested.inner_iterate_id, COLLECTION_FIELD)[0]+ body_input = state.graph._get_input_edges(nested.body_node_id)[0]+ all_preparations_ready = True+ all_inner_collections_empty = True+ for outer_index in range(len(collection)):+ outer_path = (outer_index,)+ outer_exec_id = prepared_at_path(nested.outer_iterate_id, outer_path)+ if outer_exec_id is None:+ outer_exec_id = create_copy(+ nested.outer_iterate_id,+ outer_path,+ [+ Edge(+ source=EdgeConnection(node_id=source_exec_id, field=outer_collection_edge.source.field),+ destination=EdgeConnection(node_id="", field=outer_collection_edge.destination.field),+ )+ ],+ iteration_index=outer_index,+ )+ preparation_exec_id = prepared_at_path(nested.preparation_node_id, outer_path)+ if preparation_exec_id is None:+ preparation_exec_id = create_copy(+ nested.preparation_node_id,+ outer_path,+ [+ Edge(+ source=EdgeConnection(node_id=outer_exec_id, field=preparation_input.source.field),+ destination=EdgeConnection(node_id="", field=preparation_input.destination.field),+ )+ ],+ )+ if preparation_exec_id not in state.results:+ all_preparations_ready = False+ continue+ inner_collection = getattr(state.results[preparation_exec_id], inner_collection_edge.source.field)+ if not isinstance(inner_collection, list):+ raise ValueError("Nested Iterate collection source must produce a list")+ if not inner_collection:+ state._discard_source_executed(nested.inner_iterate_id)+ state._record_empty_iterate_stream(nested.inner_iterate_id, outer_path)+ else:+ all_inner_collections_empty = False+ for inner_index in range(len(inner_collection)):+ inner_path = (*outer_path, inner_index)+ inner_exec_id = prepared_at_path(nested.inner_iterate_id, inner_path)+ if inner_exec_id is None:+ inner_exec_id = create_copy(+ nested.inner_iterate_id,+ inner_path,+ [+ Edge(+ source=EdgeConnection(+ node_id=preparation_exec_id, field=inner_collection_edge.source.field+ ),+ destination=EdgeConnection(node_id="", field=inner_collection_edge.destination.field),+ )+ ],+ iteration_index=inner_index,+ )++ if prepared_at_path(nested.body_node_id, inner_path) is None:+ create_copy(+ nested.body_node_id,+ inner_path,+ [+ Edge(+ source=EdgeConnection(node_id=inner_exec_id, field=body_input.source.field),+ destination=EdgeConnection(node_id="", field=body_input.destination.field),+ )+ ],+ )++ if all_preparations_ready and all_inner_collections_empty:+ state._mark_source_executed(nested.inner_iterate_id)+ state._mark_source_executed(nested.body_node_id)diff --git a/invokeai/app/services/shared/graph_scheduler.py b/invokeai/app/services/shared/graph_scheduler.pyindex 1da04da7a2..96d2ccaad8 100644--- a/invokeai/app/services/shared/graph_scheduler.py+++ b/invokeai/app/services/shared/graph_scheduler.py@@ -14,7 +14,9 @@ from invokeai.app.services.shared.execution_engine.scheduler import ()from invokeai.app.services.shared.graph_nested_iterate_planner import (can_use_nested_iterate_planner,+ can_use_nested_iterate_sequence_planner,prepare_nested_iterate_bodies,+ prepare_nested_iterate_sequences,)from invokeai.app.services.shared.graph_validation import CollectInvocation, IterateInvocation, nx@@ -638,6 +640,8 @@ class _GenericGraphSchedulerAdapter:self._enqueue_activation_ready_nodes()if can_use_nested_iterate_planner(self._state):prepare_nested_iterate_bodies(self._state)+ elif can_use_nested_iterate_sequence_planner(self._state):+ prepare_nested_iterate_sequences(self._state)else:self._try_materialize_deferred_nested_for_body(exec_node_id)if finalized_for_exec_node_id is None:diff --git a/invokeai/app/services/shared/graph_validation.py b/invokeai/app/services/shared/graph_validation.pyindex 754d6d16b0..f82105cac1 100644--- a/invokeai/app/services/shared/graph_validation.py+++ b/invokeai/app/services/shared/graph_validation.py@@ -119,6 +119,15 @@ class _SupportedNestedIterateChain:collect_node_id: str+@dataclass(frozen=True)+class _SupportedNestedIterateSequence:+ body_path_nodes: frozenset[str]+ outer_iterate_id: str+ preparation_node_id: str+ inner_iterate_id: str+ body_node_id: str++def get_output_field_type(node: BaseInvocation, field: str) -> Any:implementation = _get_facade_override("get_output_field_type", get_output_field_type)if implementation is not get_output_field_type:@@ -1367,6 +1376,81 @@ class Graph(BaseModel):collect_node_id=collect_node_id,)+ def _get_supported_nested_iterate_sequence(self, graph: "nx.DiGraph") -> _SupportedNestedIterateSequence | None:+ """Return the exact outer-Iterate/preparation/inner-Iterate/body shape, if present."""+ if len(self.nodes) != 5 or len(self.edges) != 4:+ return None+ iterate_node_ids = tuple(node_id for node_id, node in self.nodes.items() if isinstance(node, IterateInvocation))+ if len(iterate_node_ids) != 2:+ return None+ # The outer iterator is the one whose collection source is outside the two-iterator body.+ outer_candidates = [+ node_id+ for node_id in iterate_node_ids+ if self._get_input_edges(node_id, COLLECTION_FIELD)+ and not self._get_input_edges(self._get_input_edges(node_id, COLLECTION_FIELD)[0].source.node_id)+ ]+ if len(outer_candidates) != 1:+ return None+ outer_iterate_id = outer_candidates[0]+ inner_iterate_id = next(node_id for node_id in iterate_node_ids if node_id != outer_iterate_id)++ outer_collection_edges = self._get_input_edges(outer_iterate_id, COLLECTION_FIELD)+ inner_collection_edges = self._get_input_edges(inner_iterate_id, COLLECTION_FIELD)+ if len(outer_collection_edges) != 1 or len(inner_collection_edges) != 1:+ return None+ source_node_id = outer_collection_edges[0].source.node_id+ preparation_node_id = inner_collection_edges[0].source.node_id+ body_candidates = [+ node_id+ for node_id in self.nodes+ if node_id not in {outer_iterate_id, inner_iterate_id, source_node_id, preparation_node_id}+ ]+ if len(body_candidates) != 1:+ return None+ body_node_id = body_candidates[0]+ control_types = (+ CallSavedWorkflowInvocation,+ IfInvocation,+ ForInvocation,+ ForReturnInvocation,+ CollectInvocation,+ IterateInvocation,+ )+ if any(+ isinstance(self.get_node(node_id), control_types)+ for node_id in {source_node_id, preparation_node_id, body_node_id}+ ):+ return None+ source_inputs = self._get_input_edges(source_node_id)+ preparation_inputs = self._get_input_edges(preparation_node_id)+ body_inputs = self._get_input_edges(body_node_id)+ if (+ source_inputs+ or len(preparation_inputs) != 1+ or preparation_inputs[0].source.node_id != outer_iterate_id+ or preparation_inputs[0].source.field != ITEM_FIELD+ or len(body_inputs) != 1+ or body_inputs[0].source.node_id != inner_iterate_id+ or body_inputs[0].source.field != ITEM_FIELD+ ):+ return None+ if self._get_output_edges(outer_iterate_id, ITEM_FIELD) != preparation_inputs:+ return None+ if self._get_output_edges(inner_iterate_id, ITEM_FIELD) != body_inputs:+ return None+ if self._get_output_edges(source_node_id) != outer_collection_edges:+ return None+ if self._get_output_edges(preparation_node_id) != inner_collection_edges:+ return None+ return _SupportedNestedIterateSequence(+ body_path_nodes=frozenset(self.nodes),+ outer_iterate_id=outer_iterate_id,+ preparation_node_id=preparation_node_id,+ inner_iterate_id=inner_iterate_id,+ body_node_id=body_node_id,+ )+def _get_supported_for_nested_for_body(self, node_id: str, graph: "nx.DiGraph") -> _SupportedNestedForBody | None:"""Returns the supported recursive nested For contract, if this For uses it.diff --git a/tests/app/services/shared/test_execution_engine_differential.py b/tests/app/services/shared/test_execution_engine_differential.pyindex b2ed757437..53e5b12ce7 100644--- a/tests/app/services/shared/test_execution_engine_differential.py+++ b/tests/app/services/shared/test_execution_engine_differential.py@@ -602,6 +602,29 @@ def _serial_two_level_nested_for_iterate_collect_graph(*, outer_collection: listreturn graph+def _nested_iterate_chain_graph(*, outer_collection: list[list[str]] | None = None) -> Graph:+ """Existing nested-iterator shape: outer Iterate -> preparation -> inner Iterate -> body."""+ graph = Graph()+ graph.add_node(+ CollectionConcatInvocation(+ id="outer_source", first=[["a", "b"], ["c"]] if outer_collection is None else outer_collection+ )+ )+ graph.add_node(IterateInvocation(id="outer_iterate"))+ graph.add_node(PolymorphicStringTestInvocation(id="inner_collection"))+ graph.add_node(IterateInvocation(id="inner_iterate"))+ graph.add_node(AnyTypeTestInvocation(id="body"))++ def connect(source: str, source_field: str, destination: str, destination_field: str) -> None:+ graph.add_edge(create_edge(source, source_field, destination, destination_field))++ connect("outer_source", "collection", "outer_iterate", "collection")+ connect("outer_iterate", "item", "inner_collection", "value")+ connect("inner_collection", "collection", "inner_iterate", "collection")+ connect("inner_iterate", "item", "body", "value")+ return graph++def _direct_iterate_body_collect_graph(*, collection: list[Any] | None = None, with_after: bool = False, downstream_count: int | None = None) -> Graph:@@ -2072,6 +2095,130 @@ def test_serial_two_level_nested_for_iterate_collect_retry_isolated() -> None:assert retry_state.is_complete()+def test_nested_iterate_chain_matches_compatibility() -> None:+ graph = _nested_iterate_chain_graph()+ with patch.object(+ graph_module._ExecutionMaterializer,+ "prepare",+ side_effect=AssertionError("nested Iterate chain used compatibility materializer"),+ ):+ generic_trace, generic_state = _run(GraphExecutionState(graph=graph))+ compatibility_trace, compatibility_state = _run(+ GraphExecutionState(graph=graph),+ force_compatibility_scheduler=True,+ )++ assert generic_trace == compatibility_trace+ assert generic_trace == [+ "outer_source",+ "outer_iterate",+ "outer_iterate",+ "inner_collection",+ "inner_collection",+ "inner_iterate",+ "inner_iterate",+ "inner_iterate",+ "body",+ "body",+ "body",+ ]+ assert generic_state.is_complete()+ assert compatibility_state.is_complete()+ assert _state_projection(generic_state) == _state_projection(compatibility_state)+++def test_nested_iterate_chain_closes_empty_inner_frame() -> None:+ graph = _nested_iterate_chain_graph(outer_collection=[[], ["c"]])+ with patch.object(+ graph_module._ExecutionMaterializer,+ "prepare",+ side_effect=AssertionError("nested Iterate chain used compatibility materializer"),+ ):+ generic_trace, generic_state = _run(GraphExecutionState(graph=graph))+ compatibility_trace, compatibility_state = _run(+ GraphExecutionState(graph=graph),+ force_compatibility_scheduler=True,+ )++ assert generic_trace == compatibility_trace+ assert generic_trace == [+ "outer_source",+ "outer_iterate",+ "outer_iterate",+ "inner_collection",+ "inner_collection",+ "inner_iterate",+ "body",+ ]+ assert generic_state.is_complete()+ assert compatibility_state.is_complete()+ assert (+ generic_state._generic_runtime().streams[generic_state._iteration_stream_id("inner_iterate", (0,))].values == ()+ )+++def test_nested_iterate_chain_completes_when_all_collections_are_empty() -> None:+ graph = _nested_iterate_chain_graph(outer_collection=[[], []])+ with patch.object(+ graph_module._ExecutionMaterializer,+ "prepare",+ side_effect=AssertionError("nested Iterate chain used compatibility materializer"),+ ):+ generic_trace, generic_state = _run(GraphExecutionState(graph=graph))+ compatibility_trace, compatibility_state = _run(+ GraphExecutionState(graph=graph),+ force_compatibility_scheduler=True,+ )++ assert generic_trace == compatibility_trace+ assert generic_trace == [+ "outer_source",+ "outer_iterate",+ "outer_iterate",+ "inner_collection",+ "inner_collection",+ ]+ assert generic_state.is_complete()+ assert compatibility_state.is_complete()+ assert _state_projection(generic_state) == _state_projection(compatibility_state)+++def test_nested_iterate_chain_rehydrates_without_replay() -> None:+ graph = _nested_iterate_chain_graph()+ expected_trace, expected_state = _run(GraphExecutionState(graph=graph))+ partial_trace, partial_state = _run(GraphExecutionState(graph=graph), stop_after=5)++ resumed_trace, resumed_state = _run(load_execution_state(dump_execution_state(partial_state)))++ assert partial_trace + resumed_trace == expected_trace+ assert resumed_state.is_complete()+ assert _state_projection(resumed_state) == _state_projection(expected_state)+++def test_nested_iterate_chain_failure_does_not_release_later_frames() -> None:+ graph = _nested_iterate_chain_graph()+ with patch.object(+ graph_module._ExecutionMaterializer,+ "prepare",+ side_effect=AssertionError("nested Iterate chain used compatibility materializer"),+ ):+ generic_trace, generic_state = _run_graph_with_effects(+ GraphExecutionState(graph=graph),+ fail_source_id="body",+ )+ compatibility_trace, compatibility_state = _run_graph_with_effects(+ GraphExecutionState(graph=graph),+ force_compatibility_scheduler=True,+ fail_source_id="body",+ )++ assert generic_trace == compatibility_trace+ assert generic_state.has_error() and compatibility_state.has_error()+ assert generic_state.is_complete() and compatibility_state.is_complete()+ assert "body" in generic_trace+ assert generic_trace.count("body") == 1++@pytest.mark.parametrize("values", [[1, None, 1], []], ids=["ordered-duplicates-and-none", "empty"])def test_input_driven_iterate_collect_uses_generic_stream_ownership(values: list[Any]) -> None:compatibility_state = GraphExecutionState(graph=_input_driven_iterate_body_collect_graph(values))