DOGMA v56.4 Automatic Mask Safety Gate
A PASS/FAIL audit that can only ever make your masks safer
- mask_1
- mask_2
- mask_3
- mask_4
- mask_5
- safe_mask_1
- safe_mask_2
- safe_mask_3
- safe_mask_4
- safe_mask_5
- report
This is the node that makes the mask audit worth running. DOGMAMaskAuditGateV564 takes five masks and a vision model's verdict on them, and applies an asymmetry that's worth internalising: a PASS hands your mask through untouched, a FAIL returns an all-zero mask so the whole downstream crop becomes a no-op.
The asymmetry is the design
There's no "clean up" branch. The node's own documentation says why: it does no morphological repair, deliberately, so it can't damage a mask that was fine. You get the original SAM tensor exactly, or you get nothing.
That's the right call. A gate that "improves" masks has to be right twice - right about which masks are bad, and right about how to fix them. A gate that only skips is only responsible for the first question, and getting it wrong just means a region you'd already fixed globally stays fixed globally. Failing safe here means fewer edits, never weirder ones.
What it parses
audit_text is the vision model's reply - the five-line PASS/FAIL block that DOGMAMaskAuditSheetV564's audit_prompt asks for. The gate reads it line by line, looking for FAIL or REJECT (that slot is off) and PASS or ACCEPT (that slot is on), and stops after five decisions.
Three things then override the model:
- a slot whose category is unused, empty, or
none-ish is forced off, whatever the audit said - a slot whose mask is effectively empty (essentially no pixels above 0.35) is forced off - there's nothing to inpaint anyway
- if the model returned fewer than five parseable lines, the missing slots default to off, and the
reportstring calls it out as Qwen audit FAIL / malformed audit
That last one is the bit I like. A chatty or truncated VLM response doesn't corrupt five regions; it downgrades them to no-ops. Same for a model that decides to write an essay before answering.
Set enabled to false and the whole thing bypasses - five inputs straight to five outputs, with a report line saying the audit was disabled. Useful when you're debugging whether the audit or the masker is at fault.
Outputs
safe_mask_1 through safe_mask_5, plus a report string that's a per-slot verdict: SLOT 2 PASS - buildings - original SAM mask preserved unchanged, or SLOT 3 SKIP - people - empty mask; zero mask prevents any inpaint. That report is your audit log, and on a batch run it's the only place that tells you why a region came back untouched.
Wiring it
Five masks and their five categories from the same source the sheet used - they must be in the same slot order, since position is the only thing tying a verdict to a mask. audit_text from your VLM node's text output. Then the safe_mask_N outputs replace the originals going into your crop/cluster node.
Install
ComfyUI Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Restart and look under DOGMA/v56.4. No dependencies, no downloads - the pack is PyTorch plus ComfyUI's APIs.
Where it bites
Slot order is the entire contract. Swap two category wires relative to the sheet and the gate will confidently skip the wrong region. Build both nodes from the same five wires, in the same order, and don't touch it after.
Second, a VLM that likes the word "pass" in prose can produce false passes - the parser scans for the words, so a line like "PASS criteria: mask is fine" reads as a PASS. The sheet's prompt demands one word per line for exactly this reason; if you're writing your own instruction, keep that constraint.
Third, this gate only knows whether a mask is semantically contaminated. It can't tell you a mask is the right object but the wrong size, and it won't catch a mask that's correct but where your prompt will still wreck the crop - that's what the result gates downstream are for.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_1 | MASK | — | |
| mask_2 | MASK | — | |
| mask_3 | MASK | — | |
| mask_4 | MASK | — | |
| mask_5 | MASK | — | |
| category_1 | STRING | — | |
| category_2 | STRING | — | |
| category_3 | STRING | — | |
| category_4 | STRING | — | |
| category_5 | STRING | — | |
| audit_text | STRING | — | |
| enabled | BOOLEAN | true | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| safe_mask_1 | MASK | — |
| safe_mask_2 | MASK | — |
| safe_mask_3 | MASK | — |
| safe_mask_4 | MASK | — |
| safe_mask_5 | MASK | — |
| report | STRING | — |