Modules & Input/Output Contracts — designing branches as replaceable building blocks
A professional workflow is easier to build and maintain when every major branch has one responsibility, explicit inputs, a predictable output and an independent checkpoint. The Master Workflow then becomes a system of modules rather than a monolith.
A module is a complete responsibility, not just a colored frame
A group becomes an engineering module only when its purpose can be stated in one sentence, its required inputs can be listed, and one or more expected outputs can be named.
A good module can be temporarily separated from the Master Workflow, fed with test inputs, and evaluated independently.
The input contract defines what a module is allowed to expect
A branch should not rely on hidden assumptions. If a module requires an IMAGE at 1536 px, a MASK on the same canvas, a MODEL from a specific family and a FLOAT denoise value, that contract should be explicit before integration.
An input contract includes more than the socket type: dimensions, batch, coordinate space, polarity, model family, and whether the parameter is required or optional all matter.
| Contract field | Example |
|---|---|
| Type | IMAGE / MASK / LATENT / MODEL |
| Dimensions | 1536 × 1024 |
| Batch | 1 image / N masks |
| Coordinate space | Same as BASE IMAGE |
| Model family | SDXL / FLUX-compatible |
| Required / optional | BASE IMAGE required; reference optional |
The output contract defines what downstream can safely consume
An output should be usable by the next module without guesswork. If the PEOPLE branch returns a composited IMAGE on the same canvas, downstream FLUX can consume it as a predictable source. If the branch returns a crop at a different size, that is a different contract.
The return point is the branch’s official exit back into the Master Workflow
A complex branch should have one clearly readable return point. This is where the local task is complete and its result becomes part of the main data plane again.
Marking the return point explicitly makes standalone extraction, debugging and implementation replacement easier without forcing downstream reconstruction.
One module — one primary responsibility
| Module | Responsibility |
|---|---|
| CONTROLNET | Create / apply geometry guidance |
| SDXL | Produce base generation / img2img result |
| MASKS | Define protected / editable regions |
| PPL | Create or replace people and return a composite |
| MAIN FLUX | Perform controlled final refinement |
| UPSCALE | Increase output resolution while preserving consistency |
| OUTPUT | Save / preview the delivery result |
Every module should expose its own provable result
If the only preview is at the very end of the Master Workflow, it is difficult to identify which module failed. A local module output should therefore have a Preview / MaskPreview / comparer or another diagnostic probe.
The Master Workflow should assemble like LEGO from known modules
Practice: write a contract for one familiar branch
- Choose one branch from the current workflow.
- State its responsibility in one line.
- List every external incoming link.
- For each input, record type, size/batch and required/optional status.
- Name one official output / return point.
- Add a checkpoint immediately before return.
- Verify that upstream can be replaced with test inputs and the branch can run independently.