phenotypic.gui.builder._state._seed_input_image#

phenotypic.gui.builder._state._seed_input_image(scope: _DagBuilderScope) None[source]#

Idempotently add an InputImage block at the head of scope.

Rule 6 of the validation suite (spec §4.6) requires exactly one InputImage block per scope. This helper enforces the invariant by:

  • Doing nothing if scope already has at least one block whose class_name == INPUT_IMAGE_CLASS_NAME — extras are detected and reported by the validator, not pruned here.

  • Otherwise inserting a fresh InputImage block at index 0.

Called from _DagBuilderScope.__post_init__() and from every deserialisation path (see state_from_json() for the DAG branch) so corrupted JSON missing an Input Image self-heals on load.

Parameters:

scope (_DagBuilderScope) – The scope to seed in place.

Return type:

None