Skip to content

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.

test(execution): prove fresh If ownership boundary

JPPhoto2eaa86e9d687
diff --git a/invokeai/app/services/shared/README.md b/invokeai/app/services/shared/README.md
index 0800c04822..b4a7795443 100644
--- a/invokeai/app/services/shared/README.md
+++ b/invokeai/app/services/shared/README.md
@@ -17,7 +17,7 @@ dependencies in `GraphExecutionState`; unsupported fresh shapes use the compatib
Current fresh sibling support includes exactly four independent `If`s with no nesting, fan-out, or other control-flow
nodes. The bounded three-`If` chain requires direct `default` edges, all three `If`s to have `condition`, `true_input`,
and `false_input` inputs, and inner/middle `If`s to have no output except their direct nested branch edge. Four or more
-nested `If`s, fan-out, mixed, loop-containing, saved-workflow, legacy, and five-or-more sibling shapes remain on the
+nested `If`s, other fan-out, mixed, loop-containing, saved-workflow, legacy, and five-or-more sibling shapes remain on the
compatibility fallback. Legacy snapshots retain their generic compatibility projection and legacy skipped-state metadata.
Legacy skipped-state projection remains only for old snapshots. Fresh `If` materialization prepares the condition boundary first,
resolves the activation token, and attaches only the selected branch input.
@@ -25,6 +25,12 @@ Unselected branch nodes are never prepared, skipped, or added to fresh execution
consume these dependency decisions without pruning execution edges or calling a type-specific branch scheduler.
Legacy skipped-state metadata remains only for snapshots that already contain the old projection. Branch-membership
analysis remains an internal author-graph admission decision.
+The focused fresh-shape ownership matrix also verifies that supported flat,
+nested, bounded fan-out, and four-sibling graphs do not instantiate the
+compatibility controller or project fresh skipped nodes in either scheduler
+route. This proves the current ownership boundary; it does not remove the
+controller, which remains required for unsupported fresh shapes and legacy
+snapshots.
Direct `Iterate`/`Collect` graphs that do not contain `If`, `For`, `ForReturn`, or saved-workflow control flow also use
the generic adapter. Its adapter-level readiness predicate waits for canonical Iterate streams to close, and generic
completion mirrors each Iterate result into that ledger before releasing `Collect`. The exact fresh four-node shape
@@ -264,7 +270,7 @@ remains forward-compatible.
For a fresh generic `If` graph with one ordinary-node `If`, the exact one-level nested shape described above, the exact
bounded three-`If` inner/middle/outer chain, or exactly two, exactly three, or exactly four independent sibling `If`s,
`GraphExecutionState` compiles opaque, frame-local activation-dependency records privately on each branch-local plan
-node. Four-or-more nesting, five-or-more sibling `If`s, fan-out, mixed, loop-containing, and saved-workflow shapes use
+node. Four-or-more nesting, five-or-more sibling `If`s, other fan-out, mixed, loop-containing, and saved-workflow shapes use
the compatibility scheduler and `_IfActivationController` for the same records; legacy snapshots retain the generic
compatibility projection and legacy skipped-state metadata. The controller
remains the fallback runtime dependency owner, and the schedulers no longer call a legacy compiler. Fresh materialization prepares the condition boundary, resolves the activation token,
diff --git a/tests/app/services/shared/test_execution_engine_differential.py b/tests/app/services/shared/test_execution_engine_differential.py
index 5243edf6ed..968fc705cf 100644
--- a/tests/app/services/shared/test_execution_engine_differential.py
+++ b/tests/app/services/shared/test_execution_engine_differential.py
@@ -4351,6 +4351,46 @@ def test_fresh_four_sibling_ifs_shared_ancestor_executes_once_without_cross_owne
assert _activation_projection(runs[0][1]) == _activation_projection(runs[1][1])
+ "graph_factory",
+ [
+ pytest.param(_flat_if_graph, id="flat"),
+ pytest.param(_noncanonical_flat_if_graph, id="noncanonical-flat"),
+ pytest.param(_nested_if_graph, id="nested"),
+ pytest.param(_three_nested_if_graph, id="three-nested"),
+ pytest.param(_three_nested_if_graph_with_middle_leaf_fanout, id="middle-leaf-fanout"),
+ pytest.param(_four_sibling_if_graph, id="four-siblings"),
+ ],
+)
[email protected]("force_compatibility_scheduler", [False, True])
+def test_supported_fresh_if_shapes_do_not_use_controller_or_skip_projection(
+ graph_factory: Any,
+ force_compatibility_scheduler: bool,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Fresh supported shapes use graph-state dependencies in both scheduler routes."""
+
+ def fail_controller(*_: object, **__: object) -> Any:
+ raise AssertionError("fresh supported If shape used compatibility controller")
+
+ def fail_generic_retirement(*_: object, **__: object) -> None:
+ raise AssertionError("fresh supported If shape used generic skip projection")
+
+ monkeypatch.setattr(GraphExecutionState, "_if_activation_controller", fail_controller)
+ monkeypatch.setattr(_GenericGraphSchedulerAdapter, "_retire_unselected_node", fail_generic_retirement)
+
+ state = GraphExecutionState(graph=graph_factory())
+ assert state._can_use_fresh_flat_if_activation()
+ trace, state = _run(state, force_compatibility_scheduler=force_compatibility_scheduler)
+
+ assert trace
+ assert state.is_complete()
+ assert all(
+ state._get_prepared_exec_metadata(exec_node_id).state != "skipped"
+ for exec_node_id in state.prepared_source_mapping
+ )
+
+
@pytest.mark.parametrize("force_compatibility_scheduler", [False, True])
@pytest.mark.parametrize(
("first_condition", "second_condition", "third_condition"),