AV ComfyUI Manual
11 / 64
Files
11
PRACTICE LAB · WORKFLOW ENGINEERING

Module Contract Lab: INPUT → PROCESS → CHECKPOINT → RETURN

The third lab turns a group from a visual frame into an engineering module. We will build a small branch using only core ComfyUI nodes and explicitly define its input contract, responsibility, checkpoint and return point.

CONFIRMEDThe lab uses the basic IMAGE type and core nodes LoadImage, ImageInvert and PreviewImage. No generative models are required, so attention stays on module boundaries and the data contract.
01 · GOAL

Learn to see responsibility boundaries

One of the main sources of chaos in a large workflow is not knowing where one responsibility ends and the next begins. LAB 03 forces that boundary to become explicit on the canvas.

After the exercise, you should be able to take any Hansen branch and state what it receives, what it does, where its result is verified, and what it officially returns to the Master Workflow.

02 · BUILD

A minimal IMAGE module without models

  • Keep LoadImage outside MODULE_01_INVERT: it is the upstream / Master Input.
  • Place ImageInvert inside the MODULE_01_INVERT group.
  • Place the first PreviewImage inside the group and label it CHECKPOINT · MODULE RESULT.
  • Keep the second PreviewImage outside and label it MASTER DOWNSTREAM / OUTPUT.
  • Connect the single IMAGE output of ImageInvert to both the local checkpoint and downstream output.

03 · INPUT CONTRACT

Write the contract before you run the graph

CONFIRMED

Why this is a contract

The module must not hide dependencies on prompt, model, seed or mask. Its only external dependency in this lab is IMAGE.

FieldLAB 03
Required inputIMAGE
SourceMASTER INPUT · LoadImage
DimensionsInherited from the source image
BatchPassed with the IMAGE tensor
Coordinate spaceSame canvas as the input IMAGE
Optional inputsNone
04 · ONE RESPONSIBILITY

State the task in one line

MODULE_01_INVERT has one responsibility: receive IMAGE and return an inverted IMAGE. Nothing more. It does not load the file, save the delivery result, choose a route or control other groups.

If a module description requires a long sentence containing several independent tasks, the boundary is probably poorly drawn.

05 · CHECKPOINT

A checkpoint proves the module before downstream

Run the workflow and inspect only the LOCAL CHECKPOINT first. Do not judge MASTER OUTPUT until the local result is proven.

This simple rule saves hours later in PPL, masks and main FLUX: a local branch should be able to prove its own result independently of whatever happens after return.

06 · RETURN CONTRACT

Return is a boundary, not necessarily a dedicated node

In LAB 03, the return point is the IMAGE link that crosses the right boundary of MODULE_01_INVERT and continues to MASTER OUTPUT. A separate Return node is not required; what matters is an unambiguous interface.

In a large production graph, return points are worth marking with a reroute/label/note, especially if the module may later be extracted as a standalone JSON.

Return fieldLAB 03
TypeIMAGE
MeaningProcessed module result
CanvasSame logical image canvas as input
Downstream assumptionThe consumer should not need to know the module’s internal implementation
07 · EXPERIMENT A

Replacement test: the module should be replaceable

Create a second group, MODULE_02_PASS_THROUGH. Its job is to return the original IMAGE unchanged. Then place a selector after the two module outputs and switch between MODULE_01_INVERT and MODULE_02_PASS_THROUGH.

If downstream continues to receive the same IMAGE contract, the modules are interface-compatible even though their internal behavior is completely different.

08 · EXPERIMENT B

Deliberately create a hidden dependency and catch it

Add another external control or source inside MODULE_01, but do not include it in the contract. Now imagine extracting the group into a standalone workflow. The problem becomes obvious: the branch is no longer autonomous.

Then fix the contract: either add the dependency as an explicit module input or move the required control inside the module. This is exactly the audit needed when extracting Hansen branches.

09 · TRANSFER TO HANSEN

Use the same questions on any Hansen branch

LAB 03 questionProduction branch example
INPUT CONTRACT?BASE IMAGE / MASK / MODEL / prompt / controls
ONE RESPONSIBILITY?For example Generate Person or Segment Person
LOCAL CHECKPOINT?raw generation / bbox / mask / clean cutout / composite
RETURN CONTRACT?IMAGE / MASK / LATENT returned downstream
HIDDEN DEPENDENCIES?shared seed, size, selector, loader, prompt fragment
10 · PASS CRITERIA

LAB 03 is complete when you can design a module before choosing nodes

  • You write the responsibility and contracts before selecting nodes.
  • You distinguish a local checkpoint from the final Master output.
  • You can point to the exact return point on the canvas.
  • You can identify incoming links that cross the module boundary.
  • You understand why two very different modules can be interchangeable when they share the same contract.
  • You can explain why a hidden dependency breaks standalone extraction.
CONFIRMED

After the first three labs

LAB 01 teaches route selection; LAB 02 teaches centralized group control; LAB 03 teaches module boundaries. Together they provide the minimum practical foundation for reading the Hansen production graph.