feat(HEL-892): add pinned MP3 and mixed LayerStyle reference profiles

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-30 02:32:15 +08:00
co-authored by multica-agent
parent a8cd8e8ac5
commit 8ed420ebac
4 changed files with 619 additions and 6 deletions
@@ -25,9 +25,12 @@ from calliope.comfyui.serialization_reference import (
ASR_PROFILE,
AUX_PROFILE,
CASE04_PROFILE,
MEDIA_PROFILES,
MP3_PROFILE,
PREVIEW_PROFILE,
PRIMITIVE_PROFILE,
PROFILE,
REEL_PROFILE,
resolve_reference_link,
serialize_case04_node,
serialize_promoted_node,
@@ -283,6 +286,7 @@ REFERENCE_PROFILES = (
*PROMOTED_PROFILES,
CASE04_PROFILE,
ASR_PROFILE,
*MEDIA_PROFILES,
)
@@ -367,6 +371,69 @@ def asr_field_evidence(source, prompt):
return fields
def media_field_evidence(source, prompt, profile):
"""Independent final byte pointers, including every class/input/title/link."""
layouts = {
"LoadAudio": ("audio",),
"SaveAudioMP3": ("filename_prefix", "quality"),
"LoadImage": ("image",),
"PreviewImage": (),
"LayerUtility: ImageReel": (
"image1_text",
"image2_text",
"image3_text",
"image4_text",
"reel_height",
"border",
),
"LayerUtility: ImageReelComposit": ("font_file", "font_size", "border", "color_theme"),
}
fields = []
for index, node in enumerate(source["nodes"]):
nid = str(node["id"])
if nid not in prompt:
continue
actual = prompt[nid]
assert actual["class_type"] == node["type"]
assert actual["_meta"] == {"title": node.get("title") or node["type"]}
names = layouts[node["type"]]
for name, value in actual["inputs"].items():
socket = next((s for s in node["inputs"] if s["name"] == name), {})
if socket.get("link") is not None:
li, link = next(
(i, link) for i, link in enumerate(source["links"]) if link[0] == socket["link"]
)
expected = [str(link[1]), link[2]]
pointer, rule = f"/links/{li}", "original final endpoint ID/slot"
elif name in names:
wi = names.index(name)
expected = node["widgets_values"][wi]
pointer, rule = f"/nodes/{index}/widgets_values/{wi}", "fixed constructor identity"
else:
assert name == "audioUI"
expected = ""
pointer, rule = None, "1.37.11 DOM getter without getValue; not a descriptor"
assert type(value) is type(expected) and value == expected
fields.append(
{
"node_id": nid,
"class_type": node["type"],
"class_pointer": f"/nodes/{index}/type",
"title_pointer": f"/nodes/{index}/title"
if node.get("title")
else f"/nodes/{index}/type",
"field": name,
"value": value,
"json_type": type(value).__name__,
"source_pointer": pointer,
"rule": rule,
"profile": profile,
"contract_manifest": "media-reference/contract.json",
}
)
return fields
def profile_attempt(source, profile):
expected = {**STRUCTURE_PROFILES, **PROMOTED_PROFILES, CASE04_PROFILE: "1.53.6"}.get(
profile, "1.37.11"
@@ -385,7 +452,19 @@ def profile_attempt(source, profile):
if profile == AUX_PROFILE
else None,
"aux_release_artifact_match": "unknown" if profile == AUX_PROFILE else "not_used",
"media_reference": (
{"core": "0.11.0@09725967cf76304371c390ca1d6483e04061da48"}
if profile == MP3_PROFILE
else {
"core": "0.4.0@fc657f471a29d07696ca16b566000e8e555d67d1",
"ImageReel": "4f4d5cbbe40e030a5a0bb474fb65c4032585bc3c",
"ImageReelComposit": "42ccdd8f75ab312285eaa77073a5cc20bdba484c",
}
if profile == REEL_PROFILE
else None
),
"reference_sources": [
"media-reference/sources.json",
"serialization-evidence/sources.json",
"structure-reference/sources.json",
"controlnet-reference/sources.json",
@@ -397,7 +476,9 @@ def profile_attempt(source, profile):
declared_frontend = (source.get("extra") or {}).get("frontendVersion")
assumptions["source_frontend_declaration"] = declared_frontend
assumptions["missing_frontend_policy"] = (
"explicit_legacy_reference_assumption"
"explicit_media_reference_assumption"
if profile in MEDIA_PROFILES
else "explicit_legacy_reference_assumption"
if profile in (PROFILE, AUX_PROFILE, PRIMITIVE_PROFILE)
else "requires_explicit_declaration"
)
@@ -408,7 +489,8 @@ def profile_attempt(source, profile):
and (n["provider"] is None or n["version"] is None)
]
if declared_frontend != expected and not (
declared_frontend is None and profile in (PROFILE, AUX_PROFILE, PRIMITIVE_PROFILE)
declared_frontend is None
and profile in (PROFILE, AUX_PROFILE, PRIMITIVE_PROFILE, *MEDIA_PROFILES)
):
return {
**base,
@@ -444,6 +526,8 @@ def profile_attempt(source, profile):
**(
{"field_evidence": asr_field_evidence(source, result.prompt)}
if profile == ASR_PROFILE
else {"field_evidence": media_field_evidence(source, result.prompt, profile)}
if profile in MEDIA_PROFILES
else {}
),
}
@@ -545,7 +629,7 @@ def audit_library(repo: Path, profiles=REFERENCE_PROFILES):
row["source_path"]
for row in rows
if any(
a["status"] == "complete_reference_candidate" and a["profile"] != ASR_PROFILE
a["status"] == "complete_reference_candidate" and a["profile"] not in MEDIA_PROFILES
for a in row["attempts"]
)
}
@@ -555,7 +639,7 @@ def audit_library(repo: Path, profiles=REFERENCE_PROFILES):
"source_total": len(manifest),
"target_total": len(rows) + len(api_paths),
"coverage_delta": {
"baseline": "all previous profiles excluding ASR_PROFILE; applied this run",
"baseline": "previous eleven profiles excluding MEDIA_PROFILES; applied this run",
"previous_complete_paths": sorted(old_complete),
"current_complete_paths": sorted(now_complete),
"new_complete_paths": sorted(now_complete - old_complete),
@@ -592,6 +676,7 @@ def main():
"--profile",
choices=(
ASR_PROFILE,
*MEDIA_PROFILES,
PROFILE,
AUX_PROFILE,
PRIMITIVE_PROFILE,
@@ -12,6 +12,10 @@ from __future__ import annotations
from typing import Any
MP3_PROFILE = "comfy-frontend-1.37.11-mp3-core-0.11.0-reference"
REEL_PROFILE = "comfy-frontend-1.37.11-layerstyle-mixed-core-0.4.0-reference"
MEDIA_PROFILES = (MP3_PROFILE, REEL_PROFILE)
ASR_PROFILE = "comfy-frontend-1.37.11-asr-b037d7be-reference"
PROFILE = "comfy-frontend-1.37.11-core-reference"
AUX_PROFILE = "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference"
@@ -82,6 +86,8 @@ def reference_definitions(profile: str = PROFILE) -> dict[str, Any]:
"output": outputs,
}
if profile in MEDIA_PROFILES:
return media_definitions(profile)
if profile == ASR_PROFILE:
definitions = reference_definitions(PREVIEW_PROFILE)
return {
@@ -154,6 +160,8 @@ def reference_definitions(profile: str = PROFILE) -> dict[str, Any]:
def serialize_reference_widgets(node: dict[str, Any], profile: str = PROFILE) -> dict[str, Any]:
"""Apply only the pinned identity serializers; reject any extra/missing value."""
if profile in MEDIA_PROFILES:
return serialize_media_node(node, profile)
if profile == ASR_PROFILE:
if any(k in node for k in ("widgets", "widgets_values_named", "serializeValue")):
raise ValueError("ASR参考不支持自定义控件/serializer覆盖")
@@ -1019,3 +1027,160 @@ def _serialize_asr(node):
):
raise ValueError("ASR输入类型/具名控件绑定不符")
return result
# Explicit mixed-version reference assumptions, never inferred target versions.
# sources: media-reference/sources.json and reused structure/serialization sources.
_REEL_VERSION = "4f4d5cbbe40e030a5a0bb474fb65c4032585bc3c"
_COMPOSIT_VERSION = "42ccdd8f75ab312285eaa77073a5cc20bdba484c"
_MEDIA_LAYOUTS = {
"LoadAudio": (("audio", str),),
"SaveAudioMP3": (("filename_prefix", str), ("quality", str)),
"LoadImage": (("image", str),),
"PreviewImage": (),
"LayerUtility: ImageReel": (
("image1_text", str),
("image2_text", str),
("image3_text", str),
("image4_text", str),
("reel_height", int),
("border", int),
),
"LayerUtility: ImageReelComposit": (
("font_file", str),
("font_size", int),
("border", int),
("color_theme", str),
),
}
def media_definitions(profile):
def spec(required, outputs, optional=None):
return {
"input": {
"required": {k: [v] for k, v in required.items()},
"optional": {k: [v] for k, v in (optional or {}).items()},
},
"output": outputs,
}
if profile == MP3_PROFILE:
return {
"LoadAudio": spec({"audio": "COMBO"}, ["AUDIO"], {"audioUI": "AUDIO_UI"}),
"SaveAudioMP3": spec(
{"audio": "AUDIO", "filename_prefix": "STRING", "quality": "COMBO"},
[],
{"audioUI": "AUDIO_UI"},
),
}
if profile != REEL_PROFILE:
raise ValueError("未知媒体参考版本")
return {
"LoadImage": spec({"image": "COMBO"}, ["IMAGE", "MASK"]),
"PreviewImage": spec({"images": "IMAGE"}, []),
"LayerUtility: ImageReel": spec(
{
"image1": "IMAGE",
**{f"image{i}_text": "STRING" for i in range(1, 5)},
"reel_height": "INT",
"border": "INT",
},
["Reel"],
{f"image{i}": "IMAGE" for i in range(2, 5)},
),
"LayerUtility: ImageReelComposit": spec(
{
"reel_1": "Reel",
"font_file": "COMBO",
"font_size": "INT",
"border": "INT",
"color_theme": "COMBO",
},
["IMAGE"],
{f"reel_{i}": "Reel" for i in range(2, 5)},
),
}
def serialize_media_node(node, profile):
"""Only original constructors, with explicit missing declaration assumptions.
Font/file strings prove neither membership nor availability. Audio UI is a
DOM getter, not a file descriptor. No encoding, plugin, or queue hooks run.
"""
ct, props = node.get("type"), node.get("properties") or {}
definitions = media_definitions(profile)
if ct not in definitions or node.get("mode", 0) != 0:
raise ValueError("节点类型/模式不在媒体固定参考契约内")
if any(k in node for k in ("widgets", "widgets_values_named", "serializeValue")):
raise ValueError("媒体参考不支持自定义控件/serializer覆盖")
provider = "comfyui_layerstyle" if ct.startswith("LayerUtility:") else "comfy-core"
version = (
_REEL_VERSION
if ct == "LayerUtility: ImageReel"
else _COMPOSIT_VERSION
if ct == "LayerUtility: ImageReelComposit"
else "0.11.0"
if profile == MP3_PROFILE
else "0.4.0"
)
# Audio has neither declaration; allow absence only in this labeled profile.
if any(
props.get(k) != v and not (profile == MP3_PROFILE and props.get(k) is None)
for k, v in (("cnr_id", provider), ("ver", version))
):
raise ValueError("媒体节点提供方/版本与固定参考冲突")
layout = _MEDIA_LAYOUTS[ct]
values = node.get("widgets_values", [])
count = len(layout) + (2 if ct == "LoadAudio" else 1 if ct == "LoadImage" else 0)
if not isinstance(values, list) or len(values) != count:
raise ValueError("媒体节点控件数量/形式与固定参考不符")
if ct == "LoadAudio" and (values[1] is not None or values[2] not in (None, "")):
raise ValueError("LoadAudio仅支持DOM空洞及上传按钮占位,不支持录音/自定义布局")
if ct == "LoadImage" and values[-1] != "image":
raise ValueError("LoadImage上传按钮占位不符")
result = {}
for (name, kind), value in zip(layout, values):
if type(value) is not kind:
raise ValueError(f"媒体字段{name}类型不符")
if kind is str and ("{" in value or "}" in value or "%" in value):
raise ValueError(f"媒体字段{name}含未覆盖动态表达式")
result[name] = value
if ct == "SaveAudioMP3" and result["quality"] not in ("V0", "128k", "320k"):
raise ValueError("MP3 quality静态枚举不符")
if ct == "LayerUtility: ImageReelComposit" and result["color_theme"] not in ("light", "dark"):
raise ValueError("ImageReelComposit color_theme静态枚举不符")
bounds = (
{"reel_height": (64, 2048), "border": (8, 512)}
if ct == "LayerUtility: ImageReel"
else {"font_size": (4, 1024), "border": (8, 512)}
if ct == "LayerUtility: ImageReelComposit"
else {}
)
for name, (low, high) in bounds.items():
if not low <= result[name] <= high:
raise ValueError(f"媒体字段{name}超出固定范围")
spec = definitions[ct]["input"]
slots = {k: v[0] for k, v in {**spec["required"], **spec["optional"]}.items()}
widgets = {name for name, _ in layout}
if ct in ("LoadAudio", "SaveAudioMP3"):
widgets.add("audioUI")
if ct in ("LoadAudio", "LoadImage"):
slots["upload"] = "AUDIOUPLOAD" if ct == "LoadAudio" else "IMAGEUPLOAD"
widgets.add("upload")
sockets = node.get("inputs", [])
if len(sockets) != len(slots) or {s.get("name") for s in sockets} != set(slots):
raise ValueError("媒体输入槽缺失/重复/额外")
for socket in sockets:
name = socket["name"]
if socket.get("type") != slots[name] or socket.get("widget") != (
{"name": name} if name in widgets else None
):
raise ValueError("媒体输入类型/具名控件绑定不符")
# Do not infer widget-to-link coercions, converted widgets, or UI links.
if name in widgets and socket.get("link") is not None:
raise ValueError("媒体控件连线转换未证明")
if ct in ("LoadAudio", "SaveAudioMP3"):
result["audioUI"] = ""
return result
@@ -17,6 +17,7 @@ from .serialization_reference import (
ASR_PROFILE,
AUX_PROFILE,
CASE04_PROFILE,
MEDIA_PROFILES,
PREVIEW_PROFILE,
PRIMITIVE_PROFILE,
PROFILE,
@@ -59,6 +60,7 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
not in (
PROFILE,
ASR_PROFILE,
*MEDIA_PROFILES,
AUX_PROFILE,
PRIMITIVE_PROFILE,
PREVIEW_PROFILE,
@@ -122,6 +124,10 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
and (source.get("extra") or {}).get("frontendVersion") != "1.37.11"
):
raise ValueError("PreviewAny 需要显式1.37.11前端声明")
if profile in MEDIA_PROFILES and any(
node.get("type") == "Reroute" for node in source.get("nodes", [])
):
raise ValueError("媒体最小参考仅覆盖直接连线,不扩展虚拟节点")
original = source
if profile in (PRIMITIVE_PROFILE, PREVIEW_PROFILE):
source = fold_reference_primitives(source, profile)
@@ -133,7 +139,7 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
except (ValueError, TypeError, KeyError, AttributeError, IndexError) as exc:
return Conversion(None, [{"code": "invalid_reference_contract", "message": str(exc)}], True)
result.reference_only = True
if profile == ASR_PROFILE:
if profile in (ASR_PROFILE, *MEDIA_PROFILES):
result.serialization_stage = "restored_saved_state_before_queue_hooks"
return result
@@ -214,6 +220,12 @@ def _convert(
for lid in links:
try:
resolve_reference_link(nodes, links, lid)
if reference_profile in MEDIA_PROFILES:
link = links[lid]
upstream = nodes[str(link[1])]["outputs"][link[2]]
downstream = nodes[str(link[3])]["inputs"][link[4]]
if link[5] != upstream.get("type") or link[5] != downstream.get("type"):
raise ValueError("媒体连线类型记录与两端槽不符")
except (ValueError, TypeError, KeyError, AttributeError) as exc:
fail("reference_link_invalid", str(exc))
prompt = {}
@@ -259,7 +271,8 @@ def _convert(
names = [s.get("name") for s in node.get("inputs", [])]
allowed = set(declared) | ({"upload"} if ct == "LoadImage" else set())
if (
reference_profile in (PRIMITIVE_PROFILE, PREVIEW_PROFILE, ASR_PROFILE)
reference_profile
in (PRIMITIVE_PROFILE, PREVIEW_PROFILE, ASR_PROFILE, *MEDIA_PROFILES)
and ct == "LoadAudio"
):
allowed |= {"upload", "audioUI"}
@@ -0,0 +1,350 @@
"""Real saved bytes and synthetic mutations; no codec, fonts, or target execution."""
from __future__ import annotations
import ast
import copy
import json
from pathlib import Path
import pytest
from scripts import audit_reference_conversion as audit
from calliope.comfyui.serialization_reference import MEDIA_PROFILES, MP3_PROFILE, REEL_PROFILE
from calliope.comfyui.ui2api import convert, convert_reference
REPO = Path(__file__).resolve().parents[2]
BASE = "example_ComfyUI_workflows/0-基础处理:图像合并-音频分离-视频截取合并-图像视频放大/"
FILES = {MP3_PROFILE: "音频转MP3格式.json", REEL_PROFILE: "图像嵌入文字描述.json"}
def graph(profile):
return json.loads((REPO / BASE / FILES[profile]).read_bytes())
@pytest.mark.parametrize("profile", MEDIA_PROFILES)
def test_real_candidate_all_fields_links_and_types_have_original_byte_pointers(profile):
source = graph(profile)
original = copy.deepcopy(source)
attempt = audit.profile_attempt(source, profile)
assert attempt["status"] == "complete_reference_candidate"
assert attempt["assumptions"]["source_frontend_declaration"] is None
assert (
attempt["assumptions"]["missing_frontend_policy"] == "explicit_media_reference_assumption"
)
assert attempt["assumptions"]["target_version_match"] == "unknown"
result = convert_reference(source, profile)
assert result.reference_only and result.prompt and not result.issues
assert result.serialization_stage == "restored_saved_state_before_queue_hooks"
assert source == original and convert(source).prompt is None
prompt = result.prompt
assert set(prompt) == {str(n["id"]) for n in source["nodes"]}
for n in source["nodes"]:
actual = prompt[str(n["id"])]
assert actual["class_type"] == n["type"]
assert actual["_meta"] == {"title": n.get("title") or n["type"]}
# AST only, proving the fixed upstream constructor order independently.
if profile == REEL_PROFILE:
for version, clsname, expected in [
(
"4f4d5cbb",
"ImageReel",
[
"image1",
"image1_text",
"image2_text",
"image3_text",
"image4_text",
"reel_height",
"border",
],
),
(
"42ccdd8f",
"ImageReelComposit",
["reel_1", "font_file", "font_size", "border", "color_theme"],
),
]:
path = (
REPO
/ f"docs/hel-892/media-reference/ComfyUI_LayerStyle__{version}__py__image_reel.py"
)
tree = ast.parse(path.read_text())
cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == clsname)
method = next(
n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == "INPUT_TYPES"
)
schema = next(n.value for n in ast.walk(method) if isinstance(n, ast.Return))
required = next(v for k, v in zip(schema.keys, schema.values) if k.value == "required")
assert [k.value for k in required.keys] == expected
mapping = next(
n.value
for n in tree.body
if isinstance(n, ast.Assign)
and any(
isinstance(t, ast.Name) and t.id == "NODE_CLASS_MAPPINGS" for t in n.targets
)
)
assert ("LayerUtility: " + clsname, clsname) in [
(k.value, v.id) for k, v in zip(mapping.keys, mapping.values)
]
else:
assert prompt["4"]["inputs"] == {
"filename_prefix": "audio/ComfyUI",
"quality": "V0",
"audioUI": "",
"audio": ["1", 0],
}
assert prompt["1"]["inputs"] == {
"audio": source["nodes"][1]["widgets_values"][0],
"audioUI": "",
}
fields = attempt["field_evidence"]
assert len(fields) == sum(len(n["inputs"]) for n in prompt.values())
for field in fields:
if field["source_pointer"] is None:
assert field["field"] == "audioUI" and field["value"] == ""
continue
value = source
for part in field["source_pointer"].split("/")[1:]:
value = value[int(part)] if isinstance(value, list) else value[part]
expected = (
[str(value[1]), value[2]] if field["source_pointer"].startswith("/links/") else value
)
assert type(expected) is type(field["value"]) and expected == field["value"]
@pytest.mark.parametrize("quality", ["V0", "128k", "320k"])
def test_mp3_changed_file_prefix_and_quality_propagate_without_encoding(quality):
source = graph(MP3_PROFILE)
source["nodes"][0]["widgets_values"] = ["新目录/测试", quality]
source["nodes"][1]["widgets_values"][0] = "different input.wav"
prompt = convert_reference(source, MP3_PROFILE).prompt
assert prompt["4"]["inputs"]["filename_prefix"] == "新目录/测试"
assert prompt["4"]["inputs"]["quality"] == quality
assert prompt["1"]["inputs"]["audio"] == "different input.wav"
assert prompt["4"]["inputs"]["audio"] == ["1", 0]
def test_reel_text_sizes_dynamic_font_and_two_images_remain_independent():
source = graph(REEL_PROFILE)
source["nodes"][0]["widgets_values"][0] = "one.png"
source["nodes"][1]["widgets_values"][0] = "two.png"
source["nodes"][2]["widgets_values"] = ["", "第二行\n第三行", "three", "four", 1024, 64]
source["nodes"][3]["widgets_values"] = ["unverified-font.ttf", 72, 16, "dark"]
prompt = convert_reference(source, REEL_PROFILE).prompt
assert prompt["3"]["inputs"] == {"image": "one.png"}
assert prompt["4"]["inputs"] == {"image": "two.png"}
assert prompt["1"]["inputs"] == {
"image1_text": "",
"image2_text": "第二行\n第三行",
"image3_text": "three",
"image4_text": "four",
"reel_height": 1024,
"border": 64,
"image1": ["3", 0],
"image2": ["4", 0],
}
assert prompt["2"]["inputs"] == {
"font_file": "unverified-font.ttf",
"font_size": 72,
"border": 16,
"color_theme": "dark",
"reel_1": ["1", 0],
}
assert prompt["5"]["inputs"] == {"images": ["2", 0]}
@pytest.mark.parametrize("profile", MEDIA_PROFILES)
@pytest.mark.parametrize(
"mutation",
[
"extra",
"missing",
"null",
"boolean",
"enum",
"provider",
"version",
"frontend",
"custom",
"binding",
"slot_type",
"missing_socket",
"duplicate_socket",
"output",
"mode",
"link",
"link_type",
"widget_link",
"dynamic",
],
)
def test_bad_assumptions_close_whole_graph(profile, mutation):
source = graph(profile)
node = source["nodes"][0] if profile == MP3_PROFILE else source["nodes"][2]
wi = 0 if profile == MP3_PROFILE else 4
if mutation == "extra":
node["widgets_values"].append("custom")
elif mutation == "missing":
node["widgets_values"].pop()
elif mutation == "null":
node["widgets_values"][wi] = None
elif mutation == "boolean":
node["widgets_values"][wi] = True
elif mutation == "enum":
if profile == MP3_PROFILE:
node["widgets_values"][1] = "V3"
else:
source["nodes"][3]["widgets_values"][3] = "unknown"
elif mutation == "provider":
node["properties"]["cnr_id"] = "different"
elif mutation == "version":
node["properties"]["ver"] = "0.38.0"
elif mutation == "frontend":
source["extra"]["frontendVersion"] = "1.53.6"
elif mutation == "custom":
node["serializeValue"] = "custom"
elif mutation == "binding":
next(s for s in node["inputs"] if s.get("widget"))["widget"] = {"name": "wrong"}
elif mutation == "slot_type":
node["inputs"][0]["type"] = "STRING"
elif mutation == "missing_socket":
node["inputs"].pop()
elif mutation == "duplicate_socket":
node["inputs"].append(copy.deepcopy(node["inputs"][-1]))
elif mutation == "output":
source["nodes"][1]["outputs"][0]["type"] = "STRING"
elif mutation == "mode":
node["mode"] = 2
elif mutation == "link":
source["links"][0][2] = 999
elif mutation == "link_type":
source["links"][0][5] = "STRING"
elif mutation == "widget_link":
next(s for s in node["inputs"] if s.get("widget"))["link"] = source["links"][0][0]
elif mutation == "dynamic":
node["widgets_values"][0] = "{one|two}"
result = convert_reference(source, profile)
assert result.prompt is None and result.issues and result.reference_only
@pytest.mark.parametrize("value", [False, 1, "", "recorded.wav"])
def test_audio_dom_hole_is_not_a_serialized_file(value):
source = graph(MP3_PROFILE)
source["nodes"][1]["widgets_values"][1] = value
assert convert_reference(source, MP3_PROFILE).prompt is None
@pytest.mark.parametrize("value", [False, 3.0, 3, 1025])
def test_font_size_boolean_float_and_outside_range_are_rejected(value):
source = graph(REEL_PROFILE)
source["nodes"][3]["widgets_values"][1] = value
assert convert_reference(source, REEL_PROFILE).prompt is None
def test_mixed_plugin_commits_cannot_be_interchanged():
source = graph(REEL_PROFILE)
source["nodes"][3]["properties"]["ver"] = source["nodes"][2]["properties"]["ver"]
assert convert_reference(source, REEL_PROFILE).prompt is None
def test_library_actual_delta_keeps_old_candidates_and_no_golden_claim():
previous = audit.audit_library(
REPO, tuple(p for p in audit.REFERENCE_PROFILES if p not in MEDIA_PROFILES)
)
current = audit.audit_library(REPO)
assert (
current["coverage_delta"]["previous_complete_paths"]
== previous["coverage_delta"]["current_complete_paths"]
)
assert set(current["coverage_delta"]["new_complete_paths"]) == {
BASE + n for n in FILES.values()
}
assert current["ui_total"] == 145 and current["target_total"] == 155
for row in current["cases"]:
if row["source_path"] in current["coverage_delta"]["new_complete_paths"]:
assert row["comparison_status"] == "comparison_unavailable"
assert (
row["execution_verified"] is False and row["production_prompt_available"] is False
)
assert len(row["candidate_hashes"]) == 1
for attempt in row["attempts"]:
if attempt["status"] != "complete_reference_candidate":
assert "candidate_prompt" not in attempt
async def test_mp3_original_schema_and_synthetic_descriptor_boundary():
tree = ast.parse(
(
REPO
/ "docs/hel-892/structure-reference/ComfyUI__09725967__comfy_extras__nodes_audio.py"
).read_text()
)
cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == "SaveAudioMP3")
schema = next(
n
for n in ast.walk(cls)
if isinstance(n, ast.Call) and isinstance(n.func, ast.Attribute) and n.func.attr == "Schema"
)
inputs = next(k.value for k in schema.keywords if k.arg == "inputs")
assert [call.args[0].value for call in inputs.elts] == ["audio", "filename_prefix", "quality"]
assert ast.literal_eval(
next(k.value for k in inputs.elts[2].keywords if k.arg == "options")
) == ["V0", "128k", "320k"]
assert next(k.value.value for k in schema.keywords if k.arg == "is_output_node") is True
# Pure synthetic history shape. No serializer imports, codec, waveform or network.
from calliope.comfyui.client import ComfyUIClient
from calliope.comfyui.output_map import auto_output_map
from calliope.comfyui.registry import OUTPUT_CLASSES
# MP3 was already registered before this change; no new registry entry.
assert "SaveAudioMP3" in OUTPUT_CLASSES
prompt = convert_reference(graph(MP3_PROFILE), MP3_PROFILE).prompt
assert [e["kind"] for e in auto_output_map(prompt)] == ["audio"]
client = ComfyUIClient()
await client.close() # extraction is pure, with the transport already closed
fixture = {
"outputs": {
"4": {
"audio": [
{"filename": "synthetic_00001.mp3", "subfolder": "audio", "type": "output"}
]
}
}
}
assert client.extract_outputs(fixture, {"4": "audio"}) == [
{
"filename": "synthetic_00001.mp3",
"subfolder": "audio",
"type": "output",
"node_id": "4",
"media_kind": "audio",
}
]
for path in ["audio/synthetic_00001.mp3", "https://example.invalid/audio.mp3", ""]:
assert client.extract_outputs({"outputs": {"4": {"audio": [path]}}}, {"4": "audio"}) == []
def test_synthetic_two_reel_instances_do_not_share_text_or_size_values():
source = graph(REEL_PROFILE)
# Duplicate a complete branch, with independent IDs/links but shared source image.
reel, composit = copy.deepcopy(source["nodes"][2:4])
reel["id"], composit["id"] = 11, 12
reel["inputs"][0]["link"] = 12
reel["inputs"][1]["link"] = None
reel["outputs"][0]["links"] = [11]
reel["widgets_values"] = ["other", "", "three", "four", 768, 16]
composit["inputs"][0]["link"] = 11
composit["outputs"][0]["links"] = []
composit["widgets_values"] = ["another-font.otf", 60, 8, "dark"]
source["nodes"][0]["outputs"][0]["links"].append(12)
source["nodes"].extend([reel, composit])
source["links"].extend([[12, 3, 0, 11, 0, "IMAGE"], [11, 11, 0, 12, 0, "Reel"]])
prompt = convert_reference(source, REEL_PROFILE).prompt
assert prompt["1"]["inputs"]["image1_text"] == "image1"
assert prompt["11"]["inputs"]["image1_text"] == "other"
assert prompt["11"]["inputs"]["reel_height"] == 768
assert prompt["12"]["inputs"]["font_size"] == 60
assert prompt["2"]["inputs"]["font_size"] == 40
assert prompt["12"]["inputs"]["reel_1"] == ["11", 0]