Nodes/DOGMA Nodes/DOGMA v36 Local Safety Gate
ComfyUI Node

DOGMA v36 Local Safety Gate

When Klein rewrites your crop, this node rations the damage

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA v36 Local Safety Gate
  • edited
  • original
  • image
  • info
prompt

Most gates are binary: accept the edit or throw it away. DOGMALocalSafetyGateV36 refuses the binary. It measures how far the local pass actually moved the pixels and then decides how much of that move deserves to survive - which means a slightly-off crop keeps most of its improvement, and a wholesale reinterpretation gets almost entirely reverted.

The mechanism

Preserve prompt first, same contract as the pack's other gates: if prompt starts with PRESERVE , you get original back and the Klein output is dropped. Nothing clever.

Otherwise it gets quantitative. It takes the mean absolute per-channel difference between edited and original (resizing or broadcasting original if the shapes disagree), and converts that deviation into a blend weight:

  • the weight tracks an inverse of the deviation - around 0.095 divided by the mean delta
  • it's floored at 0.20 and capped at 0.72

Then it outputs a blend of the two: the original weighted (1 − alpha), the edit weighted alpha. So a crop that came back close to its source (small delta) keeps up to 72% of the edit. A crop that came back radically different (large delta) keeps only about 20% of it. The info string prints the measured deltas and the alphas it used, which is a genuinely useful debug line when one group in a batch keeps coming out blurry.

The commentary in the source is blunt about the intent: a local crop must never be allowed to become a wholesale reinterpretation. Note that this is a safety rule, not a quality rule - if the crop really did need a big fix, this node will under-deliver on purpose and you should be looking at your denoise and mask instead.

Where it sits in a graph

edited from the local pass's decode, original from the crop you sent into that pass, prompt from the prompt node (DOGMALocalPromptV36 is the natural partner - same version, same philosophy of refusing to over-edit). image continues to the stitch; info goes to a text preview.

The blend is a straight global mix over the whole crop, not a masked composite. So this node softens the edit everywhere in the crop rather than feathering at the mask edge - the mask's own feathering is the crop-side concern (DOGMAMaskedLatentV542 and its relatives), and this is the belt to that pair of braces.

Inputs and outputs

Three required, no options: edited (IMAGE), original (IMAGE), prompt (STRING). Outputs image (IMAGE) and info (STRING).

Install

ComfyUI Manager → search DOGMA Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes

Restart. This pack adds no Python dependencies - requirements.txt is a comment and pyproject.toml declares an empty dependency list - and no weights. Your Klein checkpoint, VLM and masker all come from the rest of the graph.

Where it bites

The blend is per frame in the batch and driven by the mean delta across the whole crop. In a crop where one small thing changed a lot and everything else is identical, the mean is small, so the big change sails through with a high alpha. This is a drift damper, not a semantic checker - it can't tell a corrected wheel from a newly invented spoiler. If you want per-region judgement, that's what the mask audit nodes are for.

Second, the ~0.095 constant means the numbers only make sense at a scale where a good local repair lands somewhere in the 0.1–0.5 mean-delta range. Crops with heavy grain or a strong contrast shift will read as "huge deviation" and get capped down, which can look like the gate is refusing to let real fixes through.

Third, the preserve branch is a string convention like every other gate here. Wire prompt straight from the prompt node; if you rewrite it on the way in, the safety rail stops existing.

CategoryDOGMA/Semantic Detailer

Inputs (3)

NameTypeDefaultDescription
editedIMAGE
originalIMAGE
promptSTRING

Outputs (2)

NameTypeDescription
imageIMAGE
infoSTRING