HEL-892: record pinned VHS node evidence and protected library coverage
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,931 @@
|
||||
diff --git a/calliope-backend/scripts/audit_reference_conversion.py b/calliope-backend/scripts/audit_reference_conversion.py
|
||||
index 9f5c2a7..c0e5169 100644
|
||||
--- a/calliope-backend/scripts/audit_reference_conversion.py
|
||||
+++ b/calliope-backend/scripts/audit_reference_conversion.py
|
||||
@@ -33,6 +33,7 @@ from calliope.comfyui.serialization_reference import (
|
||||
PROFILE,
|
||||
REEL_PROFILE,
|
||||
SEPARATION_PROFILE,
|
||||
+ VHS_PROFILES,
|
||||
resolve_reference_link,
|
||||
serialize_case04_node,
|
||||
serialize_promoted_node,
|
||||
@@ -291,6 +292,7 @@ REFERENCE_PROFILES = (
|
||||
*MEDIA_PROFILES,
|
||||
SEPARATION_PROFILE,
|
||||
*CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
)
|
||||
|
||||
|
||||
@@ -455,10 +457,45 @@ def media_field_evidence(source, prompt, profile):
|
||||
return fields
|
||||
|
||||
|
||||
+def vhs_field_evidence(source, prompt):
|
||||
+ """Re-read every final field from named source bytes or original links."""
|
||||
+ fields = []
|
||||
+ for i, node in enumerate(source["nodes"]):
|
||||
+ nid = str(node["id"])
|
||||
+ assert prompt[nid]["class_type"] == node["type"]
|
||||
+ assert prompt[nid]["_meta"] == {"title": node.get("title") or node["type"]}
|
||||
+ for name, value in prompt[nid]["inputs"].items():
|
||||
+ socket = next(s for s in node["inputs"] if s["name"] == name)
|
||||
+ if socket.get("link") is not None:
|
||||
+ li, link = next(
|
||||
+ (j, edge) for j, edge in enumerate(source["links"]) if edge[0] == socket["link"]
|
||||
+ )
|
||||
+ expected = [str(link[1]), link[2]]
|
||||
+ pointer = f"/links/{li}"
|
||||
+ else:
|
||||
+ expected = node["widgets_values"][name]
|
||||
+ pointer = f"/nodes/{i}/widgets_values/{name}"
|
||||
+ assert type(value) is type(expected) and value == expected
|
||||
+ fields.append(
|
||||
+ {
|
||||
+ "node_id": nid,
|
||||
+ "class_type": node["type"],
|
||||
+ "field": name,
|
||||
+ "value": value,
|
||||
+ "json_type": type(value).__name__,
|
||||
+ "source_pointer": pointer,
|
||||
+ }
|
||||
+ )
|
||||
+ return fields
|
||||
+
|
||||
+
|
||||
def profile_attempt(source, profile):
|
||||
- expected = {**STRUCTURE_PROFILES, **PROMOTED_PROFILES, CASE04_PROFILE: "1.53.6"}.get(
|
||||
- profile, "1.37.11"
|
||||
- )
|
||||
+ expected = {
|
||||
+ **STRUCTURE_PROFILES,
|
||||
+ **PROMOTED_PROFILES,
|
||||
+ CASE04_PROFILE: "1.53.6",
|
||||
+ **VHS_PROFILES,
|
||||
+ }.get(profile, "1.37.11")
|
||||
assumptions = {
|
||||
"frontend": expected,
|
||||
"unmodified_frontend_and_widgets": True,
|
||||
@@ -522,8 +559,20 @@ def profile_attempt(source, profile):
|
||||
"separation-reference/sources.json",
|
||||
*assumptions["reference_sources"],
|
||||
]
|
||||
+ if profile in VHS_PROFILES:
|
||||
+ assumptions["vhs_reference"] = {
|
||||
+ "contracts": "vhs-reference/contract.json",
|
||||
+ "unmodified_pinned_plugin_and_format_files": True,
|
||||
+ "extension_overrides_and_target_installation": "unknown",
|
||||
+ "named_mirror": "if present, assumed inert and required equal to VHS map",
|
||||
+ "array_migration": "unsupported; never fill missing fields from defaults",
|
||||
+ }
|
||||
+ assumptions["reference_sources"] = [
|
||||
+ "vhs-reference/sources.json",
|
||||
+ "serialization-evidence/sources.json",
|
||||
+ ]
|
||||
base = {"profile": profile, "assumptions": assumptions}
|
||||
- if profile in CROP_SPLIT_PROFILES:
|
||||
+ if profile in (*CROP_SPLIT_PROFILES, *VHS_PROFILES):
|
||||
base["source_declarations"] = [
|
||||
{
|
||||
"pointer": f"/nodes/{i}",
|
||||
@@ -531,32 +580,48 @@ def profile_attempt(source, profile):
|
||||
}
|
||||
for i, n in enumerate(source.get("nodes", []))
|
||||
]
|
||||
- base["verified_reference_facts"] = "crop-split-reference/verified-facts.json"
|
||||
+ base["verified_reference_facts"] = (
|
||||
+ "vhs-reference/contract.json"
|
||||
+ if profile in VHS_PROFILES
|
||||
+ else "crop-split-reference/verified-facts.json"
|
||||
+ )
|
||||
declared_frontend = (source.get("extra") or {}).get("frontendVersion")
|
||||
assumptions["source_frontend_declaration"] = declared_frontend
|
||||
+ if profile in VHS_PROFILES:
|
||||
+ assumptions["vhs_reference"]["missing_frontend_policy"] = (
|
||||
+ "explicit_1.37.11_reference_assumption"
|
||||
+ if expected == "1.37.11"
|
||||
+ else "requires_explicit_1.48.6"
|
||||
+ )
|
||||
assumptions["missing_frontend_policy"] = (
|
||||
"explicit_media_reference_assumption"
|
||||
- if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES)
|
||||
+ if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES, *VHS_PROFILES)
|
||||
else "explicit_legacy_reference_assumption"
|
||||
if profile in (PROFILE, AUX_PROFILE, PRIMITIVE_PROFILE)
|
||||
else "requires_explicit_declaration"
|
||||
)
|
||||
+ if profile in VHS_PROFILES and expected == "1.48.6":
|
||||
+ assumptions["missing_frontend_policy"] = "requires_explicit_1.48.6"
|
||||
assumptions["missing_node_declarations"] = [
|
||||
n["pointer"]
|
||||
for n in node_inventory(source, include_aux=profile in CROP_SPLIT_PROFILES)
|
||||
if n["type"] not in ("Note", "MarkdownNote", "Reroute", "PrimitiveNode")
|
||||
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,
|
||||
- *MEDIA_PROFILES,
|
||||
- SEPARATION_PROFILE,
|
||||
- *CROP_SPLIT_PROFILES,
|
||||
+ if (profile in VHS_PROFILES and expected == "1.48.6" and declared_frontend is None) or (
|
||||
+ declared_frontend != expected
|
||||
+ and not (
|
||||
+ declared_frontend is None
|
||||
+ and profile
|
||||
+ in (
|
||||
+ PROFILE,
|
||||
+ AUX_PROFILE,
|
||||
+ PRIMITIVE_PROFILE,
|
||||
+ *MEDIA_PROFILES,
|
||||
+ SEPARATION_PROFILE,
|
||||
+ *CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
+ )
|
||||
)
|
||||
):
|
||||
return {
|
||||
@@ -593,8 +658,10 @@ def profile_attempt(source, profile):
|
||||
**(
|
||||
{"field_evidence": asr_field_evidence(source, result.prompt)}
|
||||
if profile == ASR_PROFILE
|
||||
+ else {"field_evidence": vhs_field_evidence(source, result.prompt)}
|
||||
+ if profile in VHS_PROFILES
|
||||
else {"field_evidence": media_field_evidence(source, result.prompt, profile)}
|
||||
- if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES)
|
||||
+ if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES, *VHS_PROFILES)
|
||||
else {}
|
||||
),
|
||||
}
|
||||
@@ -698,7 +765,10 @@ def audit_library(repo: Path, profiles=REFERENCE_PROFILES, *, baseline_profiles=
|
||||
for cohort in ("without_companion", "with_companion")
|
||||
}
|
||||
if baseline_profiles is None:
|
||||
- baseline_profiles = tuple(p for p in profiles if p not in CROP_SPLIT_PROFILES)
|
||||
+ excluded_profiles = (
|
||||
+ VHS_PROFILES if any(p in VHS_PROFILES for p in profiles) else CROP_SPLIT_PROFILES
|
||||
+ )
|
||||
+ baseline_profiles = tuple(p for p in profiles if p not in excluded_profiles)
|
||||
old_complete = {
|
||||
row["source_path"]
|
||||
for row in rows
|
||||
@@ -754,6 +824,7 @@ def main():
|
||||
*MEDIA_PROFILES,
|
||||
SEPARATION_PROFILE,
|
||||
*CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
PROFILE,
|
||||
AUX_PROFILE,
|
||||
PRIMITIVE_PROFILE,
|
||||
diff --git a/calliope-backend/src/calliope/comfyui/serialization_reference.py b/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
||||
index afd2ea5..b79a15d 100644
|
||||
--- a/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
||||
+++ b/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
||||
@@ -10,6 +10,7 @@ installation is inferred.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
+import json
|
||||
import math
|
||||
from typing import Any
|
||||
|
||||
@@ -22,6 +23,13 @@ CROP_PROFILE = "comfy-frontend-1.37.11-audio-crop-1.4.0-core-0.3.68-reference"
|
||||
SPLIT_PROFILE = "comfy-frontend-1.37.11-guhai-885cac3d-core-0.21.1-reference"
|
||||
CROP_SPLIT_PROFILES = (CROP_PROFILE, SPLIT_PROFILE)
|
||||
|
||||
+VHS_COMBINE_COMMIT = "4ee72c065db22c9d96c2427954dc69e7b908444b"
|
||||
+VHS_LOAD_COMMIT = "8550981384301e9bc5bfea83e5c2c75258102593"
|
||||
+VHS_PROFILES = {
|
||||
+ "comfy-frontend-1.37.11-vhs-pinned-reference": "1.37.11",
|
||||
+ "comfy-frontend-1.48.6-vhs-pinned-reference": "1.48.6",
|
||||
+}
|
||||
+
|
||||
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"
|
||||
@@ -92,6 +100,8 @@ def reference_definitions(profile: str = PROFILE) -> dict[str, Any]:
|
||||
"output": outputs,
|
||||
}
|
||||
|
||||
+ if profile in VHS_PROFILES:
|
||||
+ return vhs_definitions()
|
||||
if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES):
|
||||
return media_definitions(profile)
|
||||
if profile == ASR_PROFILE:
|
||||
@@ -166,6 +176,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 VHS_PROFILES:
|
||||
+ return serialize_vhs_node(node)
|
||||
if profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES):
|
||||
return serialize_media_node(node, profile)
|
||||
if profile == ASR_PROFILE:
|
||||
@@ -1316,3 +1328,186 @@ def serialize_media_node(node, profile):
|
||||
if ct in ("LoadAudio", "SaveAudioMP3", "PreviewAudio"):
|
||||
result["audioUI"] = ""
|
||||
return result
|
||||
+
|
||||
+
|
||||
+# Only named-map state with every execution field present is covered. VHS's
|
||||
+# legacy six-value arrays run migrations/default fallbacks and are rejected.
|
||||
+# Sources: docs/hel-892/vhs-reference/{4ee72c06,85509813}/ and sources.json.
|
||||
+_VHS_COMBINE = {
|
||||
+ "frame_rate": "FLOAT",
|
||||
+ "loop_count": "INT",
|
||||
+ "filename_prefix": "STRING",
|
||||
+ "format": "COMBO",
|
||||
+ "pingpong": "BOOLEAN",
|
||||
+ "save_output": "BOOLEAN",
|
||||
+ "pix_fmt": "COMBO",
|
||||
+ "crf": "INT",
|
||||
+ "save_metadata": "BOOLEAN",
|
||||
+ "trim_to_audio": "BOOLEAN",
|
||||
+}
|
||||
+_VHS_LOAD = {
|
||||
+ "video": "COMBO",
|
||||
+ "force_rate": "FLOAT",
|
||||
+ "custom_width": "INT",
|
||||
+ "custom_height": "INT",
|
||||
+ "frame_load_cap": "INT",
|
||||
+ "skip_first_frames": "INT",
|
||||
+ "select_every_nth": "INT",
|
||||
+ "format": "COMBO",
|
||||
+}
|
||||
+
|
||||
+
|
||||
+def vhs_definitions():
|
||||
+ """Two fixed classes, h264-mp4/AnimateDiff, IMAGE without VAE only."""
|
||||
+
|
||||
+ def spec(required, optional, output):
|
||||
+ return {
|
||||
+ "input": {
|
||||
+ "required": {k: [v] for k, v in required.items()},
|
||||
+ "optional": {k: [v] for k, v in optional.items()},
|
||||
+ },
|
||||
+ "output": output,
|
||||
+ }
|
||||
+
|
||||
+ return {
|
||||
+ "VHS_VideoCombine": spec(
|
||||
+ {"images": "IMAGE", **_VHS_COMBINE},
|
||||
+ {"audio": "AUDIO", "meta_batch": "VHS_BatchManager", "vae": "VAE"},
|
||||
+ ["VHS_FILENAMES"],
|
||||
+ ),
|
||||
+ "VHS_LoadVideo": spec(
|
||||
+ {k: v for k, v in _VHS_LOAD.items() if k != "format"},
|
||||
+ {"meta_batch": "VHS_BatchManager", "vae": "VAE", "format": "COMBO"},
|
||||
+ ["IMAGE", "INT", "AUDIO", "VHS_VIDEOINFO"],
|
||||
+ ),
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+def serialize_vhs_node(node):
|
||||
+ """Bounded restored state, before queue hooks; never run preview callbacks.
|
||||
+
|
||||
+ VHS useKVState calls callbacks during restore (unlike plain core restore).
|
||||
+ Accept only values that are fixed points of the pinned callbacks. UI state
|
||||
+ is persisted by onSerialize despite options.serialize=false, but excluded
|
||||
+ from graphToPrompt. This does not assert target extensions or file access.
|
||||
+ """
|
||||
+ ct, props = node.get("type"), node.get("properties") or {}
|
||||
+ if ct not in vhs_definitions():
|
||||
+ raise ValueError("VHS固定参考未覆盖此类")
|
||||
+ expected = VHS_COMBINE_COMMIT if ct == "VHS_VideoCombine" else VHS_LOAD_COMMIT
|
||||
+ if (
|
||||
+ props.get("cnr_id") != "comfyui-videohelpersuite"
|
||||
+ or props.get("ver") != expected
|
||||
+ or props.get("aux_id") is not None
|
||||
+ or type(node.get("mode", 0)) is not int
|
||||
+ or node.get("mode", 0) != 0
|
||||
+ ):
|
||||
+ raise ValueError("VHS提供方/完整提交/模式冲突;不使用发布号替代")
|
||||
+ for container in (node, props):
|
||||
+ if any(k in container for k in ("widgets", "serializeValue", "comfyDynamic")):
|
||||
+ raise ValueError("VHS自定义控件或serializer覆盖未知")
|
||||
+ ue = props.get("ue_properties") or {}
|
||||
+ if "widgets_values_named" in props or any(
|
||||
+ ue.get(k) for k in ("widget_ue_connectable", "input_ue_unconnectable")
|
||||
+ ):
|
||||
+ raise ValueError("VHS不覆盖UE控件改写")
|
||||
+ layout = _VHS_COMBINE if ct == "VHS_VideoCombine" else _VHS_LOAD
|
||||
+ values = node.get("widgets_values")
|
||||
+ # Upload button is skipped on restore and options.serialize=false in prompt.
|
||||
+ allowed = set(layout) | {"videopreview"}
|
||||
+ if ct == "VHS_LoadVideo":
|
||||
+ allowed.add("choose video to upload")
|
||||
+ if not isinstance(values, dict) or not set(layout) <= set(values) <= allowed:
|
||||
+ raise ValueError("VHS仅覆盖完整具名对象;数组迁移/缺项/额外动态项不补默认")
|
||||
+ named = node.get("widgets_values_named")
|
||||
+ if named is not None and (
|
||||
+ type(named) is not dict
|
||||
+ or json.dumps(named, sort_keys=True, allow_nan=False)
|
||||
+ != json.dumps(values, sort_keys=True, allow_nan=False)
|
||||
+ ):
|
||||
+ raise ValueError("VHS额外具名镜像冲突")
|
||||
+ if "choose video to upload" in values and values["choose video to upload"] != "image":
|
||||
+ raise ValueError("VHS上传按钮占位未知")
|
||||
+ preview = values.get("videopreview")
|
||||
+ if preview is not None and (
|
||||
+ type(preview) is not dict
|
||||
+ or set(preview) - {"hidden", "paused", "params", "muted"}
|
||||
+ or any(type(preview[k]) is not bool for k in ("hidden", "paused", "muted") if k in preview)
|
||||
+ or ("params" in preview and type(preview["params"]) is not dict)
|
||||
+ ):
|
||||
+ raise ValueError("VHS持久化预览状态形状未知")
|
||||
+ result = {}
|
||||
+ for name, kind in layout.items():
|
||||
+ value = values[name]
|
||||
+ valid = (
|
||||
+ type(value) in (int, float) and math.isfinite(value)
|
||||
+ if kind == "FLOAT"
|
||||
+ else type(value) is int
|
||||
+ if kind == "INT"
|
||||
+ else type(value) is bool
|
||||
+ if kind == "BOOLEAN"
|
||||
+ else type(value) is str
|
||||
+ )
|
||||
+ if not valid or (type(value) is int and abs(value) > 2**53 - 1):
|
||||
+ raise ValueError(f"VHS字段{name}类型或JavaScript精确整数范围不符")
|
||||
+ if type(value) is str and any(t in value for t in ("%", "{", "}")):
|
||||
+ raise ValueError("VHS动态表达式不在字面量参考内")
|
||||
+ result[name] = value
|
||||
+ bounds = (
|
||||
+ {"frame_rate": (1, float("inf")), "loop_count": (0, 100), "crf": (0, 100)}
|
||||
+ if ct == "VHS_VideoCombine"
|
||||
+ else {
|
||||
+ "force_rate": (0, 60),
|
||||
+ "custom_width": (0, 8192),
|
||||
+ "custom_height": (0, 8192),
|
||||
+ "frame_load_cap": (0, 2**53 - 1),
|
||||
+ "skip_first_frames": (0, 2**53 - 1),
|
||||
+ "select_every_nth": (1, 2**53 - 1),
|
||||
+ }
|
||||
+ )
|
||||
+ for name, (low, high) in bounds.items():
|
||||
+ if not low <= result[name] <= high:
|
||||
+ raise ValueError(f"VHS字段{name}超出固定参考边界")
|
||||
+ if ct == "VHS_VideoCombine":
|
||||
+ if result["format"] != "video/h264-mp4" or result["pix_fmt"] not in (
|
||||
+ "yuv420p",
|
||||
+ "yuv420p10le",
|
||||
+ ):
|
||||
+ raise ValueError("VHS仅证明固定h264-mp4及其四项动态控件")
|
||||
+ elif result["format"] != "AnimateDiff" or any(
|
||||
+ result[k] % 8 for k in ("custom_width", "custom_height")
|
||||
+ ):
|
||||
+ raise ValueError("VHS仅证明AnimateDiff;尺寸必须是恢复回调的不变点(8倍数或0)")
|
||||
+ spec = vhs_definitions()[ct]["input"]
|
||||
+ slots = {k: v[0] for k, v in {**spec["required"], **spec["optional"]}.items()}
|
||||
+ sockets = node.get("inputs", [])
|
||||
+ names = [s.get("name") for s in sockets]
|
||||
+ if len(names) != len(set(names)) or set(names) != set(slots):
|
||||
+ raise ValueError("VHS输入槽缺失/额外/重复")
|
||||
+ for socket in sockets:
|
||||
+ name = socket["name"]
|
||||
+ expected_type = ["yuv420p", "yuv420p10le"] if name == "pix_fmt" else slots[name]
|
||||
+ # Some original workflow exports store the dynamic combo as COMBO;
|
||||
+ # both are the pinned config's exact two-option combo representation.
|
||||
+ valid_type = (
|
||||
+ socket.get("type") in (expected_type, "COMBO")
|
||||
+ if name == "pix_fmt"
|
||||
+ else socket.get("type") == expected_type
|
||||
+ )
|
||||
+ if not valid_type:
|
||||
+ raise ValueError("VHS输入槽类型与固定schema不符")
|
||||
+ if socket.get("widget") != ({"name": name} if name in layout else None):
|
||||
+ raise ValueError("VHS具名控件绑定不符")
|
||||
+ if socket.get("link") is not None and (
|
||||
+ name in ("vae", "meta_batch") or (name in layout and name != "frame_rate")
|
||||
+ ):
|
||||
+ raise ValueError("VHS控件转连线/VAE/批次模式未覆盖")
|
||||
+ outputs = node.get("outputs", [])
|
||||
+ if [s.get("type") for s in outputs] != vhs_definitions()[ct]["output"]:
|
||||
+ raise ValueError("VHS返回类型/槽不符")
|
||||
+ for i, socket in enumerate(outputs):
|
||||
+ if "slot_index" in socket and (
|
||||
+ type(socket["slot_index"]) is not int or socket["slot_index"] != i
|
||||
+ ):
|
||||
+ raise ValueError("VHS原输出槽索引冲突")
|
||||
+ return result
|
||||
diff --git a/calliope-backend/src/calliope/comfyui/ui2api.py b/calliope-backend/src/calliope/comfyui/ui2api.py
|
||||
index af4228a..5dd00ff 100644
|
||||
--- a/calliope-backend/src/calliope/comfyui/ui2api.py
|
||||
+++ b/calliope-backend/src/calliope/comfyui/ui2api.py
|
||||
@@ -23,6 +23,7 @@ from .serialization_reference import (
|
||||
PRIMITIVE_PROFILE,
|
||||
PROFILE,
|
||||
SEPARATION_PROFILE,
|
||||
+ VHS_PROFILES,
|
||||
case04_definitions,
|
||||
fold_reference_primitives,
|
||||
promoted_definitions,
|
||||
@@ -65,6 +66,7 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
||||
*MEDIA_PROFILES,
|
||||
SEPARATION_PROFILE,
|
||||
*CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
AUX_PROFILE,
|
||||
PRIMITIVE_PROFILE,
|
||||
PREVIEW_PROFILE,
|
||||
@@ -81,6 +83,12 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
||||
True,
|
||||
)
|
||||
try:
|
||||
+ if (
|
||||
+ profile in VHS_PROFILES
|
||||
+ and VHS_PROFILES[profile] == "1.48.6"
|
||||
+ and (source.get("extra") or {}).get("frontendVersion") != "1.48.6"
|
||||
+ ):
|
||||
+ raise ValueError("VHS 1.48.6参考要求显式前端声明;缺失仅选择1.37.11")
|
||||
if profile in (*STRUCTURE_PROFILES, *PROMOTED_PROFILES, CASE04_PROFILE):
|
||||
case04 = profile == CASE04_PROFILE
|
||||
promoted = profile in PROMOTED_PROFILES or case04
|
||||
@@ -128,11 +136,14 @@ 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, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES) and any(
|
||||
- node.get("type") == "Reroute" for node in source.get("nodes", [])
|
||||
- ):
|
||||
+ if profile in (
|
||||
+ *MEDIA_PROFILES,
|
||||
+ SEPARATION_PROFILE,
|
||||
+ *CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
+ ) and any(node.get("type") == "Reroute" for node in source.get("nodes", [])):
|
||||
raise ValueError("媒体最小参考仅覆盖直接连线,不扩展虚拟节点")
|
||||
- if profile in (SEPARATION_PROFILE, *CROP_SPLIT_PROFILES) and any(
|
||||
+ if profile in (SEPARATION_PROFILE, *CROP_SPLIT_PROFILES, *VHS_PROFILES) and any(
|
||||
(source.get("extra") or {}).get(k) for k in ("ue_links", "links_added_by_ue")
|
||||
):
|
||||
raise ValueError("音频分离参考不覆盖UE附加连线")
|
||||
@@ -147,7 +158,13 @@ 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 in (ASR_PROFILE, *MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES):
|
||||
+ if profile in (
|
||||
+ ASR_PROFILE,
|
||||
+ *MEDIA_PROFILES,
|
||||
+ SEPARATION_PROFILE,
|
||||
+ *CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
+ ):
|
||||
result.serialization_stage = "restored_saved_state_before_queue_hooks"
|
||||
return result
|
||||
|
||||
@@ -208,6 +225,7 @@ def _convert(
|
||||
**STRUCTURE_PROFILES,
|
||||
**PROMOTED_PROFILES,
|
||||
CASE04_PROFILE: "1.53.6",
|
||||
+ **VHS_PROFILES,
|
||||
}.get(reference_profile, "1.37.11")
|
||||
if frontend_version is not None and frontend_version != expected_version:
|
||||
fail("reference_frontend_mismatch", "源图声明的前端版本与固定参考不一致")
|
||||
@@ -228,7 +246,12 @@ def _convert(
|
||||
for lid in links:
|
||||
try:
|
||||
resolve_reference_link(nodes, links, lid)
|
||||
- if reference_profile in (*MEDIA_PROFILES, SEPARATION_PROFILE, *CROP_SPLIT_PROFILES):
|
||||
+ if reference_profile in (
|
||||
+ *MEDIA_PROFILES,
|
||||
+ SEPARATION_PROFILE,
|
||||
+ *CROP_SPLIT_PROFILES,
|
||||
+ *VHS_PROFILES,
|
||||
+ ):
|
||||
link = links[lid]
|
||||
upstream = nodes[str(link[1])]["outputs"][link[2]]
|
||||
downstream = nodes[str(link[3])]["inputs"][link[4]]
|
||||
diff --git a/calliope-backend/tests/test_audio_separation_reference.py b/calliope-backend/tests/test_audio_separation_reference.py
|
||||
index 99879b2..c8d5a9e 100644
|
||||
--- a/calliope-backend/tests/test_audio_separation_reference.py
|
||||
+++ b/calliope-backend/tests/test_audio_separation_reference.py
|
||||
@@ -359,7 +359,11 @@ def test_old_mp3_profile_rejects_real_graph_and_new_profile_rejects_old_core():
|
||||
|
||||
def test_library_actual_delta_keeps_every_old_attempt_and_all_six_golden_comparisons():
|
||||
previous = json.loads((REPO / "docs/hel-892/media-evidence/library.json").read_bytes())
|
||||
- profiles = tuple(p for p in audit.REFERENCE_PROFILES if p not in audit.CROP_SPLIT_PROFILES)
|
||||
+ profiles = tuple(
|
||||
+ p
|
||||
+ for p in audit.REFERENCE_PROFILES
|
||||
+ if p not in (*audit.CROP_SPLIT_PROFILES, *audit.VHS_PROFILES)
|
||||
+ )
|
||||
baseline = tuple(p for p in profiles if p != SEPARATION_PROFILE)
|
||||
old = audit.audit_library(REPO, baseline)
|
||||
current = audit.audit_library(REPO, profiles, baseline_profiles=baseline)
|
||||
diff --git a/calliope-backend/tests/test_crop_split_reference.py b/calliope-backend/tests/test_crop_split_reference.py
|
||||
index ef9fa0f..dd9f46a 100644
|
||||
--- a/calliope-backend/tests/test_crop_split_reference.py
|
||||
+++ b/calliope-backend/tests/test_crop_split_reference.py
|
||||
@@ -16,6 +16,7 @@ from calliope.comfyui.serialization_reference import (
|
||||
CROP_SPLIT_PROFILES,
|
||||
SEPARATION_PROFILE,
|
||||
SPLIT_PROFILE,
|
||||
+ VHS_PROFILES,
|
||||
serialize_reference_widgets,
|
||||
)
|
||||
from calliope.comfyui.ui2api import convert, convert_reference
|
||||
@@ -350,12 +351,13 @@ def test_two_disjoint_instances_preserve_nodes_links_and_values(profile):
|
||||
|
||||
|
||||
def test_all_old_fourteen_profiles_attempts_gaps_and_six_differences_unchanged():
|
||||
- profiles = tuple(p for p in audit.REFERENCE_PROFILES if p not in CROP_SPLIT_PROFILES)
|
||||
+ historical_profiles = tuple(p for p in audit.REFERENCE_PROFILES if p not in VHS_PROFILES)
|
||||
+ profiles = tuple(p for p in historical_profiles if p not in CROP_SPLIT_PROFILES)
|
||||
historical = json.loads((REPO / "docs/hel-892/separation-evidence/library.json").read_bytes())
|
||||
baseline = audit.audit_library(REPO, profiles)
|
||||
- current = audit.audit_library(REPO)
|
||||
+ current = audit.audit_library(REPO, historical_profiles)
|
||||
assert baseline["gap_groups"] == historical["gap_groups"]
|
||||
- assert len(profiles) == 14 and len(audit.REFERENCE_PROFILES) == 16
|
||||
+ assert len(profiles) == 14 and len(historical_profiles) == 16
|
||||
assert current["coverage_delta"]["baseline_profiles"] == list(profiles)
|
||||
assert current["coverage_delta"]["new_complete_paths"] == [CROP]
|
||||
assert len(current["coverage_delta"]["current_complete_paths"]) == 8
|
||||
diff --git a/calliope-backend/tests/test_vhs_reference.py b/calliope-backend/tests/test_vhs_reference.py
|
||||
new file mode 100644
|
||||
index 0000000..20d016d
|
||||
--- /dev/null
|
||||
+++ b/calliope-backend/tests/test_vhs_reference.py
|
||||
@@ -0,0 +1,375 @@
|
||||
+"""Pinned source bytes and synthetic graphs only; no plugins/media are executed."""
|
||||
+
|
||||
+from __future__ import annotations
|
||||
+
|
||||
+import ast
|
||||
+import copy
|
||||
+import hashlib
|
||||
+import json
|
||||
+from pathlib import Path
|
||||
+
|
||||
+import pytest
|
||||
+from scripts import audit_reference_conversion as audit
|
||||
+from scripts.verify_frontend_sources import verify
|
||||
+
|
||||
+from calliope.comfyui.serialization_reference import (
|
||||
+ VHS_COMBINE_COMMIT,
|
||||
+ VHS_LOAD_COMMIT,
|
||||
+ VHS_PROFILES,
|
||||
+ serialize_vhs_node,
|
||||
+)
|
||||
+from calliope.comfyui.ui2api import convert, convert_reference
|
||||
+
|
||||
+REPO = Path(__file__).resolve().parents[2]
|
||||
+ROOT = REPO / "docs/hel-892/vhs-reference"
|
||||
+PREFIX = "example_ComfyUI_workflows/0-基础处理:图像合并-音频分离-视频截取合并-图像视频放大/"
|
||||
+LOAD = PREFIX + "多视频合成分屏展示.json"
|
||||
+COMBINE = (
|
||||
+ "example_ComfyUI_workflows/4-视频生成/Minimax-h3/"
|
||||
+ "Minimax_H3_T8双时钟采样_参考生视频-8步高质量极速版.json"
|
||||
+)
|
||||
+
|
||||
+
|
||||
+def real_node(path, nid):
|
||||
+ return next(n for n in json.loads((REPO / path).read_bytes())["nodes"] if n["id"] == nid)
|
||||
+
|
||||
+
|
||||
+def synthetic():
|
||||
+ # This pair is not a source workflow, target export or encoding/history test.
|
||||
+ load, combine = real_node(LOAD, 17), real_node(COMBINE, 12)
|
||||
+ for n in (load, combine):
|
||||
+ n.pop("widgets_values_named", None)
|
||||
+ for s in n["inputs"]:
|
||||
+ s["link"] = None
|
||||
+ for s in n["outputs"]:
|
||||
+ s["links"] = []
|
||||
+ load["outputs"][0]["links"] = [1]
|
||||
+ load["outputs"][2]["links"] = [2]
|
||||
+ combine["inputs"][0]["link"] = 1
|
||||
+ combine["inputs"][1]["link"] = 2
|
||||
+ return {
|
||||
+ "nodes": [load, combine],
|
||||
+ "links": [[1, 17, 0, 12, 0, "IMAGE"], [2, 17, 2, 12, 1, "AUDIO"]],
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+def test_pinned_bytes_registration_schema_and_js_boundaries():
|
||||
+ assert len(verify(ROOT)["sources_verified"]) == len(
|
||||
+ json.loads((ROOT / "sources.json").read_bytes())["sources"]
|
||||
+ )
|
||||
+ for commit, ct, clsname, filename in (
|
||||
+ (VHS_COMBINE_COMMIT, "VHS_VideoCombine", "VideoCombine", "nodes.py"),
|
||||
+ (VHS_LOAD_COMMIT, "VHS_LoadVideo", "LoadVideoUpload", "load_video_nodes.py"),
|
||||
+ ):
|
||||
+ base = ROOT / commit[:8]
|
||||
+ tree = ast.parse((base / "videohelpersuite" / filename).read_bytes())
|
||||
+ cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == clsname)
|
||||
+ schema = next(
|
||||
+ n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == "INPUT_TYPES"
|
||||
+ )
|
||||
+ assert schema.lineno > 0
|
||||
+ mappings = (base / "videohelpersuite/nodes.py").read_text()
|
||||
+ assert f'"{ct}": {clsname},' in mappings
|
||||
+ js = (base / "web/js/VHS.core.js").read_text()
|
||||
+ assert "w.value = widgetDict[w.name];" in js
|
||||
+ assert "w.callback?.(w.value)" in js
|
||||
+ assert "info.widgets_values[w.name] = w.value;" in js
|
||||
+ assert "uploadWidget.options.serialize = false;" in js
|
||||
+ assert 'this.addDOMWidget("videopreview", "preview", element, {' in js
|
||||
+ assert "serialize: false," in js
|
||||
+ assert (
|
||||
+ 'VHS_VideoCombine : ["frame_rate", "loop_count", "filename_prefix", '
|
||||
+ '"format", "pingpong", "save_image"]' in js
|
||||
+ )
|
||||
+ fmt = json.loads((ROOT / "4ee72c06/video_formats/h264-mp4.json").read_bytes())
|
||||
+ assert fmt["main_pass"][4] == ["pix_fmt", ["yuv420p", "yuv420p10le"]]
|
||||
+ assert fmt["main_pass"][6] == ["crf", "INT", {"default": 19, "min": 0, "max": 100, "step": 1}]
|
||||
+ assert fmt["save_metadata"] == ["save_metadata", "BOOLEAN", {"default": True}]
|
||||
+ assert fmt["trim_to_audio"] == ["trim_to_audio", "BOOLEAN", {"default": False}]
|
||||
+ exe = (ROOT / "frontend-1.48.6/src/utils/executionUtil.ts").read_text()
|
||||
+ assert "widget.options?.serialize === false" in exe
|
||||
+ assert "await widget.serializeValue(node, i)" in exe
|
||||
+ wrapper = (ROOT / "frontend-1.48.6/src/scripts/utils.ts").read_text()
|
||||
+ assert "return _applyTextReplacements(app.rootGraph, value)" in wrapper
|
||||
+
|
||||
+
|
||||
+@pytest.mark.parametrize("profile", VHS_PROFILES)
|
||||
+def test_synthetic_complete_typed_fields_nonzero_audio_slot_and_ui_omission(profile):
|
||||
+ source = synthetic()
|
||||
+ if VHS_PROFILES[profile] == "1.48.6":
|
||||
+ assert convert_reference(source, profile).prompt is None
|
||||
+ assert audit.profile_attempt(source, profile)["status"] == "not_applicable"
|
||||
+ source["extra"] = {"frontendVersion": VHS_PROFILES[profile]}
|
||||
+ result = convert_reference(source, profile)
|
||||
+ assert result.prompt is not None and result.reference_only
|
||||
+ assert result.prompt["12"]["inputs"]["audio"] == ["17", 2]
|
||||
+ assert result.prompt["12"]["inputs"]["images"] == ["17", 0]
|
||||
+ assert len(audit.vhs_field_evidence(source, result.prompt)) == 20
|
||||
+ assert not any("videopreview" in n["inputs"] for n in result.prompt.values())
|
||||
+ assert not convert(source).prompt
|
||||
+ before = copy.deepcopy(result.prompt)
|
||||
+ source["nodes"][0]["widgets_values"]["videopreview"]["params"]["filename"] = "other.mp4"
|
||||
+ source["nodes"][0]["widgets_values"]["choose video to upload"] = "image"
|
||||
+ assert convert_reference(source, profile).prompt == before
|
||||
+ source["nodes"][0]["widgets_values"]["video"] = "第二个.mp4"
|
||||
+ source["nodes"][0]["widgets_values"]["skip_first_frames"] = 41
|
||||
+ source["nodes"][1]["widgets_values"]["crf"] = 37
|
||||
+ source["nodes"][1]["widgets_values"]["pix_fmt"] = "yuv420p10le"
|
||||
+ prompt = convert_reference(source, profile).prompt
|
||||
+ assert prompt["17"]["inputs"]["video"] == "第二个.mp4"
|
||||
+ assert prompt["17"]["inputs"]["skip_first_frames"] == 41
|
||||
+ assert prompt["12"]["inputs"]["crf"] == 37
|
||||
+ assert prompt["12"]["inputs"]["pix_fmt"] == "yuv420p10le"
|
||||
+
|
||||
+
|
||||
+@pytest.mark.parametrize(
|
||||
+ "index,field,value",
|
||||
+ [
|
||||
+ (0, "force_rate", True),
|
||||
+ (0, "force_rate", None),
|
||||
+ (0, "force_rate", float("inf")),
|
||||
+ (0, "force_rate", -1),
|
||||
+ (0, "force_rate", 61),
|
||||
+ (0, "video", 12),
|
||||
+ (0, "custom_width", 513),
|
||||
+ (0, "custom_height", 8193),
|
||||
+ (0, "custom_width", True),
|
||||
+ (0, "frame_load_cap", 1.2),
|
||||
+ (0, "frame_load_cap", 2**53),
|
||||
+ (0, "skip_first_frames", -1),
|
||||
+ (0, "select_every_nth", 0),
|
||||
+ (0, "format", "Wan"),
|
||||
+ (0, "format", "custom"),
|
||||
+ (1, "format", "image/webp"),
|
||||
+ (1, "format", "video/custom"),
|
||||
+ (1, "pix_fmt", "rgb24"),
|
||||
+ (1, "crf", 101),
|
||||
+ (1, "crf", True),
|
||||
+ (1, "frame_rate", float("nan")),
|
||||
+ (1, "frame_rate", 0),
|
||||
+ (1, "loop_count", -1),
|
||||
+ (1, "loop_count", 1.0),
|
||||
+ (1, "pingpong", 1),
|
||||
+ (1, "save_output", None),
|
||||
+ (1, "trim_to_audio", "false"),
|
||||
+ (1, "filename_prefix", "%date:yyyy%"),
|
||||
+ (1, "filename_prefix", "{unknown}"),
|
||||
+ ],
|
||||
+)
|
||||
+def test_invalid_fields_fail_whole_graph_without_partial_prompt(index, field, value):
|
||||
+ source = synthetic()
|
||||
+ source["nodes"][index]["widgets_values"][field] = value
|
||||
+ result = convert_reference(source, next(iter(VHS_PROFILES)))
|
||||
+ assert result.prompt is None and result.issues
|
||||
+
|
||||
+
|
||||
+@pytest.mark.parametrize(
|
||||
+ "change",
|
||||
+ [
|
||||
+ "provider",
|
||||
+ "release",
|
||||
+ "other_commit",
|
||||
+ "aux",
|
||||
+ "array",
|
||||
+ "extra_value",
|
||||
+ "missing_value",
|
||||
+ "mirror_type",
|
||||
+ "mirror_value",
|
||||
+ "binding",
|
||||
+ "socket_type",
|
||||
+ "extra_socket",
|
||||
+ "missing_socket",
|
||||
+ "mode",
|
||||
+ "bool_mode",
|
||||
+ "ue",
|
||||
+ "override",
|
||||
+ "prop_override",
|
||||
+ "vae",
|
||||
+ "batch",
|
||||
+ "extra_output",
|
||||
+ "output_type",
|
||||
+ "output_index",
|
||||
+ "bool_index",
|
||||
+ "bad_source_slot",
|
||||
+ "bad_target_slot",
|
||||
+ "bad_link_type",
|
||||
+ "missing_reciprocal",
|
||||
+ "wrong_frontend",
|
||||
+ "unknown_node",
|
||||
+ "preview_shape",
|
||||
+ ],
|
||||
+)
|
||||
+def test_contract_mutations_reject(change):
|
||||
+ source = synthetic()
|
||||
+ n = source["nodes"][0]
|
||||
+ if change == "provider":
|
||||
+ n["properties"]["cnr_id"] = "same-name-plugin"
|
||||
+ elif change == "release":
|
||||
+ n["properties"]["ver"] = "1.7.7"
|
||||
+ elif change == "other_commit":
|
||||
+ n["properties"]["ver"] = VHS_COMBINE_COMMIT
|
||||
+ elif change == "aux":
|
||||
+ n["properties"]["aux_id"] = "other"
|
||||
+ elif change == "array":
|
||||
+ n["widgets_values"] = list(n["widgets_values"].values())
|
||||
+ elif change == "extra_value":
|
||||
+ n["widgets_values"]["custom"] = 1
|
||||
+ elif change == "missing_value":
|
||||
+ del n["widgets_values"]["format"]
|
||||
+ elif change.startswith("mirror"):
|
||||
+ n["widgets_values_named"] = copy.deepcopy(n["widgets_values"])
|
||||
+ n["widgets_values_named"]["force_rate"] = 16.0 if change == "mirror_type" else 20
|
||||
+ elif change == "binding":
|
||||
+ n["inputs"][2]["widget"] = {"name": "wrong"}
|
||||
+ elif change == "socket_type":
|
||||
+ n["inputs"][2]["type"] = "STRING"
|
||||
+ elif change == "extra_socket":
|
||||
+ n["inputs"].append(copy.deepcopy(n["inputs"][0]))
|
||||
+ elif change == "missing_socket":
|
||||
+ n["inputs"].pop()
|
||||
+ elif change == "mode":
|
||||
+ n["mode"] = 4
|
||||
+ elif change == "bool_mode":
|
||||
+ n["mode"] = False
|
||||
+ elif change == "ue":
|
||||
+ n["properties"]["ue_properties"]["widget_ue_connectable"] = {"video": True}
|
||||
+ elif change == "override":
|
||||
+ n["serializeValue"] = "custom"
|
||||
+ elif change == "prop_override":
|
||||
+ n["properties"]["widgets"] = []
|
||||
+ elif change == "vae":
|
||||
+ n["inputs"][1]["link"] = 1
|
||||
+ elif change == "batch":
|
||||
+ n["inputs"][0]["link"] = 1
|
||||
+ elif change == "extra_output":
|
||||
+ n["outputs"].append({"type": "IMAGE", "links": []})
|
||||
+ elif change == "output_type":
|
||||
+ n["outputs"][0]["type"] = "LATENT"
|
||||
+ elif change == "output_index":
|
||||
+ n["outputs"][2]["slot_index"] = 0
|
||||
+ elif change == "bool_index":
|
||||
+ n["outputs"][0]["slot_index"] = False
|
||||
+ elif change == "bad_source_slot":
|
||||
+ source["links"][0][2] = 1
|
||||
+ elif change == "bad_target_slot":
|
||||
+ source["links"][0][4] = 2
|
||||
+ elif change == "bad_link_type":
|
||||
+ source["links"][0][5] = "LATENT"
|
||||
+ elif change == "missing_reciprocal":
|
||||
+ n["outputs"][0]["links"] = []
|
||||
+ elif change == "wrong_frontend":
|
||||
+ source["extra"] = {"frontendVersion": "1.7.9"}
|
||||
+ elif change == "unknown_node":
|
||||
+ source["nodes"].append({"id": 100, "type": "Unknown", "inputs": [], "outputs": []})
|
||||
+ elif change == "preview_shape":
|
||||
+ n["widgets_values"]["videopreview"] = "server/path.mp4"
|
||||
+ assert convert_reference(source, next(iter(VHS_PROFILES))).prompt is None
|
||||
+
|
||||
+
|
||||
+def test_real_five_load_instances_are_distinct_and_modes_not_dropped():
|
||||
+ source = json.loads((REPO / LOAD).read_bytes())
|
||||
+ nodes = [n for n in source["nodes"] if n["type"] == "VHS_LoadVideo"]
|
||||
+ assert len(nodes) == 5
|
||||
+ for n in nodes:
|
||||
+ if n["mode"] == 4:
|
||||
+ with pytest.raises(ValueError):
|
||||
+ serialize_vhs_node(n)
|
||||
+ else:
|
||||
+ values = serialize_vhs_node(n)
|
||||
+ assert all(
|
||||
+ type(v) is type(n["widgets_values"][k]) and v == n["widgets_values"][k]
|
||||
+ for k, v in values.items()
|
||||
+ )
|
||||
+ assert convert_reference(source, next(iter(VHS_PROFILES))).prompt is None
|
||||
+
|
||||
+
|
||||
+def test_old_sixteen_attempts_gaps_candidates_and_six_comparisons_protected():
|
||||
+ old = json.loads((REPO / "docs/hel-892/crop-split-evidence/library.json").read_bytes())
|
||||
+ profiles = tuple(p for p in audit.REFERENCE_PROFILES if p not in VHS_PROFILES)
|
||||
+ baseline = audit.audit_library(REPO, profiles)
|
||||
+ now = audit.audit_library(REPO, baseline_profiles=profiles)
|
||||
+ assert len(profiles) == 16 and len(now["profiles"]) == 18
|
||||
+ assert old["gap_groups"] == baseline["gap_groups"]
|
||||
+ for previous, before, after in zip(old["cases"], baseline["cases"], now["cases"]):
|
||||
+ assert previous["attempts"] == before["attempts"] == after["attempts"][:-2]
|
||||
+ assert previous.get("comparisons") == after.get("comparisons")
|
||||
+ assert previous["status"] == after["status"]
|
||||
+ assert previous["candidate_hashes"] == after["candidate_hashes"]
|
||||
+ assert previous["comparison_status"] == after["comparison_status"]
|
||||
+ assert len(now["coverage_delta"]["current_complete_paths"]) == 8
|
||||
+ assert now["coverage_delta"]["new_complete_paths"] == []
|
||||
+ assert now["coverage_delta"]["baseline_profiles"] == list(profiles)
|
||||
+
|
||||
+ def unavailable(r):
|
||||
+ return {
|
||||
+ c["source_path"]
|
||||
+ for c in r["cases"]
|
||||
+ if all(a["status"] == "not_applicable" for a in c["attempts"])
|
||||
+ }
|
||||
+
|
||||
+ assert unavailable(old) == unavailable(now) and len(unavailable(now)) == 98
|
||||
+ for raw in json.loads((ROOT / "sources.json").read_bytes())["sources"]:
|
||||
+ assert hashlib.sha256((ROOT / raw["local_file"]).read_bytes()).hexdigest() == raw["sha256"]
|
||||
+
|
||||
+
|
||||
+def test_disjoint_instances_values_ids_links_not_shared():
|
||||
+ first, second = synthetic(), synthetic()
|
||||
+ for n in second["nodes"]:
|
||||
+ n["id"] += 100
|
||||
+ for socket in n["inputs"]:
|
||||
+ if socket.get("link") is not None:
|
||||
+ socket["link"] += 100
|
||||
+ for socket in n["outputs"]:
|
||||
+ socket["links"] = [lid + 100 for lid in socket.get("links", [])]
|
||||
+ for link in second["links"]:
|
||||
+ for i in (0, 1, 3):
|
||||
+ link[i] += 100
|
||||
+ second["nodes"][0]["widgets_values"]["video"] = "other-file.mp4"
|
||||
+ second["nodes"][0]["widgets_values"]["force_rate"] = 29.97
|
||||
+ second["nodes"][1]["widgets_values"]["frame_rate"] = 29.97
|
||||
+ source = {"nodes": first["nodes"] + second["nodes"], "links": first["links"] + second["links"]}
|
||||
+ prompt = convert_reference(source, next(iter(VHS_PROFILES))).prompt
|
||||
+ assert set(prompt) == {"17", "12", "117", "112"}
|
||||
+ assert prompt["112"]["inputs"]["audio"] == ["117", 2]
|
||||
+ assert prompt["12"]["inputs"]["audio"] == ["17", 2]
|
||||
+ assert prompt["117"]["inputs"]["video"] == "other-file.mp4"
|
||||
+ assert prompt["17"]["inputs"]["video"] != "other-file.mp4"
|
||||
+ assert prompt["112"]["inputs"]["frame_rate"] == 29.97
|
||||
+ assert len(audit.vhs_field_evidence(source, prompt)) == 40
|
||||
+
|
||||
+
|
||||
+def test_all_five_real_combines_have_node_contract_even_when_other_nodes_close_graph():
|
||||
+ seen = []
|
||||
+ for path in (REPO / "example_ComfyUI_workflows").rglob("*"):
|
||||
+ if not path.is_file():
|
||||
+ continue
|
||||
+ source = json.loads(path.read_bytes())
|
||||
+ for n in source.get("nodes", []):
|
||||
+ if n["type"] == "VHS_VideoCombine" and n["properties"].get("ver") == VHS_COMBINE_COMMIT:
|
||||
+ frontend = source.get("extra", {}).get("frontendVersion") or "1.37.11"
|
||||
+ if frontend not in VHS_PROFILES.values():
|
||||
+ assert all(
|
||||
+ audit.profile_attempt(source, p)["status"] == "not_applicable"
|
||||
+ for p in VHS_PROFILES
|
||||
+ )
|
||||
+ continue
|
||||
+ values = serialize_vhs_node(n)
|
||||
+ assert values["crf"] == n["widgets_values"]["crf"]
|
||||
+ assert values["frame_rate"] == n["widgets_values"]["frame_rate"]
|
||||
+ seen.append((path, n["id"]))
|
||||
+ profile = next(
|
||||
+ p
|
||||
+ for p, v in VHS_PROFILES.items()
|
||||
+ if v == (source.get("extra", {}).get("frontendVersion") or "1.37.11")
|
||||
+ )
|
||||
+ result = convert_reference(source, profile)
|
||||
+ assert result.prompt is None
|
||||
+ node_issues = [i for i in result.issues if i.get("node_id") == str(n["id"])]
|
||||
+ # The source upstream classes still have no schema in this
|
||||
+ # minimal profile; preserve those edge errors, not a partial prompt.
|
||||
+ assert node_issues
|
||||
+ assert {i["code"] for i in node_issues} <= {
|
||||
+ "invalid_output_slot",
|
||||
+ "missing_required_input",
|
||||
+ }
|
||||
+ assert len(seen) == 5
|
||||
Reference in New Issue
Block a user