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
test(execution): prove fresh If ownership boundary
JPPhoto2eaa86e9d687
diff --git a/invokeai/app/services/shared/README.md b/invokeai/app/services/shared/README.mdindex 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 compatibCurrent fresh sibling support includes exactly four independent `If`s with no nesting, fan-out, or other control-flownodes. 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 thecompatibility 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 executionconsume 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-membershipanalysis 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 usethe generic adapter. Its adapter-level readiness predicate waits for canonical Iterate streams to close, and genericcompletion 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 exactbounded 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 usethe compatibility scheduler and `_IfActivationController` for the same records; legacy snapshots retain the genericcompatibility projection and legacy skipped-state metadata. The controllerremains 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.pyindex 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_owneassert _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"),