From e51a49f16a3eb8ce31f67d8c79d1e91b3608a390 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 19 Oct 2026 07:27:41 +0000 Subject: [PATCH 1/5] feat(workflow): emit source_address on promoted subgraph widget rows workflow slots advertises a promoted subgraph widget at . and hides the interior widget behind it, so a consumer could not tell which interior node and widget a row stands for -- a renamed promotion (459.clip_name_1 for a CLIPLoader.clip_name) or two same-class loaders in one subgraph were indistinguishable. Each promoted widget row (linked, nested, or a repairable legacy proxyWidgets entry) now carries source_address, the concrete interior widget resolved through deepest_source: /[/].. Additive only: address, node_type, current_value and the hidden-interior rule are unchanged. --- CHANGELOG.md | 4 + comfy_cli/cql/engine.py | 43 ++++++++--- comfy_cli/skills/comfy/SKILL.md | 4 + .../comfy_cli/command/test_workflow_slots.py | 75 +++++++++++++++++++ 4 files changed, 116 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c9f271e..441c2dad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ history. ### Added +- `comfy workflow slots` rows for a subgraph's promoted widgets carry + `source_address`, the interior node and widget the row stands for + (`57/28.unet_name`), resolved through nested promotions and renamed inputs. + The row's `address` is unchanged and stays the one to edit. - `comfy build init`, `update` and `validate` carry `data.warnings[]` as `{code, message}` under `--json`. `build_comfy_version_missing` means the spec has no `baseComfyVersion`; `build_snapshot_empty` means a diff --git a/comfy_cli/cql/engine.py b/comfy_cli/cql/engine.py index 72d97c96f..f4140f308 100644 --- a/comfy_cli/cql/engine.py +++ b/comfy_cli/cql/engine.py @@ -5266,6 +5266,10 @@ def _declared_subgraph_slots( } if linked_from is not None: slot["linked_from"] = linked_from + if pi is not None and pi.is_widget: + source_address = _promoted_source_address(instance_id, sg, pi, defs) + if source_address is not None: + slot["source_address"] = source_address declared.append(slot) if workflow is not None: # Legacy ``proxyWidgets`` promotions the definition does not back @@ -5283,19 +5287,38 @@ def _declared_subgraph_slots( if current is _promoted.UNSET: all_resolved = False continue - declared.append( - { - "address": f"{instance_id}.{entry.name}", - "name": entry.name, - "type": str(entry.type), - "current_value": current, - "instance_id": instance_id, - "node_type": instance.get("type", ""), - } - ) + slot = { + "address": f"{instance_id}.{entry.name}", + "name": entry.name, + "type": str(entry.type), + "current_value": current, + "instance_id": instance_id, + "node_type": instance.get("type", ""), + } + # A primitive bypass holds its own value and fans out to interior + # widgets, so it has no one interior source to name. + if entry.plan == _promoted.PLAN_CREATE: + source_address = _promoted_source_address(instance_id, sg, entry.as_promoted_input(sg), defs) + if source_address is not None: + slot["source_address"] = source_address + declared.append(slot) return declared, (any_declared and all_resolved) +def _promoted_source_address(instance_id: str, sg: dict, pi: Any, defs: dict[str, dict]) -> str | None: + """``/[/…].`` — the concrete interior + widget a promoted row stands for, through any nested promotion chain. + Informational only: the row is still edited at ``.``. + ``None`` when the chain does not resolve.""" + from comfy_cli.cql import promoted as _promoted + + target = _promoted.deepest_source(sg, pi, defs) + if target is None: + return None + path, widget = target + return f"{_SUBGRAPH_PATH_SEP.join([instance_id, *path])}.{widget}" + + def promoted_source_port(sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) -> tuple[str, Port | None]: """``(interior class, Port)`` of the concrete widget behind promoted input ``pi`` — the schema a host value is validated against.""" diff --git a/comfy_cli/skills/comfy/SKILL.md b/comfy_cli/skills/comfy/SKILL.md index 41f3e9597..228becfc9 100644 --- a/comfy_cli/skills/comfy/SKILL.md +++ b/comfy_cli/skills/comfy/SKILL.md @@ -1079,6 +1079,10 @@ comfy --json workflow slots path.json # --node lists one node's slots, subgraph interior included (a # template id like 94 works on an inserted canvas; that node's own rows # carry template_node_id) +# a promoted subgraph widget row (.) carries +# source_address — the interior widget it stands for, e.g. +# 57/28.unet_name (the real widget name, even when the promotion is +# renamed). Read-only context: edit at the row's own address # 2. Set a single slot comfy workflow set-slot path.json 6.text="a cat" diff --git a/tests/comfy_cli/command/test_workflow_slots.py b/tests/comfy_cli/command/test_workflow_slots.py index df9b72ffb..55a31e484 100644 --- a/tests/comfy_cli/command/test_workflow_slots.py +++ b/tests/comfy_cli/command/test_workflow_slots.py @@ -1101,3 +1101,78 @@ def test_set_slot_reports_a_domain_error_instead_of_crashing(self, patched_graph env = _run(["set-slot", str(path), "3.seed=1"], capsys) assert env["ok"] is False assert env["error"]["code"] == "workflow_slot_invalid" + + +# --------------------------------------------------------------------------- +# slots — source_address on promoted subgraph widget rows +# --------------------------------------------------------------------------- +# +# A promoted widget is advertised at ``.`` and its interior +# widget is hidden, so the row names the interior node + widget it stands for +# in ``source_address`` — the only way a consumer recovers the real widget +# behind a renamed promotion or tells two same-class loaders apart. + + +def _gallery_workflow(name: str) -> dict: + return json.loads((_FIXTURES / "gallery" / name).read_text(encoding="utf-8")) + + +@pytest.fixture +def patched_promoted_graph(monkeypatch): + oi = json.loads((_FIXTURES / "object_info_subgraph_promoted.json").read_text(encoding="utf-8")) + monkeypatch.setattr(workflow_cmd, "_get_graph", lambda *a, **kw: Graph.from_object_info(oi)) + + +class TestSlotsSourceAddress: + def test_promoted_row_names_its_interior_widget(self, patched_promoted_graph, tmp_path, capsys): + path = _write_workflow(tmp_path, _gallery_workflow("image_z_image_turbo.json")) + env = _run(["slots", str(path)], capsys) + by_addr = {s["address"]: s for s in env["data"]["slots"]} + row = by_addr["57.unet_name"] + assert row["source_address"] == "57/28.unet_name" + # Additive only: the editable address and the UUID node_type stay. + assert row["node_type"] == "f2fdebf6-dfaf-43b6-9eb2-7f70613cfdc1" + assert "57/28.unet_name" not in by_addr + # A labelled promotion still names the interior widget. + assert by_addr["57.text"]["source_address"] == "57/27.text" + + def test_minimax_promoted_loader(self, patched_promoted_graph, tmp_path, capsys): + path = _write_workflow(tmp_path, _gallery_workflow("audio_minimax_music_3.json")) + env = _run(["slots", str(path)], capsys) + by_addr = {s["address"]: s for s in env["data"]["slots"]} + assert by_addr["37.unet_name"]["source_address"] == "37/6.unet_name" + + def test_renamed_promotion_carries_the_real_widget_name(self, patched_promoted_graph, tmp_path, capsys): + wf = _gallery_workflow("image_z_image_turbo.json") + sg = wf["definitions"]["subgraphs"][0] + next(i for i in sg["inputs"] if i["name"] == "unet_name")["name"] = "diffusion_model" + path = _write_workflow(tmp_path, wf) + env = _run(["slots", str(path)], capsys) + by_addr = {s["address"]: s for s in env["data"]["slots"]} + assert "57.unet_name" not in by_addr + assert by_addr["57.diffusion_model"]["source_address"] == "57/28.unet_name" + + def test_top_level_row_has_no_source_address(self, patched_promoted_graph, tmp_path, capsys): + path = _write_workflow(tmp_path, _gallery_workflow("image_z_image_turbo.json")) + env = _run(["slots", str(path)], capsys) + by_addr = {s["address"]: s for s in env["data"]["slots"]} + assert "source_address" not in by_addr["9.filename_prefix"] + + def test_nested_promotion_resolves_to_the_deepest_widget(self, patched_subgraph_graph, tmp_path, capsys): + path = _write_workflow(tmp_path, _subgraph_workflow()) + env = _run(["slots", str(path)], capsys) + by_addr = {s["address"]: s for s in env["data"]["slots"]} + # 10.value -> inner instance 3's promoted value -> node 7's widget. + assert by_addr["10.value"]["source_address"] == "10/3/7.value" + # A legacy proxyWidgets promotion the frontend repairs on load. + assert by_addr["10.seed"]["source_address"] == "10/9.seed" + # Interior rows are not promotions. + assert "source_address" not in by_addr["10/9.prompt"] + + def test_select_projects_source_address(self, patched_promoted_graph, tmp_path, capsys): + path = _write_workflow(tmp_path, _gallery_workflow("audio_minimax_music_3.json")) + env = _run(["slots", str(path), "--select", "slots.#.source_address"], capsys) + assert env["ok"] is True + # Rows without the key (plain top-level widgets) are dropped, not null. + assert "37/6.unet_name" in env["data"] + assert all(isinstance(a, str) for a in env["data"]) From c0a69491b0bbf78a65644672a45ece4367901fda Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 19 Oct 2026 07:50:43 +0000 Subject: [PATCH 2/5] fix(workflow): omit source_address when the interior widget is stale Validate the terminal widget against the catalog before publishing source_address, so a promotion whose interior class no longer has that widget does not name a dangling address. A class the catalog does not know is trusted as saved. Docs and changelog now say the key is optional. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + comfy_cli/cql/engine.py | 21 ++++++++--- comfy_cli/skills/comfy/SKILL.md | 7 ++-- .../comfy_cli/command/test_workflow_slots.py | 35 +++++++++++++++++++ 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 441c2dad8..b447e64de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ history. - `comfy workflow slots` rows for a subgraph's promoted widgets carry `source_address`, the interior node and widget the row stands for (`57/28.unet_name`), resolved through nested promotions and renamed inputs. + The key is optional: a row whose interior widget does not resolve omits it. The row's `address` is unchanged and stays the one to edit. - `comfy build init`, `update` and `validate` carry `data.warnings[]` as `{code, message}` under `--json`. `build_comfy_version_missing` means the diff --git a/comfy_cli/cql/engine.py b/comfy_cli/cql/engine.py index f4140f308..60a57cd78 100644 --- a/comfy_cli/cql/engine.py +++ b/comfy_cli/cql/engine.py @@ -5267,7 +5267,7 @@ def _declared_subgraph_slots( if linked_from is not None: slot["linked_from"] = linked_from if pi is not None and pi.is_widget: - source_address = _promoted_source_address(instance_id, sg, pi, defs) + source_address = _promoted_source_address(instance_id, sg, pi, defs, graph) if source_address is not None: slot["source_address"] = source_address declared.append(slot) @@ -5298,24 +5298,37 @@ def _declared_subgraph_slots( # A primitive bypass holds its own value and fans out to interior # widgets, so it has no one interior source to name. if entry.plan == _promoted.PLAN_CREATE: - source_address = _promoted_source_address(instance_id, sg, entry.as_promoted_input(sg), defs) + source_address = _promoted_source_address(instance_id, sg, entry.as_promoted_input(sg), defs, graph) if source_address is not None: slot["source_address"] = source_address declared.append(slot) return declared, (any_declared and all_resolved) -def _promoted_source_address(instance_id: str, sg: dict, pi: Any, defs: dict[str, dict]) -> str | None: +def _promoted_source_address(instance_id: str, sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) -> str | None: """``/[/…].`` — the concrete interior widget a promoted row stands for, through any nested promotion chain. Informational only: the row is still edited at ``.``. - ``None`` when the chain does not resolve.""" + ``None`` when the chain does not resolve to a live interior widget: a + missing interior node, or a widget the catalog says that class lacks (a + class the catalog does not know is trusted as saved).""" from comfy_cli.cql import promoted as _promoted target = _promoted.deepest_source(sg, pi, defs) if target is None: return None path, widget = target + class_type, port = promoted_source_port(sg, pi, defs, graph) + if port is None: + if not class_type: + return None + m = graph.node(class_type) + if m is not None: + # A dynamic-combo sub-widget (``model.size_preset``) is not a + # top-level port; its selector is. + head = widget.split(".", 1)[0] + if head == widget or not any(p.name == head and p.is_dynamic_combo for p in m.inputs): + return None return f"{_SUBGRAPH_PATH_SEP.join([instance_id, *path])}.{widget}" diff --git a/comfy_cli/skills/comfy/SKILL.md b/comfy_cli/skills/comfy/SKILL.md index 228becfc9..6efa6e288 100644 --- a/comfy_cli/skills/comfy/SKILL.md +++ b/comfy_cli/skills/comfy/SKILL.md @@ -1080,9 +1080,10 @@ comfy --json workflow slots path.json # template id like 94 works on an inserted canvas; that node's own rows # carry template_node_id) # a promoted subgraph widget row (.) carries -# source_address — the interior widget it stands for, e.g. -# 57/28.unet_name (the real widget name, even when the promotion is -# renamed). Read-only context: edit at the row's own address +# source_address when its interior widget resolves — the interior widget +# it stands for, e.g. 57/28.unet_name (the real widget name, even when +# the promotion is renamed). Optional: a row whose source does not +# resolve omits it. Read-only context: edit at the row's own address # 2. Set a single slot comfy workflow set-slot path.json 6.text="a cat" diff --git a/tests/comfy_cli/command/test_workflow_slots.py b/tests/comfy_cli/command/test_workflow_slots.py index 55a31e484..a27958d33 100644 --- a/tests/comfy_cli/command/test_workflow_slots.py +++ b/tests/comfy_cli/command/test_workflow_slots.py @@ -1176,3 +1176,38 @@ def test_select_projects_source_address(self, patched_promoted_graph, tmp_path, # Rows without the key (plain top-level widgets) are dropped, not null. assert "37/6.unet_name" in env["data"] assert all(isinstance(a, str) for a in env["data"]) + + @staticmethod + def _materialized_loader(interior_type: str) -> dict: + # Host value materialized for every promotion, so the unet_name row is + # emitted even when the interior widget no longer resolves. + wf = _gallery_workflow("image_z_image_turbo.json") + next(n for n in wf["nodes"] if n["id"] == 57)["widgets_values"] = [ + "a cat", + 1024, + 1024, + 0, + 8, + "z.safetensors", + "qwen.safetensors", + "ae.safetensors", + ] + sg = wf["definitions"]["subgraphs"][0] + next(n for n in sg["nodes"] if n["id"] == 28)["type"] = interior_type + return wf + + def test_stale_interior_widget_omits_source_address(self, patched_promoted_graph, tmp_path, capsys): + # The catalog's VAELoader has no unet_name: the row stays (the host + # value runs) but names no dangling interior widget. + path = _write_workflow(tmp_path, self._materialized_loader("VAELoader")) + env = _run(["slots", str(path)], capsys) + row = {s["address"]: s for s in env["data"]["slots"]}["57.unet_name"] + assert row["current_value"] == "z.safetensors" + assert "source_address" not in row + + def test_uncatalogued_interior_class_keeps_source_address(self, patched_promoted_graph, tmp_path, capsys): + # A custom node the catalog does not know is trusted as saved. + path = _write_workflow(tmp_path, self._materialized_loader("SomeCustomUnetLoader")) + env = _run(["slots", str(path)], capsys) + row = {s["address"]: s for s in env["data"]["slots"]}["57.unet_name"] + assert row["source_address"] == "57/28.unet_name" From a4e638d9a220624f9842c8fa36cbc6fd4009c0ea Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 19 Oct 2026 08:15:07 +0000 Subject: [PATCH 3/5] fix(workflow): skip non-dict interior nodes on the promoted source chain deepest_source, source_value, promoted_source_port and as_promoted_input scanned a definition's nodes without the isinstance guard every other walk uses, so a null entry crashed `slots` with no JSON envelope. Route them through _inner_node. Document which promoted rows omit source_address (primitive bypass, proxyWidgets-only inputs). Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 +++- comfy_cli/cql/engine.py | 7 ++++--- comfy_cli/cql/promoted.py | 16 ++++------------ comfy_cli/skills/comfy/SKILL.md | 6 ++++-- tests/comfy_cli/command/test_workflow_slots.py | 12 ++++++++++++ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b447e64de..9eea5df66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,9 @@ history. - `comfy workflow slots` rows for a subgraph's promoted widgets carry `source_address`, the interior node and widget the row stands for (`57/28.unet_name`), resolved through nested promotions and renamed inputs. - The key is optional: a row whose interior widget does not resolve omits it. + The key is optional: a row omits it when its interior widget does not + resolve, when its value comes from an interior PrimitiveNode, or when the + input is backed only by a legacy `proxyWidgets` entry. The row's `address` is unchanged and stays the one to edit. - `comfy build init`, `update` and `validate` carry `data.warnings[]` as `{code, message}` under `--json`. `build_comfy_version_missing` means the diff --git a/comfy_cli/cql/engine.py b/comfy_cli/cql/engine.py index 60a57cd78..207620dd2 100644 --- a/comfy_cli/cql/engine.py +++ b/comfy_cli/cql/engine.py @@ -5295,8 +5295,9 @@ def _declared_subgraph_slots( "instance_id": instance_id, "node_type": instance.get("type", ""), } - # A primitive bypass holds its own value and fans out to interior - # widgets, so it has no one interior source to name. + # A primitive bypass's value lives on an interior PrimitiveNode + # that may feed several widgets; source_address names one concrete + # widget, so these rows omit it (documented in SKILL.md). if entry.plan == _promoted.PLAN_CREATE: source_address = _promoted_source_address(instance_id, sg, entry.as_promoted_input(sg), defs, graph) if source_address is not None: @@ -5344,7 +5345,7 @@ def promoted_source_port(sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) current_sg = sg node: dict | None = None for seg in path: - node = next((n for n in current_sg.get("nodes") or [] if str(n.get("id")) == seg), None) + node = _promoted._inner_node(current_sg, seg) if node is None: return "", None nxt = defs.get(str(node.get("type", ""))) diff --git a/comfy_cli/cql/promoted.py b/comfy_cli/cql/promoted.py index 905b748f2..20a209c95 100644 --- a/comfy_cli/cql/promoted.py +++ b/comfy_cli/cql/promoted.py @@ -839,7 +839,7 @@ def source_value( return UNSET stack = _stack | {id(sg)} defs = defs if defs is not None else defs_by_id(workflow) - inner = next((n for n in sg.get("nodes") or [] if str(n.get("id")) == pi.source_node), None) + inner = _inner_node(sg, pi.source_node) if inner is None: return UNSET if pi.nested: @@ -958,15 +958,7 @@ def deepest_source(sg: dict, pi: PromotedInput, defs: dict[str, dict]) -> tuple[ path.append(current.source_node) if not current.nested: return path, str(current.source_widget) - nodes = current_sg.get("nodes") - inner = next( - ( - n - for n in (nodes if isinstance(nodes, list) else []) - if isinstance(n, dict) and str(n.get("id")) == current.source_node - ), - None, - ) + inner = _inner_node(current_sg, current.source_node) inner_def = defs.get(str(inner.get("type", ""))) if inner is not None else None if inner_def is None or current.source_input is None: return None @@ -1138,7 +1130,7 @@ def resolve_write( ) if link is not None: origin = link.get("origin_id") - origin_node = next((n for n in parent_def.get("nodes") or [] if str(n.get("id")) == str(origin)), None) + origin_node = _inner_node(parent_def, origin) raise ValueError( f"{given} is fed by interior node {'/'.join(segments[:-1])}/{origin} " f"({origin_node.get('type') if origin_node else '?'}) — that link supplies the value, so a widget " @@ -1388,7 +1380,7 @@ def as_promoted_input(self, sg: dict) -> PromotedInput: validation/source-port lookup a linked promotion gets applies.""" if self.plan == PLAN_PRIMITIVE: tid, slot = self.targets[0] - target = next((n for n in sg.get("nodes") or [] if str(n.get("id")) == tid), None) + target = _inner_node(sg, tid) entry = (target.get("inputs") or [])[slot] if target is not None else None marker = entry.get("widget") if isinstance(entry, dict) else None widget = marker.get("name") if isinstance(marker, dict) and marker.get("name") else entry.get("name") diff --git a/comfy_cli/skills/comfy/SKILL.md b/comfy_cli/skills/comfy/SKILL.md index 6efa6e288..b1c08fb74 100644 --- a/comfy_cli/skills/comfy/SKILL.md +++ b/comfy_cli/skills/comfy/SKILL.md @@ -1082,8 +1082,10 @@ comfy --json workflow slots path.json # a promoted subgraph widget row (.) carries # source_address when its interior widget resolves — the interior widget # it stands for, e.g. 57/28.unet_name (the real widget name, even when -# the promotion is renamed). Optional: a row whose source does not -# resolve omits it. Read-only context: edit at the row's own address +# the promotion is renamed). Optional: a row omits it when its source +# does not resolve, when the value comes from an interior PrimitiveNode, +# or when the input is only a legacy proxyWidgets entry. Read-only +# context: edit at the row's own address # 2. Set a single slot comfy workflow set-slot path.json 6.text="a cat" diff --git a/tests/comfy_cli/command/test_workflow_slots.py b/tests/comfy_cli/command/test_workflow_slots.py index a27958d33..884a20a2e 100644 --- a/tests/comfy_cli/command/test_workflow_slots.py +++ b/tests/comfy_cli/command/test_workflow_slots.py @@ -1211,3 +1211,15 @@ def test_uncatalogued_interior_class_keeps_source_address(self, patched_promoted env = _run(["slots", str(path)], capsys) row = {s["address"]: s for s in env["data"]["slots"]}["57.unet_name"] assert row["source_address"] == "57/28.unet_name" + + def test_null_interior_node_does_not_crash_the_chain(self, patched_subgraph_graph, tmp_path, capsys): + # Every other walk skips a non-dict ``nodes`` entry; the source chain + # must too rather than raising out of ``slots`` with no envelope. + wf = _subgraph_workflow() + for sg in wf["definitions"]["subgraphs"]: + sg["nodes"].insert(0, None) + path = _write_workflow(tmp_path, wf) + env = _run(["slots", str(path)], capsys) + assert env["ok"] is True + by_addr = {s["address"]: s for s in env["data"]["slots"]} + assert by_addr["10.value"]["source_address"] == "10/3/7.value" From ca6f1c29bbec36122aeb3d770dbc879c8d3562d0 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 19 Oct 2026 09:10:38 +0000 Subject: [PATCH 4/5] fix(workflow): omit source_address for an unselected dynamic-combo sub-widget A promoted dynamic-combo sub-widget (model.max_images) passed the declaration check whenever its selector was a dynamic combo, even when the saved selection does not expose it. Check the sub-widget against the interior node's value-aware widget order before publishing the address. The terminal-node walk is shared with promoted_source_port. Co-Authored-By: Claude Opus 5.5 --- comfy_cli/cql/engine.py | 34 ++++++++++++++----- .../comfy_cli/command/test_workflow_slots.py | 26 ++++++++++++++ 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/comfy_cli/cql/engine.py b/comfy_cli/cql/engine.py index 207620dd2..c1b84a514 100644 --- a/comfy_cli/cql/engine.py +++ b/comfy_cli/cql/engine.py @@ -5330,28 +5330,44 @@ class the catalog does not know is trusted as saved).""" head = widget.split(".", 1)[0] if head == widget or not any(p.name == head and p.is_dynamic_combo for p in m.inputs): return None + # …and only the SELECTED option's sub-widgets exist on the node. + node = _promoted_source_node(sg, path, defs) + values = _widgets_as_positional(node.get("widgets_values") if node else None, graph, class_type) + if widget not in graph.widget_order_for_node(class_type, values): + return None return f"{_SUBGRAPH_PATH_SEP.join([instance_id, *path])}.{widget}" -def promoted_source_port(sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) -> tuple[str, Port | None]: - """``(interior class, Port)`` of the concrete widget behind promoted input - ``pi`` — the schema a host value is validated against.""" +def _promoted_source_node(sg: dict, path: list[str], defs: dict[str, dict]) -> dict | None: + """The terminal interior node at the end of a promoted source ``path``, + descending into nested subgraph definitions; ``None`` if any hop is missing.""" from comfy_cli.cql import promoted as _promoted - target = _promoted.deepest_source(sg, pi, defs) - if target is None: - return "", None - path, widget = target current_sg = sg node: dict | None = None for seg in path: node = _promoted._inner_node(current_sg, seg) if node is None: - return "", None + return None nxt = defs.get(str(node.get("type", ""))) if nxt is not None: current_sg = nxt - class_type = str(node.get("type", "")) if node else "" + return node + + +def promoted_source_port(sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) -> tuple[str, Port | None]: + """``(interior class, Port)`` of the concrete widget behind promoted input + ``pi`` — the schema a host value is validated against.""" + from comfy_cli.cql import promoted as _promoted + + target = _promoted.deepest_source(sg, pi, defs) + if target is None: + return "", None + path, widget = target + node = _promoted_source_node(sg, path, defs) + if node is None: + return "", None + class_type = str(node.get("type", "")) m = graph.node(class_type) if m is None: return class_type, None diff --git a/tests/comfy_cli/command/test_workflow_slots.py b/tests/comfy_cli/command/test_workflow_slots.py index 884a20a2e..46e8d78fb 100644 --- a/tests/comfy_cli/command/test_workflow_slots.py +++ b/tests/comfy_cli/command/test_workflow_slots.py @@ -1223,3 +1223,29 @@ def test_null_interior_node_does_not_crash_the_chain(self, patched_subgraph_grap assert env["ok"] is True by_addr = {s["address"]: s for s in env["data"]["slots"]} assert by_addr["10.value"]["source_address"] == "10/3/7.value" + + @pytest.mark.parametrize( + ("selection", "widget", "expected"), + [ + ("seedream 5.0 pro", "model.size_preset", "50/1.model.size_preset"), + # max_images exists only on the lite option: the saved pro + # selection has no such widget, so no dangling address. + ("seedream 5.0 pro", "model.max_images", None), + ("seedream 5.0 lite", "model.max_images", "50/1.model.max_images"), + ("seedream 5.0 pro", "model.bogus", None), + ], + ) + def test_dynamic_combo_sub_widget_follows_saved_selection(self, selection, widget, expected): + from comfy_cli.cql import engine as cql_engine + from comfy_cli.cql.promoted import PromotedInput + + inner = _seedream_workflow()["nodes"][0] + if selection == "seedream 5.0 lite": + # lite inlines size_preset, width, height, max_images, fail_on_partial. + inner["widgets_values"] = ["p", selection, "(1K) 1024x1024 (1:1)", 2048, 2048, 3, False, 0, "fixed", False] + else: + assert inner["widgets_values"][1] == selection + pi = PromotedInput( + name=widget, type="INT", index=0, value_index=0, source_node="1", source_input=widget, source_widget=widget + ) + assert cql_engine._promoted_source_address("50", {"nodes": [inner]}, pi, {}, _seedream_graph()) == expected From 9ea95762905413df73a5c2aef04ec5e8c8e5e900 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Wed, 28 Oct 2026 06:34:34 +0000 Subject: [PATCH 5/5] fix(workflow): check promoted dynamic-combo sub-widgets against the effective selector A promoted selector's host value runs over the interior's saved option, so source_address now checks a sub-widget against that option (a live link keeps the saved one). Docs: plain proxyWidgets fallback rows omit source_address; repaired legacy entries carry it. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 +- comfy_cli/cql/engine.py | 68 +++++++++++++++++-- comfy_cli/skills/comfy/SKILL.md | 3 +- .../comfy_cli/command/test_workflow_slots.py | 51 ++++++++++++++ 4 files changed, 118 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eea5df66..441534e4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ history. (`57/28.unet_name`), resolved through nested promotions and renamed inputs. The key is optional: a row omits it when its interior widget does not resolve, when its value comes from an interior PrimitiveNode, or when the - input is backed only by a legacy `proxyWidgets` entry. + input is a plain legacy `proxyWidgets` fallback (a legacy entry that will be + repaired into a linked input does carry it). The row's `address` is unchanged and stays the one to edit. - `comfy build init`, `update` and `validate` carry `data.warnings[]` as `{code, message}` under `--json`. `build_comfy_version_missing` means the diff --git a/comfy_cli/cql/engine.py b/comfy_cli/cql/engine.py index c1b84a514..f442b3ae6 100644 --- a/comfy_cli/cql/engine.py +++ b/comfy_cli/cql/engine.py @@ -5267,7 +5267,9 @@ def _declared_subgraph_slots( if linked_from is not None: slot["linked_from"] = linked_from if pi is not None and pi.is_widget: - source_address = _promoted_source_address(instance_id, sg, pi, defs, graph) + source_address = _promoted_source_address( + instance_id, sg, pi, defs, graph, instance, scope if scope is not None else workflow + ) if source_address is not None: slot["source_address"] = source_address declared.append(slot) @@ -5299,20 +5301,38 @@ def _declared_subgraph_slots( # that may feed several widgets; source_address names one concrete # widget, so these rows omit it (documented in SKILL.md). if entry.plan == _promoted.PLAN_CREATE: - source_address = _promoted_source_address(instance_id, sg, entry.as_promoted_input(sg), defs, graph) + source_address = _promoted_source_address( + instance_id, + sg, + entry.as_promoted_input(sg), + defs, + graph, + instance, + scope if scope is not None else workflow, + ) if source_address is not None: slot["source_address"] = source_address declared.append(slot) return declared, (any_declared and all_resolved) -def _promoted_source_address(instance_id: str, sg: dict, pi: Any, defs: dict[str, dict], graph: Graph) -> str | None: +def _promoted_source_address( + instance_id: str, + sg: dict, + pi: Any, + defs: dict[str, dict], + graph: Graph, + instance: dict | None = None, + scope: dict | None = None, +) -> str | None: """``/[/…].`` — the concrete interior widget a promoted row stands for, through any nested promotion chain. Informational only: the row is still edited at ``.``. ``None`` when the chain does not resolve to a live interior widget: a missing interior node, or a widget the catalog says that class lacks (a - class the catalog does not know is trusted as saved).""" + class the catalog does not know is trusted as saved). A dynamic-combo + sub-widget is checked against the option execution selects — a promoted + selector's host value (``instance`` in ``scope``) over the interior one.""" from comfy_cli.cql import promoted as _promoted target = _promoted.deepest_source(sg, pi, defs) @@ -5333,11 +5353,49 @@ class the catalog does not know is trusted as saved).""" # …and only the SELECTED option's sub-widgets exist on the node. node = _promoted_source_node(sg, path, defs) values = _widgets_as_positional(node.get("widgets_values") if node else None, graph, class_type) - if widget not in graph.widget_order_for_node(class_type, values): + selected = _promoted_selector_value(instance, scope, sg, path, head, defs) + order = graph.widget_order_for_node(class_type, values) + if selected is not _promoted.UNSET and head in order and order.index(head) < len(values): + values = list(values) + values[order.index(head)] = selected + order = graph.widget_order_for_node(class_type, values) + if widget not in order: return None return f"{_SUBGRAPH_PATH_SEP.join([instance_id, *path])}.{widget}" +def _promoted_selector_value( + instance: dict | None, scope: dict | None, sg: dict, path: list[str], selector: str, defs: dict[str, dict] +) -> Any: + """The host value execution writes over the interior dynamic-combo + ``selector`` at the end of ``path`` when that selector is itself promoted + — outermost host first, as the converter's overlay lets an outer host win. + :data:`promoted.UNSET` when no host materializes it, or when a live link + feeds it (its value is only known at run time), so the caller keeps the + interior's saved selection.""" + from comfy_cli.cql import promoted as _promoted + + current_instance, current_scope, current_sg = instance, scope, sg + for depth in range(len(path)): + if current_instance is None or current_scope is None: + break + remaining = path[depth:] + for spi in _promoted.promoted_inputs(current_sg, defs): + if not spi.is_widget or _promoted.deepest_source(current_sg, spi, defs) != (remaining, selector): + continue + if _promoted.live_external_link(current_scope, current_instance, spi.name, current_sg) is not None: + return _promoted.UNSET + value = _promoted.host_value(current_instance, spi) + if value is not _promoted.UNSET: + return value + inner = _promoted._inner_node(current_sg, remaining[0]) + inner_def = defs.get(str(inner.get("type", ""))) if inner is not None else None + if inner_def is None: + break + current_instance, current_scope, current_sg = inner, current_sg, inner_def + return _promoted.UNSET + + def _promoted_source_node(sg: dict, path: list[str], defs: dict[str, dict]) -> dict | None: """The terminal interior node at the end of a promoted source ``path``, descending into nested subgraph definitions; ``None`` if any hop is missing.""" diff --git a/comfy_cli/skills/comfy/SKILL.md b/comfy_cli/skills/comfy/SKILL.md index b1c08fb74..32250d71e 100644 --- a/comfy_cli/skills/comfy/SKILL.md +++ b/comfy_cli/skills/comfy/SKILL.md @@ -1084,7 +1084,8 @@ comfy --json workflow slots path.json # it stands for, e.g. 57/28.unet_name (the real widget name, even when # the promotion is renamed). Optional: a row omits it when its source # does not resolve, when the value comes from an interior PrimitiveNode, -# or when the input is only a legacy proxyWidgets entry. Read-only +# or when the input is a plain legacy proxyWidgets fallback (a legacy +# entry the CLI will repair into a linked input does carry it). Read-only # context: edit at the row's own address # 2. Set a single slot diff --git a/tests/comfy_cli/command/test_workflow_slots.py b/tests/comfy_cli/command/test_workflow_slots.py index 46e8d78fb..43726d4c3 100644 --- a/tests/comfy_cli/command/test_workflow_slots.py +++ b/tests/comfy_cli/command/test_workflow_slots.py @@ -1249,3 +1249,54 @@ def test_dynamic_combo_sub_widget_follows_saved_selection(self, selection, widge name=widget, type="INT", index=0, value_index=0, source_node="1", source_input=widget, source_widget=widget ) assert cql_engine._promoted_source_address("50", {"nodes": [inner]}, pi, {}, _seedream_graph()) == expected + + @pytest.mark.parametrize( + ("host_selection", "linked", "expected"), + [ + # The host's promoted selector runs over the interior's saved + # "pro", so lite's max_images is the live widget. + ("seedream 5.0 lite", False, "50/1.model.max_images"), + ("seedream 5.0 pro", False, None), + # A link feeds the selector: its value is only known at run time, + # so the interior's saved selection (pro) decides. + ("seedream 5.0 lite", True, None), + ], + ) + def test_dynamic_combo_sub_widget_follows_promoted_selector(self, host_selection, linked, expected): + from comfy_cli.cql import engine as cql_engine + from comfy_cli.cql import promoted as _promoted + + inner = _seedream_workflow()["nodes"][0] + assert inner["widgets_values"][1] == "seedream 5.0 pro" + base = len(inner.get("inputs") or []) + inner["inputs"] = list(inner.get("inputs") or []) + [ + {"name": "model", "type": "COMBO", "widget": {"name": "model"}, "link": 1}, + {"name": "model.max_images", "type": "INT", "widget": {"name": "model.max_images"}, "link": 2}, + ] + sg = { + "id": "sg-seedream", + "nodes": [inner], + "inputs": [ + {"name": "model", "type": "COMBO", "linkIds": [1]}, + {"name": "max_images", "type": "INT", "linkIds": [2]}, + ], + "links": [ + {"id": 1, "origin_id": -10, "origin_slot": 0, "target_id": 1, "target_slot": base, "type": "COMBO"}, + {"id": 2, "origin_id": -10, "origin_slot": 1, "target_id": 1, "target_slot": base + 1, "type": "INT"}, + ], + } + defs = {"sg-seedream": sg} + instance = { + "id": 50, + "type": "sg-seedream", + "inputs": [{"name": "model", "link": 99 if linked else None}, {"name": "max_images", "link": None}], + "widgets_values": [host_selection, 3], + } + workflow = { + "nodes": [instance, {"id": 60, "type": "PrimitiveNode"}], + "links": [[99, 60, 0, 50, 0, "COMBO"]] if linked else [], + "definitions": {"subgraphs": [sg]}, + } + pi = _promoted.find_promoted(sg, defs, "max_images") + address = cql_engine._promoted_source_address("50", sg, pi, defs, _seedream_graph(), instance, workflow) + assert address == expected