1663 lines
64 KiB
Diff
1663 lines
64 KiB
Diff
diff --git a/calliope-backend/scripts/audit_reference_conversion.py b/calliope-backend/scripts/audit_reference_conversion.py
|
|
index b7b5f18..34cb588 100644
|
|
--- a/calliope-backend/scripts/audit_reference_conversion.py
|
|
+++ b/calliope-backend/scripts/audit_reference_conversion.py
|
|
@@ -23,0 +24 @@ from calliope.comfyui.delivery_scope import exclusion_for
|
|
+from calliope.comfyui.h3_core_reference import CORE_PROFILE
|
|
@@ -309,0 +311 @@ REFERENCE_PROFILES = (
|
|
+ CORE_PROFILE,
|
|
@@ -603,0 +606,83 @@ def h3_field_evidence(source, prompt):
|
|
+def core_field_evidence(source):
|
|
+ """Node diagnostics only, including rejected layouts; never a partial prompt."""
|
|
+ from calliope.comfyui.h3_core_reference import LAYOUTS, saved_values, serialize_node
|
|
+
|
|
+ evidence = []
|
|
+ links = {
|
|
+ e[0]: (i, e)
|
|
+ for i, e in enumerate(source.get("links", []))
|
|
+ if isinstance(e, list) and len(e) == 6
|
|
+ }
|
|
+ for i, node in enumerate(source.get("nodes", [])):
|
|
+ ct = node.get("type")
|
|
+ if ct not in LAYOUTS:
|
|
+ continue
|
|
+ fields, reasons = [], []
|
|
+ try:
|
|
+ saved = saved_values(node)
|
|
+ except (ValueError, TypeError, KeyError, AttributeError) as exc:
|
|
+ saved = {}
|
|
+ reasons.append(str(exc))
|
|
+ for name, value in saved.items():
|
|
+ wi = LAYOUTS[ct].index(name)
|
|
+ fields.append(
|
|
+ {
|
|
+ "field": name,
|
|
+ "value": value,
|
|
+ "json_type": type(value).__name__,
|
|
+ "source_value_pointer": f"/nodes/{i}/widgets_values/{wi}",
|
|
+ "named_pointer": f"/nodes/{i}/widgets_values_named/{name}"
|
|
+ if name in (node.get("widgets_values_named") or {})
|
|
+ else None,
|
|
+ }
|
|
+ )
|
|
+ try:
|
|
+ serialize_node(node)
|
|
+ layout_accepted = True
|
|
+ except (ValueError, TypeError, KeyError, AttributeError) as exc:
|
|
+ layout_accepted = False
|
|
+ if str(exc) not in reasons:
|
|
+ reasons.append(str(exc))
|
|
+ physical = []
|
|
+ for si, socket in enumerate(node.get("inputs", [])):
|
|
+ entry = links.get(socket.get("link"))
|
|
+ if entry:
|
|
+ li, edge = entry
|
|
+ physical.append(
|
|
+ {
|
|
+ "input": socket.get("name"),
|
|
+ "socket_pointer": f"/nodes/{i}/inputs/{si}",
|
|
+ "link_pointer": f"/links/{li}",
|
|
+ "endpoint": [str(edge[1]), edge[2]],
|
|
+ "declared_type": edge[5],
|
|
+ "source_endpoint_only": True,
|
|
+ "upstream_type_in_public_profile": any(
|
|
+ n.get("id") == edge[1] and n.get("type") in LAYOUTS
|
|
+ for n in source.get("nodes", [])
|
|
+ ),
|
|
+ }
|
|
+ )
|
|
+ evidence.append(
|
|
+ {
|
|
+ "node_id": str(node.get("id")),
|
|
+ "type": ct,
|
|
+ "pointer": f"/nodes/{i}",
|
|
+ "layout_accepted": layout_accepted,
|
|
+ "saved_fields": fields,
|
|
+ "physical_input_evidence": physical,
|
|
+ "reasons": reasons,
|
|
+ "outputs_pointer": f"/nodes/{i}/outputs",
|
|
+ "outputs": node.get("outputs", []),
|
|
+ "workflow_only_control": {
|
|
+ "pointer": f"/nodes/{i}/widgets_values/1",
|
|
+ "value": "fixed",
|
|
+ }
|
|
+ if ct == "RandomNoise" and saved
|
|
+ else None,
|
|
+ "contract_manifest": "h3-core-reference/sources.json",
|
|
+ "not_a_submittable_node_or_partial_prompt": True,
|
|
+ }
|
|
+ )
|
|
+ return evidence
|
|
+
|
|
+
|
|
@@ -610,0 +696 @@ def profile_attempt(source, profile):
|
|
+ CORE_PROFILE: "1.53.10",
|
|
@@ -790,0 +877,17 @@ def profile_attempt(source, profile):
|
|
+ if profile == CORE_PROFILE:
|
|
+ assumptions.update(
|
|
+ {
|
|
+ "reference_sources": [
|
|
+ "h3-core-reference/sources.json",
|
|
+ "h3-reference/sources.json",
|
|
+ ],
|
|
+ "core_version": "0.33.0",
|
|
+ "core_commit": "2f35f4a08176d993cded35dac3332be4f7287f41",
|
|
+ "source_core_provider_version": "unknown_unless_explicitly_declared",
|
|
+ "reference_provider": "comfy-core",
|
|
+ "restoration_policy": "positional_when_named_absent_else_exact_typed_agreement",
|
|
+ "expressions": "opaque_strings_never_evaluated",
|
|
+ "primitive_float_bound": "conservative_32_64_bit_sys_maxsize_intersection",
|
|
+ "random_seed_bound": "core_uint64_intersect_JS_safe_integer",
|
|
+ }
|
|
+ )
|
|
@@ -823,0 +927,2 @@ def profile_attempt(source, profile):
|
|
+ if profile == CORE_PROFILE:
|
|
+ assumptions["missing_frontend_policy"] = "explicit_1.53.10_reference_assumption"
|
|
@@ -846,0 +952 @@ def profile_attempt(source, profile):
|
|
+ CORE_PROFILE,
|
|
@@ -876,0 +983,5 @@ def profile_attempt(source, profile):
|
|
+ **(
|
|
+ {"supported_node_evidence": core_field_evidence(source)}
|
|
+ if profile == CORE_PROFILE
|
|
+ else {}
|
|
+ ),
|
|
@@ -892,0 +1004,5 @@ def profile_attempt(source, profile):
|
|
+ **(
|
|
+ {"supported_node_evidence": core_field_evidence(source)}
|
|
+ if profile == CORE_PROFILE
|
|
+ else {}
|
|
+ ),
|
|
@@ -1019 +1135,3 @@ def audit_library(repo: Path, profiles=REFERENCE_PROFILES, *, baseline_profiles=
|
|
- (H3_PROFILE,)
|
|
+ (CORE_PROFILE,)
|
|
+ if CORE_PROFILE in profiles
|
|
+ else (H3_PROFILE,)
|
|
diff --git a/calliope-backend/src/calliope/comfyui/h3_core_reference.py b/calliope-backend/src/calliope/comfyui/h3_core_reference.py
|
|
new file mode 100644
|
|
index 0000000..efc8dee
|
|
--- /dev/null
|
|
+++ b/calliope-backend/src/calliope/comfyui/h3_core_reference.py
|
|
@@ -0,0 +1,246 @@
|
|
+"""Six core0.33.0 saved-state contracts, under explicit frontend1.53.10 assumptions.
|
|
+
|
|
+Sources: docs/hel-892/h3-core-reference/sources.json. Never imports upstream,
|
|
+evaluates expressions, computes dimensions or inspects a target installation.
|
|
+"""
|
|
+
|
|
+from __future__ import annotations
|
|
+
|
|
+import math
|
|
+from copy import deepcopy
|
|
+from string import ascii_lowercase
|
|
+
|
|
+CORE_PROFILE = "comfy-frontend-1.53.10-core-0.33.0-h3-first-group-reference"
|
|
+CORE_COMMIT = "2f35f4a08176d993cded35dac3332be4f7287f41"
|
|
+LAYOUTS = {
|
|
+ "PrimitiveStringMultiline": ("value",),
|
|
+ "ResolutionSelector": ("aspect_ratio", "megapixels", "multiple"),
|
|
+ "ComfyMathExpression": ("expression",),
|
|
+ "PrimitiveFloat": ("value",),
|
|
+ "RandomNoise": ("noise_seed", "control_after_generate"),
|
|
+ "BasicScheduler": ("scheduler", "steps", "denoise"),
|
|
+}
|
|
+RATIOS = (
|
|
+ "1:1 (Square)",
|
|
+ "2:3 (Portrait Photo)",
|
|
+ "3:2 (Photo)",
|
|
+ "3:4 (Portrait Standard)",
|
|
+ "4:3 (Standard)",
|
|
+ "9:16 (Portrait Widescreen)",
|
|
+ "16:9 (Widescreen)",
|
|
+ "21:9 (Ultrawide)",
|
|
+)
|
|
+SCHEDULERS = (
|
|
+ "simple",
|
|
+ "sgm_uniform",
|
|
+ "karras",
|
|
+ "exponential",
|
|
+ "ddim_uniform",
|
|
+ "beta",
|
|
+ "normal",
|
|
+ "linear_quadratic",
|
|
+ "kl_optimal",
|
|
+)
|
|
+NUMERIC_UNION = "FLOAT,INT,BOOLEAN"
|
|
+OVERRIDES = (
|
|
+ "ue_properties",
|
|
+ "widget_ue_connectable",
|
|
+ "input_ue_unconnectable",
|
|
+ "ue_links",
|
|
+ "links_added_by_ue",
|
|
+ "widgets",
|
|
+ "serializeValue",
|
|
+ "comfyDynamic",
|
|
+ "serialize_widgets",
|
|
+ "fallbackWidgetsValuesNames",
|
|
+ "comfyClass",
|
|
+ "onNodeCreated",
|
|
+ "onConnectInput",
|
|
+ "onConnectionsChange",
|
|
+ "onInputAdded",
|
|
+ "onConfigure",
|
|
+ "onSerialize",
|
|
+ "getInputLink",
|
|
+ "resolveInput",
|
|
+ "resolveOutput",
|
|
+ "onExecute",
|
|
+ "isVirtualNode",
|
|
+ "applyToGraph",
|
|
+ "beforeQueued",
|
|
+ "afterQueued",
|
|
+)
|
|
+
|
|
+
|
|
+def definitions():
|
|
+ """Public schemas only; no injected test helpers in this class set."""
|
|
+
|
|
+ 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,
|
|
+ }
|
|
+
|
|
+ return {
|
|
+ "PrimitiveStringMultiline": spec({"value": "STRING"}, ["STRING"]),
|
|
+ "ResolutionSelector": spec(
|
|
+ {"aspect_ratio": "COMBO", "megapixels": "FLOAT", "multiple": "INT"},
|
|
+ ["INT", "INT"],
|
|
+ ),
|
|
+ "ComfyMathExpression": spec(
|
|
+ {"expression": "STRING", "values.a": NUMERIC_UNION},
|
|
+ ["FLOAT", "INT", "BOOLEAN"],
|
|
+ {f"values.{c}": NUMERIC_UNION for c in ascii_lowercase[1:]},
|
|
+ ),
|
|
+ "PrimitiveFloat": spec({"value": "FLOAT"}, ["FLOAT"]),
|
|
+ "RandomNoise": spec({"noise_seed": "INT"}, ["NOISE"]),
|
|
+ "BasicScheduler": spec(
|
|
+ {"model": "MODEL", "scheduler": "COMBO", "steps": "INT", "denoise": "FLOAT"},
|
|
+ ["SIGMAS"],
|
|
+ ),
|
|
+ }
|
|
+
|
|
+
|
|
+def check_overrides(container):
|
|
+ if any(k in container for k in OVERRIDES):
|
|
+ raise ValueError("第一组不解释UE或未知控件/恢复/执行覆盖")
|
|
+
|
|
+
|
|
+def saved_values(node):
|
|
+ """Decode only proved widget order; no graph/slot validity claim here."""
|
|
+ ct, props = node.get("type"), node.get("properties") or {}
|
|
+ if ct not in LAYOUTS:
|
|
+ raise ValueError("第一组只覆盖六类core节点")
|
|
+ for k, expected in (("cnr_id", "comfy-core"), ("ver", "0.33.0")):
|
|
+ if k in props and props[k] != expected:
|
|
+ raise ValueError("第一组提供方/core版本声明冲突;缺失仅为显式参考假设")
|
|
+ if "aux_id" in props:
|
|
+ raise ValueError("第一组不解释其它来源身份")
|
|
+ if type(node.get("mode", 0)) is not int or node.get("mode", 0) != 0:
|
|
+ raise ValueError("第一组仅正常mode=0")
|
|
+ check_overrides(node)
|
|
+ check_overrides(props)
|
|
+ layout, values = LAYOUTS[ct], node.get("widgets_values")
|
|
+ if not isinstance(values, list) or len(values) != len(layout):
|
|
+ raise ValueError("第一组控件保存数组缺项/多项")
|
|
+ if "widgets_values_named" in node:
|
|
+ named = node["widgets_values_named"]
|
|
+ if not isinstance(named, dict) or set(named) != set(layout):
|
|
+ raise ValueError("第一组具名保存缺项/多项")
|
|
+ if any(type(named[k]) is not type(v) or named[k] != v for k, v in zip(layout, values)):
|
|
+ raise ValueError("第一组具名/位置恢复冲突")
|
|
+ result = dict(zip(layout, values))
|
|
+
|
|
+ def number(name, kind, lo, hi):
|
|
+ value = result[name]
|
|
+ # Conservative typed intersection: never coerce bool, text or FLOAT into INT.
|
|
+ valid_type = type(value) is int if kind == "INT" else type(value) in (int, float)
|
|
+ if not valid_type or not lo <= value <= hi or not math.isfinite(value):
|
|
+ raise ValueError(f"第一组{name}数值类型/范围不符")
|
|
+
|
|
+ if ct in ("PrimitiveStringMultiline", "ComfyMathExpression"):
|
|
+ if type(values[0]) is not str:
|
|
+ raise ValueError("第一组文本必须是原样字符串")
|
|
+ elif ct == "ResolutionSelector":
|
|
+ if result["aspect_ratio"] not in RATIOS:
|
|
+ raise ValueError("第一组aspect_ratio枚举不符")
|
|
+ number("megapixels", "FLOAT", 0.1, 16.0)
|
|
+ number("multiple", "INT", 8, 128)
|
|
+ elif ct == "PrimitiveFloat":
|
|
+ # Core uses platform-dependent sys.maxsize. Accept only the conservative
|
|
+ # 32/64-bit intersection; do not claim the target platform was observed.
|
|
+ number("value", "FLOAT", -(2**31 - 1), 2**31 - 1)
|
|
+ elif ct == "RandomNoise":
|
|
+ # JS Number cannot safely retain arbitrary 64-bit integers. Intersect
|
|
+ # core's uint64 bound with exact saved/restored numeric representation.
|
|
+ number("noise_seed", "INT", 0, 2**53 - 1)
|
|
+ if result.pop("control_after_generate") != "fixed":
|
|
+ raise ValueError("第一组seed只接受fixed;排队变值控制未证明")
|
|
+ elif ct == "BasicScheduler":
|
|
+ if result["scheduler"] not in SCHEDULERS:
|
|
+ raise ValueError("第一组scheduler枚举不符")
|
|
+ number("steps", "INT", 1, 10000)
|
|
+ number("denoise", "FLOAT", 0.0, 1.0)
|
|
+ return result
|
|
+
|
|
+
|
|
+def serialize_node(node):
|
|
+ result = saved_values(node)
|
|
+ ct, spec = node["type"], definitions()[node["type"]]
|
|
+ outputs = node.get("outputs", [])
|
|
+ if [s.get("type") for s in outputs] != spec["output"]:
|
|
+ raise ValueError("第一组输出槽数量/类型不符")
|
|
+ expected_names = {
|
|
+ "PrimitiveStringMultiline": ["STRING"],
|
|
+ "ResolutionSelector": ["width", "height"],
|
|
+ "ComfyMathExpression": ["FLOAT", "INT", "BOOL"],
|
|
+ "PrimitiveFloat": ["FLOAT"],
|
|
+ "RandomNoise": ["NOISE"],
|
|
+ "BasicScheduler": ["SIGMAS"],
|
|
+ }[ct]
|
|
+ if [s.get("name") for s in outputs] != expected_names or any(
|
|
+ "slot_index" in s and (type(s["slot_index"]) is not int or s["slot_index"] != i)
|
|
+ for i, s in enumerate(outputs)
|
|
+ ):
|
|
+ raise ValueError("第一组输出槽名字/slot_index不符")
|
|
+ sockets = node.get("inputs", [])
|
|
+ names = [s.get("name") for s in sockets]
|
|
+ if len(names) != len(set(names)):
|
|
+ raise ValueError("第一组重复输入槽")
|
|
+ declared = {**spec["input"]["required"], **spec["input"]["optional"]}
|
|
+ for s in sockets:
|
|
+ name = s.get("name")
|
|
+ if name not in declared or s.get("type") != declared[name][0]:
|
|
+ raise ValueError("第一组输入槽/类型或动态布局未证明")
|
|
+ if "widget" in s and s["widget"] != {"name": name}:
|
|
+ raise ValueError("第一组控件输入绑定不符")
|
|
+ if "slot_index" in s:
|
|
+ raise ValueError("第一组输入槽额外slot_index未证明")
|
|
+ if ct == "ComfyMathExpression":
|
|
+ dynamic = [n for n in names if n != "expression"]
|
|
+ if not 2 <= len(dynamic) <= 26 or dynamic != [
|
|
+ f"values.{c}" for c in ascii_lowercase[: len(dynamic)]
|
|
+ ]:
|
|
+ raise ValueError("第一组算式需已构造values.a/b连续动态槽;不恢复旧values占位")
|
|
+ return result
|
|
+
|
|
+
|
|
+def validate_structure(source):
|
|
+ """Reuse direct root invariants without mutating absent source identity.
|
|
+
|
|
+ Only the proved numeric MultiType autogrow slots may specialize a link type.
|
|
+ No unknown node obtains a schema through this validation.
|
|
+ """
|
|
+ from .structure_reference import validate_grid_structure
|
|
+
|
|
+ declared = (source.get("extra") or {}).get("frontendVersion")
|
|
+ if declared is not None and declared != "1.53.10":
|
|
+ raise ValueError("第一组前端声明冲突;缺失仅显式采用1.53.10参考")
|
|
+ for container in (source, source.get("extra") or {}):
|
|
+ check_overrides(container)
|
|
+ for node in source["nodes"]:
|
|
+ check_overrides(node)
|
|
+ check_overrides(node.get("properties") or {})
|
|
+ if node.get("type") == "Reroute":
|
|
+ raise ValueError("第一组不扩展虚拟节点")
|
|
+ graph = deepcopy(source)
|
|
+ graph.setdefault("extra", {})["frontendVersion"] = "1.53.10"
|
|
+ nodes = {n["id"]: n for n in graph["nodes"]}
|
|
+ for edge in graph.get("links", []):
|
|
+ if not isinstance(edge, list) or len(edge) != 6:
|
|
+ continue # Shared validator gives the precise structural rejection.
|
|
+ target = nodes.get(edge[3], {})
|
|
+ slot = edge[4]
|
|
+ if type(slot) is not int or not 0 <= slot < len(target.get("inputs", [])):
|
|
+ continue
|
|
+ socket = target["inputs"][slot]
|
|
+ if (
|
|
+ target.get("type") == "ComfyMathExpression"
|
|
+ and socket.get("name") in {f"values.{c}" for c in ascii_lowercase}
|
|
+ and socket.get("type") == NUMERIC_UNION
|
|
+ and edge[5] in NUMERIC_UNION.split(",")
|
|
+ ):
|
|
+ socket["type"] = edge[5]
|
|
+ validate_grid_structure(graph, frontend="1.53.10")
|
|
diff --git a/calliope-backend/src/calliope/comfyui/serialization_reference.py b/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
|
index 862eab5..e0e9d37 100644
|
|
--- a/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
|
+++ b/calliope-backend/src/calliope/comfyui/serialization_reference.py
|
|
@@ -16,0 +17 @@ from typing import Any
|
|
+from .h3_core_reference import CORE_PROFILE
|
|
@@ -490,0 +492,4 @@ def reference_definitions(profile: str = PROFILE) -> dict[str, Any]:
|
|
+ if profile == CORE_PROFILE:
|
|
+ from .h3_core_reference import definitions
|
|
+
|
|
+ return definitions()
|
|
@@ -576,0 +582,4 @@ def serialize_reference_widgets(node: dict[str, Any], profile: str = PROFILE) ->
|
|
+ if profile == CORE_PROFILE:
|
|
+ from .h3_core_reference import serialize_node
|
|
+
|
|
+ return serialize_node(node)
|
|
diff --git a/calliope-backend/src/calliope/comfyui/ui2api.py b/calliope-backend/src/calliope/comfyui/ui2api.py
|
|
index 4993c95..c16c208 100644
|
|
--- a/calliope-backend/src/calliope/comfyui/ui2api.py
|
|
+++ b/calliope-backend/src/calliope/comfyui/ui2api.py
|
|
@@ -15,0 +16 @@ from typing import Any
|
|
+from .h3_core_reference import CORE_PROFILE
|
|
@@ -79,0 +81 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
|
+ CORE_PROFILE,
|
|
@@ -103,0 +106,4 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
|
+ if profile == CORE_PROFILE:
|
|
+ from .h3_core_reference import validate_structure
|
|
+
|
|
+ validate_structure(source)
|
|
@@ -236 +242 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
|
- if profile in (GRID_PROFILE, H3_PROFILE):
|
|
+ if profile in (GRID_PROFILE, H3_PROFILE, CORE_PROFILE):
|
|
@@ -241,0 +248 @@ def convert_reference(source: Any, profile: str = PROFILE) -> Conversion:
|
|
+ CORE_PROFILE,
|
|
@@ -260 +267 @@ def _convert(
|
|
- if reference and reference_profile in (GRID_PROFILE, H3_PROFILE):
|
|
+ if reference and reference_profile in (GRID_PROFILE, H3_PROFILE, CORE_PROFILE):
|
|
@@ -320,0 +328 @@ def _convert(
|
|
+ CORE_PROFILE: "1.53.10",
|
|
@@ -467,6 +475,18 @@ def _convert(
|
|
- if expected != actual and not (
|
|
- reference
|
|
- and reference_profile in (PREVIEW_PROFILE, CASE04_PROFILE, ASR_PROFILE, H3_PROFILE)
|
|
- and ct == "PreviewAny"
|
|
- and name == "source"
|
|
- and expected == "*"
|
|
+ if (
|
|
+ expected != actual
|
|
+ and not (
|
|
+ reference
|
|
+ and reference_profile == CORE_PROFILE
|
|
+ and ct == "ComfyMathExpression"
|
|
+ and name.startswith("values.")
|
|
+ and actual in ("FLOAT", "INT", "BOOLEAN")
|
|
+ and expected == "FLOAT,INT,BOOLEAN"
|
|
+ )
|
|
+ and not (
|
|
+ reference
|
|
+ and reference_profile
|
|
+ in (PREVIEW_PROFILE, CASE04_PROFILE, ASR_PROFILE, H3_PROFILE)
|
|
+ and ct == "PreviewAny"
|
|
+ and name == "source"
|
|
+ and expected == "*"
|
|
+ )
|
|
diff --git a/calliope-backend/tests/test_audio_separation_reference.py b/calliope-backend/tests/test_audio_separation_reference.py
|
|
index ee8b49c..97fdc3d 100644
|
|
--- a/calliope-backend/tests/test_audio_separation_reference.py
|
|
+++ b/calliope-backend/tests/test_audio_separation_reference.py
|
|
@@ -364 +364 @@ def test_library_actual_delta_keeps_every_old_attempt_and_all_six_golden_compari
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
diff --git a/calliope-backend/tests/test_crop_split_reference.py b/calliope-backend/tests/test_crop_split_reference.py
|
|
index e2a9715..90716e4 100644
|
|
--- a/calliope-backend/tests/test_crop_split_reference.py
|
|
+++ b/calliope-backend/tests/test_crop_split_reference.py
|
|
@@ -356 +356 @@ def test_all_old_fourteen_profiles_attempts_gaps_and_six_differences_unchanged()
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
diff --git a/calliope-backend/tests/test_grid_reference.py b/calliope-backend/tests/test_grid_reference.py
|
|
index 319af04..36b549e 100644
|
|
--- a/calliope-backend/tests/test_grid_reference.py
|
|
+++ b/calliope-backend/tests/test_grid_reference.py
|
|
@@ -342 +342,3 @@ def test_fixed_sources_and_original_profile_cohorts_remain_identical():
|
|
- and tuple(p for p in audit.REFERENCE_PROFILES if p not in (GRID_PROFILE, audit.H3_PROFILE))
|
|
+ and tuple(
|
|
+ p for p in audit.REFERENCE_PROFILES[:26] if p not in (GRID_PROFILE, audit.H3_PROFILE)
|
|
+ )
|
|
diff --git a/calliope-backend/tests/test_h3_core_reference.py b/calliope-backend/tests/test_h3_core_reference.py
|
|
new file mode 100644
|
|
index 0000000..a44414d
|
|
--- /dev/null
|
|
+++ b/calliope-backend/tests/test_h3_core_reference.py
|
|
@@ -0,0 +1,449 @@
|
|
+"""Synthetic contract tests are distinct from the three unchanged real closed graphs."""
|
|
+
|
|
+import copy
|
|
+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.h3_core_reference import (
|
|
+ CORE_PROFILE,
|
|
+ LAYOUTS,
|
|
+ NUMERIC_UNION,
|
|
+ definitions,
|
|
+ saved_values,
|
|
+ serialize_node,
|
|
+)
|
|
+from calliope.comfyui.ui2api import convert, convert_reference
|
|
+
|
|
+REPO = Path(__file__).resolve().parents[2]
|
|
+PATH = next((REPO / "example_ComfyUI_workflows").rglob("minimax-h3文生视频无审核版.json"))
|
|
+
|
|
+
|
|
+def real():
|
|
+ return json.loads(PATH.read_bytes())
|
|
+
|
|
+
|
|
+def node(nid):
|
|
+ return copy.deepcopy(next(n for n in real()["nodes"] if n["id"] == nid))
|
|
+
|
|
+
|
|
+def single(nid):
|
|
+ n = node(nid)
|
|
+ for s in n["outputs"]:
|
|
+ s["links"] = None
|
|
+ for s in n["inputs"]:
|
|
+ s["link"] = None
|
|
+ return {"nodes": [n], "links": [], "extra": {}}
|
|
+
|
|
+
|
|
+def closed(g):
|
|
+ old = copy.deepcopy(g)
|
|
+ r = convert_reference(g, CORE_PROFILE)
|
|
+ assert r.prompt is None and r.issues and r.reference_only and g == old
|
|
+ assert all(i.get("pointer") is not None for i in r.issues)
|
|
+ a = audit.profile_attempt(g, CORE_PROFILE)
|
|
+ assert a["status"] in ("rejected", "not_applicable") and "candidate_prompt" not in a
|
|
+
|
|
+
|
|
+def synthetic_math():
|
|
+ g = single(133)
|
|
+ n = node(132)
|
|
+ # Construct the fixed frontend shape as a TEST fixture, never alter source bytes.
|
|
+ n["inputs"] = [
|
|
+ {"name": "values.a", "type": NUMERIC_UNION, "link": 1},
|
|
+ {"name": "values.b", "type": NUMERIC_UNION, "link": None},
|
|
+ ]
|
|
+ for s in n["outputs"]:
|
|
+ s["links"] = None
|
|
+ g["nodes"][0]["outputs"][0]["links"] = [1]
|
|
+ g["nodes"].append(n)
|
|
+ g["links"] = [[1, 133, 0, 132, 0, "FLOAT"]]
|
|
+ return g
|
|
+
|
|
+
|
|
+def test_real_main_seven_instances_five_layouts_and_two_explicit_dynamic_rejections():
|
|
+ g = real()
|
|
+ assert len(g["nodes"]) == 21 and len(g["links"]) == 24
|
|
+ selected = [n for n in g["nodes"] if n["type"] in LAYOUTS]
|
|
+ assert len(selected) == 7 and len(definitions()) == 6
|
|
+ assert sum(len(saved_values(n)) for n in selected) == 11
|
|
+ for n in selected:
|
|
+ if n["type"] == "ComfyMathExpression":
|
|
+ with pytest.raises(ValueError, match="动态布局"):
|
|
+ serialize_node(n)
|
|
+ else:
|
|
+ assert serialize_node(n) == saved_values(n)
|
|
+ closed(g)
|
|
+ a = audit.profile_attempt(g, CORE_PROFILE)
|
|
+ assert a["status"] == "rejected"
|
|
+ evidence = a["supported_node_evidence"]
|
|
+ assert len(evidence) == 7 and sum(e["layout_accepted"] for e in evidence) == 5
|
|
+ assert sum(len(e["saved_fields"]) for e in evidence) == 11
|
|
+ assert all(e["not_a_submittable_node_or_partial_prompt"] for e in evidence)
|
|
+ assert all(e["reasons"] for e in evidence if not e["layout_accepted"])
|
|
+ assert a["assumptions"]["source_frontend_declaration"] is None
|
|
+ assert a["assumptions"]["source_core_provider_version"].startswith("unknown")
|
|
+ assert a["assumptions"]["core_version"] == "0.33.0"
|
|
+ assert convert(g).prompt is None
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize("nid", [1, 115, 133, 129])
|
|
+def test_supported_saved_state_instances_under_explicit_missing_identity_assumption(nid):
|
|
+ g = single(nid)
|
|
+ before = copy.deepcopy(g)
|
|
+ r = convert_reference(g, CORE_PROFILE)
|
|
+ assert r.prompt is not None and r.reference_only and g == before
|
|
+ assert r.prompt[str(nid)]["inputs"] == serialize_node(g["nodes"][0])
|
|
+ assert r.serialization_stage == "restored_saved_state_before_queue_hooks"
|
|
+ for n in g["nodes"]:
|
|
+ n["properties"].update(cnr_id="comfy-core", ver="0.33.0")
|
|
+ g["extra"]["frontendVersion"] = "1.53.10"
|
|
+ assert convert_reference(g, CORE_PROFILE).prompt == r.prompt
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize("nid", [1, 115, 133, 129, 124, 132])
|
|
+@pytest.mark.parametrize(
|
|
+ "mutation", ["provider", "version", "aux", "mode", "ue", "hook", "short", "long"]
|
|
+)
|
|
+def test_identity_mode_layout_unknown_coverage_never_yields_partial_prompt(nid, mutation):
|
|
+ g = single(nid)
|
|
+ n = g["nodes"][0]
|
|
+ if mutation == "provider":
|
|
+ n["properties"]["cnr_id"] = "other"
|
|
+ elif mutation == "version":
|
|
+ n["properties"]["ver"] = "0.30.0"
|
|
+ elif mutation == "aux":
|
|
+ n["properties"]["aux_id"] = "comfy-core"
|
|
+ elif mutation == "mode":
|
|
+ n["mode"] = True
|
|
+ elif mutation == "ue":
|
|
+ n["properties"]["ue_properties"] = {}
|
|
+ elif mutation == "hook":
|
|
+ n["onConfigure"] = "unknown"
|
|
+ elif mutation == "short":
|
|
+ n["widgets_values"].pop()
|
|
+ else:
|
|
+ n["widgets_values"].append("extra")
|
|
+ with pytest.raises(ValueError):
|
|
+ serialize_node(n)
|
|
+ closed(g)
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize(
|
|
+ "nid,index,value",
|
|
+ [
|
|
+ (1, 0, None),
|
|
+ (1, 0, []),
|
|
+ (115, 0, "16:9"),
|
|
+ (115, 1, True),
|
|
+ (115, 1, 0.09),
|
|
+ (115, 1, 16.1),
|
|
+ (115, 1, "0.7"),
|
|
+ (115, 2, 32.0),
|
|
+ (115, 2, 7),
|
|
+ (115, 2, 129),
|
|
+ (133, 0, True),
|
|
+ (133, 0, "10"),
|
|
+ (133, 0, float("inf")),
|
|
+ (133, 0, float("nan")),
|
|
+ (133, 0, 10**500),
|
|
+ (129, 0, True),
|
|
+ (129, 0, 42.0),
|
|
+ (129, 0, -1),
|
|
+ (129, 0, 2**53),
|
|
+ (129, 0, 2**64),
|
|
+ (129, 1, "randomize"),
|
|
+ (129, 1, "increment"),
|
|
+ (129, 1, "decrement"),
|
|
+ (129, 1, None),
|
|
+ (124, 0, "unknown"),
|
|
+ (124, 1, 4.0),
|
|
+ (124, 1, True),
|
|
+ (124, 1, 0),
|
|
+ (124, 1, 10001),
|
|
+ (124, 2, -0.01),
|
|
+ (124, 2, 1.01),
|
|
+ (124, 2, True),
|
|
+ (124, 2, "1.0"),
|
|
+ ],
|
|
+)
|
|
+def test_types_enums_boundaries_seed_and_nonfixed_controls(nid, index, value):
|
|
+ n = node(nid)
|
|
+ n["widgets_values"][index] = value
|
|
+ with pytest.raises(ValueError):
|
|
+ saved_values(n)
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize(
|
|
+ "nid,index,value",
|
|
+ [
|
|
+ (1, 0, "opaque\ntext\u0000原样"),
|
|
+ (115, 1, 0.1),
|
|
+ (115, 1, 16.0),
|
|
+ (115, 2, 8),
|
|
+ (115, 2, 128),
|
|
+ (129, 0, 0),
|
|
+ (129, 0, 2**53 - 1),
|
|
+ (133, 0, -100.5),
|
|
+ (124, 0, "kl_optimal"),
|
|
+ (124, 1, 1),
|
|
+ (124, 1, 10000),
|
|
+ (124, 2, 0.0),
|
|
+ (124, 2, 1.0),
|
|
+ ],
|
|
+)
|
|
+def test_proved_values_propagate_without_coercion_or_calculation(nid, index, value):
|
|
+ n = node(nid)
|
|
+ n["widgets_values"][index] = value
|
|
+ field = LAYOUTS[n["type"]][index]
|
|
+ v = saved_values(n)[field]
|
|
+ assert v == value and type(v) is type(value)
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize("nid", [1, 115, 133, 129, 124, 132])
|
|
+@pytest.mark.parametrize("mutation", ["missing", "extra", "conflict", "typed-conflict"])
|
|
+def test_optional_named_save_must_be_complete_and_agree(nid, mutation):
|
|
+ n = node(nid)
|
|
+ layout = LAYOUTS[n["type"]]
|
|
+ n["widgets_values_named"] = dict(zip(layout, n["widgets_values"]))
|
|
+ if mutation == "missing":
|
|
+ n["widgets_values_named"].pop(layout[0])
|
|
+ elif mutation == "extra":
|
|
+ n["widgets_values_named"]["extra"] = 0
|
|
+ elif mutation == "typed-conflict":
|
|
+ n["widgets_values_named"][layout[0]] = True
|
|
+ else:
|
|
+ n["widgets_values_named"][layout[0]] = "conflict"
|
|
+ with pytest.raises(ValueError):
|
|
+ saved_values(n)
|
|
+
|
|
+
|
|
+def test_synthetic_math_expression_is_opaque_physical_union_edge_and_instance_switch():
|
|
+ g = synthetic_math()
|
|
+ original_expression = g["nodes"][1]["widgets_values"][0]
|
|
+ r = convert_reference(g, CORE_PROFILE)
|
|
+ assert r.prompt is not None, r.issues
|
|
+ assert r.prompt["132"]["inputs"] == {
|
|
+ "expression": original_expression,
|
|
+ "values.a": ["133", 0],
|
|
+ }
|
|
+ g["nodes"][1]["widgets_values"][0] = "__import__('never_called') / 0 + unknown"
|
|
+ g["nodes"][0]["id"] = 990
|
|
+ g["links"][0][1] = 990
|
|
+ r = convert_reference(g, CORE_PROFILE)
|
|
+ assert r.prompt is not None, r.issues
|
|
+ assert r.prompt["132"]["inputs"]["values.a"] == ["990", 0]
|
|
+ assert r.prompt["132"]["inputs"]["expression"] == g["nodes"][1]["widgets_values"][0]
|
|
+
|
|
+
|
|
+def test_synthetic_physical_widget_input_overrides_saved_value():
|
|
+ g = single(133)
|
|
+ n = copy.deepcopy(g["nodes"][0])
|
|
+ n["id"] = 991
|
|
+ n["inputs"] = [{"name": "value", "type": "FLOAT", "link": 1, "widget": {"name": "value"}}]
|
|
+ n["widgets_values"] = [99.0]
|
|
+ g["nodes"][0]["outputs"][0]["links"] = [1]
|
|
+ g["nodes"].append(n)
|
|
+ g["links"] = [[1, 133, 0, 991, 0, "FLOAT"]]
|
|
+ r = convert_reference(g, CORE_PROFILE)
|
|
+ assert r.prompt is not None, r.issues
|
|
+ assert r.prompt["991"]["inputs"]["value"] == ["133", 0]
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize(
|
|
+ "mutation",
|
|
+ [
|
|
+ "frontend",
|
|
+ "ue",
|
|
+ "renderer",
|
|
+ "subgraph",
|
|
+ "missing-end",
|
|
+ "wrong-slot",
|
|
+ "wrong-type",
|
|
+ "duplicate-link",
|
|
+ "reverse-input",
|
|
+ "reverse-output",
|
|
+ "duplicate-input",
|
|
+ "cycle",
|
|
+ "wrong-output-name",
|
|
+ "wrong-slot-index",
|
|
+ "unknown-class",
|
|
+ "math-placeholder",
|
|
+ ],
|
|
+)
|
|
+def test_synthetic_graph_structure_is_strict(mutation):
|
|
+ g = synthetic_math()
|
|
+ a, b = g["nodes"]
|
|
+ if mutation == "frontend":
|
|
+ g["extra"]["frontendVersion"] = "1.53.6"
|
|
+ elif mutation == "ue":
|
|
+ g["extra"]["ue_properties"] = {}
|
|
+ elif mutation == "renderer":
|
|
+ g["extra"]["workflowRendererVersion"] = "Vue"
|
|
+ elif mutation == "subgraph":
|
|
+ g["definitions"] = {"subgraphs": [{"id": "unknown"}]}
|
|
+ elif mutation == "missing-end":
|
|
+ g["links"][0][1] = 999
|
|
+ elif mutation == "wrong-slot":
|
|
+ g["links"][0][2] = 1
|
|
+ elif mutation == "wrong-type":
|
|
+ g["links"][0][5] = "INT"
|
|
+ elif mutation == "duplicate-link":
|
|
+ g["links"].append(g["links"][0])
|
|
+ elif mutation == "reverse-input":
|
|
+ b["inputs"][0]["link"] = 9
|
|
+ elif mutation == "reverse-output":
|
|
+ a["outputs"][0]["links"] = []
|
|
+ elif mutation == "duplicate-input":
|
|
+ b["inputs"].append(copy.deepcopy(b["inputs"][0]))
|
|
+ elif mutation == "cycle":
|
|
+ a["inputs"] = [{"name": "value", "type": "FLOAT", "link": 2}]
|
|
+ b["outputs"][0]["links"] = [2]
|
|
+ g["links"].append([2, 132, 0, 133, 0, "FLOAT"])
|
|
+ elif mutation == "wrong-output-name":
|
|
+ b["outputs"][1]["name"] = "FLOAT"
|
|
+ elif mutation == "wrong-slot-index":
|
|
+ b["outputs"][0]["slot_index"] = True
|
|
+ elif mutation == "unknown-class":
|
|
+ a["type"] = "TestOnlyHelperNotRegistered"
|
|
+ else:
|
|
+ b["inputs"].append({"name": "values", "type": "COMFY_AUTOGROW_V3", "link": None})
|
|
+ closed(g)
|
|
+
|
|
+
|
|
+def test_three_unchanged_uncensored_graphs_remain_closed():
|
|
+ paths = sorted(PATH.parent.glob("*.json"))
|
|
+ assert len(paths) == 3
|
|
+ for path in paths:
|
|
+ g = json.loads(path.read_bytes())
|
|
+ closed(g)
|
|
+ a = audit.profile_attempt(g, CORE_PROFILE)
|
|
+ assert a["status"] == "rejected"
|
|
+
|
|
+
|
|
+def test_pinned_sources_without_importing_upstream():
|
|
+ r = verify(REPO / "docs/hel-892/h3-core-reference")
|
|
+ assert not r["upstream_code_executed"] and len(r["sources_verified"]) >= 9
|
|
+
|
|
+
|
|
+def test_all_old_26_profiles_attempts_gaps_hashes_and_six_companions_frozen():
|
|
+ old = json.loads((REPO / "docs/hel-892/h3-evidence/library.json").read_bytes())
|
|
+ profiles = tuple(old["profiles"])
|
|
+ assert len(profiles) == 26 and profiles == audit.REFERENCE_PROFILES[:26]
|
|
+ before = audit.audit_library(REPO, profiles)
|
|
+ now = audit.audit_library(REPO, baseline_profiles=profiles)
|
|
+ assert old["gap_groups"] == before["gap_groups"]
|
|
+ for a, b, c in zip(old["cases"], before["cases"], now["cases"]):
|
|
+ assert a["attempts"] == b["attempts"] == c["attempts"][:26]
|
|
+ assert a["candidate_hashes"] == c["candidate_hashes"]
|
|
+ assert a.get("comparisons") == b.get("comparisons") == c.get("comparisons")
|
|
+ assert now["coverage_delta"]["new_complete_paths"] == []
|
|
+ assert len(now["coverage_delta"]["current_complete_paths"]) == 9
|
|
+ assert sum(r["status"] == "blocked" for r in now["cases"]) == 136
|
|
+ six = audit.audit(REPO, "case04-batch-reference")
|
|
+ assert six == json.loads(
|
|
+ (REPO / "docs/hel-892/media-evidence/protected-six-cases.json").read_bytes()
|
|
+ )
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize(
|
|
+ "key",
|
|
+ [
|
|
+ "serialize_widgets",
|
|
+ "fallbackWidgetsValuesNames",
|
|
+ "comfyClass",
|
|
+ "onNodeCreated",
|
|
+ "onConnectInput",
|
|
+ "onConnectionsChange",
|
|
+ "onInputAdded",
|
|
+ ],
|
|
+)
|
|
+def test_unknown_frontend_construction_overrides_are_not_ignored(key):
|
|
+ g = single(133)
|
|
+ g["nodes"][0][key] = False
|
|
+ closed(g)
|
|
+
|
|
+
|
|
+def test_float_platform_limit_is_symbolic_and_only_conservative_intersection_accepted():
|
|
+ n = node(133)
|
|
+ for value in (-(2**31 - 1), 2**31 - 1):
|
|
+ n["widgets_values"] = [value]
|
|
+ assert saved_values(n)["value"] == value
|
|
+ for value in (-(2**31), 2**31):
|
|
+ n["widgets_values"] = [value]
|
|
+ with pytest.raises(ValueError):
|
|
+ saved_values(n)
|
|
+
|
|
+
|
|
+def test_official_schema_ids_registration_enums_and_widget_order_by_static_ast_only():
|
|
+ import ast
|
|
+
|
|
+ from calliope.comfyui.h3_core_reference import RATIOS, SCHEDULERS
|
|
+
|
|
+ root = REPO / "docs/hel-892/h3-core-reference"
|
|
+ expected = {
|
|
+ "nodes_primitive.py": {
|
|
+ "StringMultiline": ("PrimitiveStringMultiline", ["value"]),
|
|
+ "Float": ("PrimitiveFloat", ["value"]),
|
|
+ },
|
|
+ "nodes_resolution.py": {
|
|
+ "ResolutionSelector": (
|
|
+ "ResolutionSelector",
|
|
+ ["aspect_ratio", "megapixels", "multiple"],
|
|
+ ),
|
|
+ },
|
|
+ "nodes_math.py": {
|
|
+ "MathExpressionNode": ("ComfyMathExpression", ["expression", "values"]),
|
|
+ },
|
|
+ "nodes_custom_sampler.py": {
|
|
+ "RandomNoise": ("RandomNoise", ["noise_seed"]),
|
|
+ "BasicScheduler": ("BasicScheduler", ["model", "scheduler", "steps", "denoise"]),
|
|
+ },
|
|
+ }
|
|
+ for filename, classes in expected.items():
|
|
+ tree = ast.parse((root / ("core__comfy_extras__" + filename)).read_text())
|
|
+ registered = {
|
|
+ n.id
|
|
+ for fn in ast.walk(tree)
|
|
+ if isinstance(fn, ast.AsyncFunctionDef) and fn.name == "get_node_list"
|
|
+ for ret in fn.body
|
|
+ if isinstance(ret, ast.Return) and isinstance(ret.value, ast.List)
|
|
+ for n in ret.value.elts
|
|
+ if isinstance(n, ast.Name)
|
|
+ }
|
|
+ for name, (node_id, fields) in classes.items():
|
|
+ assert name in registered
|
|
+ cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == name)
|
|
+ fn = next(
|
|
+ n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == "define_schema"
|
|
+ )
|
|
+ schema = next(
|
|
+ c
|
|
+ for c in ast.walk(fn)
|
|
+ if isinstance(c, ast.Call)
|
|
+ and isinstance(c.func, ast.Attribute)
|
|
+ and c.func.attr == "Schema"
|
|
+ )
|
|
+ kw = {k.arg: k.value for k in schema.keywords}
|
|
+ assert ast.literal_eval(kw["node_id"]) == node_id
|
|
+ actual = []
|
|
+ for c in kw["inputs"].elts:
|
|
+ ident = c.args[0] if c.args else next(k.value for k in c.keywords if k.arg == "id")
|
|
+ actual.append(ast.literal_eval(ident))
|
|
+ assert actual == fields
|
|
+ tree = ast.parse((root / "core__comfy_extras__nodes_resolution.py").read_text())
|
|
+ ratios = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == "AspectRatio")
|
|
+ assert (
|
|
+ tuple(ast.literal_eval(n.value) for n in ratios.body if isinstance(n, ast.Assign)) == RATIOS
|
|
+ )
|
|
+ tree = ast.parse((root / "core__comfy__samplers.py").read_text())
|
|
+ registry = next(
|
|
+ n
|
|
+ for n in tree.body
|
|
+ if isinstance(n, ast.Assign)
|
|
+ and any(isinstance(t, ast.Name) and t.id == "SCHEDULER_HANDLERS" for t in n.targets)
|
|
+ )
|
|
+ assert tuple(ast.literal_eval(k) for k in registry.value.keys) == SCHEDULERS
|
|
diff --git a/calliope-backend/tests/test_h3_reference.py b/calliope-backend/tests/test_h3_reference.py
|
|
index ac681f8..d68126a 100644
|
|
--- a/calliope-backend/tests/test_h3_reference.py
|
|
+++ b/calliope-backend/tests/test_h3_reference.py
|
|
@@ -315 +315 @@ def test_full_library_old_25_attempts_gaps_eight_hashes_and_six_pairs_frozen():
|
|
- assert len(baseline) == 25 and baseline == audit.REFERENCE_PROFILES[:-1]
|
|
+ assert len(baseline) == 25 and baseline == audit.REFERENCE_PROFILES[:25]
|
|
diff --git a/calliope-backend/tests/test_scail_load_reference.py b/calliope-backend/tests/test_scail_load_reference.py
|
|
index 349bc42..d89c3fe 100644
|
|
--- a/calliope-backend/tests/test_scail_load_reference.py
|
|
+++ b/calliope-backend/tests/test_scail_load_reference.py
|
|
@@ -247 +247,5 @@ def test_exact_historical_emission_is_not_user_provenance():
|
|
- [p for p in audit.REFERENCE_PROFILES if p not in (audit.GRID_PROFILE, audit.H3_PROFILE)]
|
|
+ [
|
|
+ p
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
+ if p not in (audit.GRID_PROFILE, audit.H3_PROFILE)
|
|
+ ]
|
|
diff --git a/calliope-backend/tests/test_setget_reference.py b/calliope-backend/tests/test_setget_reference.py
|
|
index 65bff83..41754ad 100644
|
|
--- a/calliope-backend/tests/test_setget_reference.py
|
|
+++ b/calliope-backend/tests/test_setget_reference.py
|
|
@@ -337 +337 @@ def test_wrong_frontend_missing_policy_and_profile_inventory():
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
@@ -424 +424 @@ def test_historical_18_profiles_attempts_gaps_and_six_comparisons_unchanged():
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
@@ -436 +436 @@ def test_historical_18_profiles_attempts_gaps_and_six_comparisons_unchanged():
|
|
- tuple(p for p in audit.REFERENCE_PROFILES if p != audit.H3_PROFILE),
|
|
+ tuple(p for p in audit.REFERENCE_PROFILES[:26] if p != audit.H3_PROFILE),
|
|
diff --git a/calliope-backend/tests/test_vhs_reference.py b/calliope-backend/tests/test_vhs_reference.py
|
|
index 3c09f1b..05c4b7c 100644
|
|
--- a/calliope-backend/tests/test_vhs_reference.py
|
|
+++ b/calliope-backend/tests/test_vhs_reference.py
|
|
@@ -291 +291 @@ def test_old_sixteen_attempts_gaps_candidates_and_six_comparisons_protected():
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
diff --git a/calliope-backend/tests/test_videoinfo_reference.py b/calliope-backend/tests/test_videoinfo_reference.py
|
|
index 9070345..fd09f6c 100644
|
|
--- a/calliope-backend/tests/test_videoinfo_reference.py
|
|
+++ b/calliope-backend/tests/test_videoinfo_reference.py
|
|
@@ -282 +282 @@ def test_real_entities_strict_source_schema_and_old_profiles_stay_frozen():
|
|
- for p in audit.REFERENCE_PROFILES
|
|
+ for p in audit.REFERENCE_PROFILES[:26]
|
|
diff --git a/docs/hel-892/h3-core-evidence/recompute.py b/docs/hel-892/h3-core-evidence/recompute.py
|
|
new file mode 100644
|
|
index 0000000..d986d92
|
|
--- /dev/null
|
|
+++ b/docs/hel-892/h3-core-evidence/recompute.py
|
|
@@ -0,0 +1,469 @@
|
|
+"""Recompute H3 core first-group reference evidence and protections without services or upstream execution."""
|
|
+
|
|
+from __future__ import annotations
|
|
+
|
|
+import argparse
|
|
+import hashlib
|
|
+import json
|
|
+import sqlite3
|
|
+import subprocess
|
|
+import sys
|
|
+import tarfile
|
|
+import zipfile
|
|
+from collections import Counter
|
|
+from pathlib import Path
|
|
+
|
|
+BASE = "8e832b8e0e14db85932f4d830be2d2929b9e62a1"
|
|
+
|
|
+
|
|
+def main():
|
|
+ parser = argparse.ArgumentParser(description=__doc__)
|
|
+ parser.add_argument("--repo", type=Path, required=True)
|
|
+ parser.add_argument("--db", type=Path, required=True)
|
|
+ parser.add_argument("--documents", type=Path, required=True)
|
|
+ args = parser.parse_args()
|
|
+ repo = args.repo.resolve()
|
|
+ sys.path.insert(0, str(repo / "calliope-backend"))
|
|
+ from calliope.comfyui.h3_core_reference import CORE_PROFILE
|
|
+ from scripts import audit_reference_conversion as audit
|
|
+ from scripts.audit_library_documents import audit as audit_docs
|
|
+ from scripts.verify_frontend_sources import verify
|
|
+
|
|
+ out = repo / "docs/hel-892/h3-core-evidence"
|
|
+
|
|
+ def write(name, value):
|
|
+ (out / name).write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n")
|
|
+
|
|
+ old = json.loads((repo / "docs/hel-892/h3-evidence/library.json").read_bytes())
|
|
+ profiles = tuple(old["profiles"])
|
|
+ assert len(profiles) == 26
|
|
+ assert profiles == tuple(p for p in audit.REFERENCE_PROFILES if p != CORE_PROFILE)
|
|
+ before = audit.audit_library(repo, profiles)
|
|
+ now = audit.audit_library(repo, baseline_profiles=profiles)
|
|
+ write("library.json", now)
|
|
+ for a, b, c in zip(old["cases"], before["cases"], now["cases"]):
|
|
+ assert a["source_path"] == b["source_path"] == c["source_path"]
|
|
+ assert a["attempts"] == b["attempts"] == c["attempts"][:26]
|
|
+ assert a.get("comparisons") == b.get("comparisons") == c.get("comparisons")
|
|
+ if a["candidate_hashes"]:
|
|
+ assert a["candidate_hashes"] == c["candidate_hashes"]
|
|
+ assert old["gap_groups"] == before["gap_groups"]
|
|
+ six = audit.audit(repo, "case04-batch-reference")
|
|
+ assert six == json.loads(
|
|
+ (repo / "docs/hel-892/media-evidence/protected-six-cases.json").read_bytes()
|
|
+ )
|
|
+ write(
|
|
+ "previous-protection.json",
|
|
+ {
|
|
+ "baseline_profiles": profiles,
|
|
+ "old_attempts_identical": True,
|
|
+ "old_gaps_identical": True,
|
|
+ "six_companion_differences_identical": True,
|
|
+ "old_candidate_hashes_identical": True,
|
|
+ },
|
|
+ )
|
|
+
|
|
+ def groups(report):
|
|
+ return {
|
|
+ tuple(
|
|
+ g[k]
|
|
+ for k in ("type", "provider", "version", "profile", "code", "rule_gap")
|
|
+ ): Counter(
|
|
+ (o["source_path"], o["node_pointer"], o["node_id"])
|
|
+ for o in g["occurrences"]
|
|
+ )
|
|
+ for g in report["gap_groups"]
|
|
+ }
|
|
+
|
|
+ def stats(report):
|
|
+ gs = groups(report)
|
|
+ return {
|
|
+ "groups": len(gs),
|
|
+ "raw_occurrences": sum(sum(c.values()) for c in gs.values()),
|
|
+ "unique_occurrences_per_group": sum(len(c) for c in gs.values()),
|
|
+ "unique_nodes": len({o for c in gs.values() for o in c}),
|
|
+ "unique_paths": len({o[0] for c in gs.values() for o in c}),
|
|
+ }
|
|
+
|
|
+ def diffrows(a, b):
|
|
+ return [
|
|
+ {
|
|
+ "key": list(k),
|
|
+ "occurrences": [
|
|
+ {
|
|
+ "source_path": o[0],
|
|
+ "node_pointer": o[1],
|
|
+ "node_id": o[2],
|
|
+ "count": n,
|
|
+ }
|
|
+ for o, n in sorted((v - b.get(k, Counter())).items(), key=str)
|
|
+ ],
|
|
+ }
|
|
+ for k, v in sorted(a.items(), key=str)
|
|
+ if v - b.get(k, Counter())
|
|
+ ]
|
|
+
|
|
+ def unavailable(report):
|
|
+ return sorted(
|
|
+ r["source_path"]
|
|
+ for r in report["cases"]
|
|
+ if all(a["status"] == "not_applicable" for a in r["attempts"])
|
|
+ )
|
|
+
|
|
+ removed_unavailable = sorted(set(unavailable(before)) - set(unavailable(now)))
|
|
+ added_unavailable = sorted(set(unavailable(now)) - set(unavailable(before)))
|
|
+ ga, gb = groups(before), groups(now)
|
|
+ added, removed = diffrows(gb, ga), diffrows(ga, gb)
|
|
+ write(
|
|
+ "coverage-delta.json",
|
|
+ {
|
|
+ "baseline_profiles": profiles,
|
|
+ "baseline": stats(before),
|
|
+ "current": stats(now),
|
|
+ "key_fields": [
|
|
+ "type",
|
|
+ "provider",
|
|
+ "version",
|
|
+ "profile",
|
|
+ "code",
|
|
+ "rule_gap",
|
|
+ ],
|
|
+ "occurrence_key": ["source_path", "node_pointer", "node_id"],
|
|
+ "added_groups": added,
|
|
+ "removed_groups": removed,
|
|
+ "added_occurrences": sum(
|
|
+ o["count"] for g in added for o in g["occurrences"]
|
|
+ ),
|
|
+ "removed_occurrences": sum(
|
|
+ o["count"] for g in removed for o in g["occurrences"]
|
|
+ ),
|
|
+ "new_complete_paths": now["coverage_delta"]["new_complete_paths"],
|
|
+ "complete_paths": now["coverage_delta"]["current_complete_paths"],
|
|
+ "closed_paths": [
|
|
+ r["source_path"] for r in now["cases"] if r["status"] == "blocked"
|
|
+ ],
|
|
+ "unavailable_frontend_before": unavailable(before),
|
|
+ "unavailable_frontend_after": unavailable(now),
|
|
+ "removed_unavailable_frontend_paths": removed_unavailable,
|
|
+ "added_unavailable_frontend_paths": added_unavailable,
|
|
+ "unavailable_frontend_change_reason": "new explicit missing-identity 1.53.10/core0.33.0 assumption; applicability is not source provenance or conversion success",
|
|
+ "attempt_counts": dict(
|
|
+ Counter(a["status"] for r in now["cases"] for a in r["attempts"])
|
|
+ ),
|
|
+ "conflicts": sum(r["status"] == "candidate_conflict" for r in now["cases"]),
|
|
+ },
|
|
+ )
|
|
+
|
|
+ from calliope.comfyui.ui2api import convert_reference
|
|
+
|
|
+ targets = sorted(
|
|
+ (repo / "example_ComfyUI_workflows/4-视频生成/uncensored").glob("*.json")
|
|
+ )
|
|
+ assert len(targets) == 3
|
|
+ actual_rows = []
|
|
+ for target in targets:
|
|
+ source = json.loads(target.read_bytes())
|
|
+ actual = convert_reference(source, CORE_PROFILE)
|
|
+ assert actual.prompt is None and actual.issues
|
|
+ row = next(
|
|
+ r
|
|
+ for r in now["cases"]
|
|
+ if r["source_path"] == target.relative_to(repo).as_posix()
|
|
+ )
|
|
+ assert row["comparison_status"] == "comparison_unavailable"
|
|
+ attempt = next(a for a in row["attempts"] if a["profile"] == CORE_PROFILE)
|
|
+ assert attempt["status"] == "rejected" and "candidate_prompt" not in attempt
|
|
+ actual_rows.append(
|
|
+ {
|
|
+ "source_path": row["source_path"],
|
|
+ "source_sha256": row["source_sha256"],
|
|
+ "profile": CORE_PROFILE,
|
|
+ "prompt": None,
|
|
+ "comparison_status": row["comparison_status"],
|
|
+ "execution_verified": False,
|
|
+ "original_bytes_modified": False,
|
|
+ "attempt": attempt,
|
|
+ }
|
|
+ )
|
|
+ write("actual-three-graphs.json", actual_rows)
|
|
+ main = next(
|
|
+ r
|
|
+ for r in actual_rows
|
|
+ if r["source_path"].endswith("minimax-h3文生视频无审核版.json")
|
|
+ )
|
|
+ evidence = main["attempt"]["supported_node_evidence"]
|
|
+ assert len(evidence) == 7 and sum(e["layout_accepted"] for e in evidence) == 5
|
|
+ assert sum(len(e["saved_fields"]) for e in evidence) == 11
|
|
+ main_source = json.loads((repo / main["source_path"]).read_bytes())
|
|
+
|
|
+ def pointer(doc, text):
|
|
+ for key in text.strip("/").split("/"):
|
|
+ doc = doc[int(key)] if isinstance(doc, list) else doc[key]
|
|
+ return doc
|
|
+
|
|
+ for r in actual_rows:
|
|
+ doc = json.loads((repo / r["source_path"]).read_bytes())
|
|
+ for e in r["attempt"]["supported_node_evidence"]:
|
|
+ for f in e["saved_fields"]:
|
|
+ value = pointer(doc, f["source_value_pointer"])
|
|
+ assert type(value).__name__ == f["json_type"] and value == f["value"]
|
|
+ for edge in e["physical_input_evidence"]:
|
|
+ original = pointer(doc, edge["link_pointer"])
|
|
+ assert edge["endpoint"] == [str(original[1]), original[2]]
|
|
+ write(
|
|
+ "main-node-evidence.json",
|
|
+ {
|
|
+ "source_path": main["source_path"],
|
|
+ "source_sha256": main["source_sha256"],
|
|
+ "source_entities": len(main_source["nodes"]),
|
|
+ "source_edges": len(main_source["links"]),
|
|
+ "profile": CORE_PROFILE,
|
|
+ "prompt": None,
|
|
+ "complete_candidates_added": 0,
|
|
+ "comparison_status": "comparison_unavailable",
|
|
+ "saved_fields_only": 11,
|
|
+ "layout_accepted_instances": 5,
|
|
+ "layout_rejected_instances": 2,
|
|
+ "supported_node_evidence": evidence,
|
|
+ "remaining_classes": sorted(
|
|
+ {
|
|
+ n["type"]
|
|
+ for n in main_source["nodes"]
|
|
+ if n["type"] not in {e["type"] for e in evidence}
|
|
+ }
|
|
+ ),
|
|
+ "remaining_instance_count": len(main_source["nodes"]) - len(evidence),
|
|
+ "issues": main["attempt"]["issues"],
|
|
+ "no_partial_prompt": True,
|
|
+ "execution_verified": False,
|
|
+ },
|
|
+ )
|
|
+ inventory = evidence
|
|
+ attempts = [
|
|
+ {
|
|
+ "source_path": r["source_path"],
|
|
+ "source_sha256": r["source_sha256"],
|
|
+ "declared_frontend": r["frontend_version"],
|
|
+ "attempt": r["attempts"][-1],
|
|
+ }
|
|
+ for r in now["cases"]
|
|
+ ]
|
|
+ assert all(r["attempt"]["profile"] == CORE_PROFILE for r in attempts)
|
|
+ write(
|
|
+ "profile-disposition.json",
|
|
+ {
|
|
+ "profile": CORE_PROFILE,
|
|
+ "counts": dict(Counter(r["attempt"]["status"] for r in attempts)),
|
|
+ "cases": attempts,
|
|
+ "proven_source_identity": False,
|
|
+ "complete_candidates_added": 0,
|
|
+ },
|
|
+ )
|
|
+
|
|
+ dirs = [
|
|
+ "serialization-evidence",
|
|
+ "structure-reference",
|
|
+ "controlnet-reference",
|
|
+ "promoted-reference",
|
|
+ "case04-reference",
|
|
+ "media-reference",
|
|
+ "separation-reference",
|
|
+ "crop-split-reference",
|
|
+ "vhs-reference",
|
|
+ "setget-reference",
|
|
+ "videoinfo-reference",
|
|
+ "scail-load-reference",
|
|
+ "grid-reference",
|
|
+ "h3-reference",
|
|
+ "h3-core-reference",
|
|
+ ]
|
|
+ entries = []
|
|
+ counts = []
|
|
+ for name in dirs:
|
|
+ directory = repo / "docs/hel-892" / name
|
|
+ verify(directory)
|
|
+ rows = json.loads((directory / "sources.json").read_bytes())["sources"]
|
|
+ for entry in rows:
|
|
+ lines = (directory / entry["local_file"]).read_text().splitlines()
|
|
+ locations = entry.get("rule_locations", {})
|
|
+ for lo, hi in (
|
|
+ locations.values() if isinstance(locations, dict) else locations
|
|
+ ):
|
|
+ assert 1 <= lo <= hi <= len(lines)
|
|
+ counts.append(
|
|
+ {
|
|
+ "manifest": name,
|
|
+ "entries": len(rows),
|
|
+ "unique_ids": len({r["id"] for r in rows}),
|
|
+ }
|
|
+ )
|
|
+ entries.extend(rows)
|
|
+ write(
|
|
+ "cached-sources-check.json",
|
|
+ {
|
|
+ "manifests": counts,
|
|
+ "entries": len(entries),
|
|
+ "unique_ids_summed_per_manifest": sum(c["unique_ids"] for c in counts),
|
|
+ "global_distinct_id_strings": len({r["id"] for r in entries}),
|
|
+ "unique_url_and_hash": len({(r["raw_url"], r["sha256"]) for r in entries}),
|
|
+ "note": "ID counts are strings; URL+SHA256 is separately deduplicated; repeated frontend originals retained",
|
|
+ },
|
|
+ )
|
|
+
|
|
+ originals = json.loads(
|
|
+ (repo / "docs/hel-892/media-evidence/original-bytes.json").read_bytes()
|
|
+ )["files"]
|
|
+ for row in originals:
|
|
+ raw = (repo / row["path"]).read_bytes()
|
|
+ assert raw == subprocess.check_output(
|
|
+ ["git", "show", f"{BASE}:{row['path']}"], cwd=repo
|
|
+ )
|
|
+ assert len(originals) == 163
|
|
+ write(
|
|
+ "original-bytes.json",
|
|
+ {"base": BASE, "count": 163, "all_unchanged": True, "files": originals},
|
|
+ )
|
|
+ production = json.loads(
|
|
+ (repo / "docs/hel-892/setget-evidence/production-protection.json").read_bytes()
|
|
+ )["files"]
|
|
+ for row in production:
|
|
+ raw = (repo / row["path"]).read_bytes()
|
|
+ assert raw == subprocess.check_output(
|
|
+ ["git", "show", f"{BASE}:{row['path']}"], cwd=repo
|
|
+ )
|
|
+ assert hashlib.sha256(raw).hexdigest() == row["sha256"]
|
|
+ write("production-protection.json", {"base": BASE, "files": production})
|
|
+ db = sqlite3.connect(args.db)
|
|
+ db.row_factory = sqlite3.Row
|
|
+ rows = db.execute(
|
|
+ "SELECT * FROM workflows WHERE source_repo_path IS NOT NULL"
|
|
+ ).fetchall()
|
|
+ assert len(rows) == 155
|
|
+ assert Counter(r["import_state"] for r in rows) == {
|
|
+ "pending_check": 16,
|
|
+ "needs_conversion": 139,
|
|
+ }
|
|
+ assert not any(
|
|
+ r["is_enabled"] or r["doc_completed_at"] or r["exec_verified_at"] for r in rows
|
|
+ )
|
|
+ issues = Counter(i["code"] for r in rows for i in json.loads(r["import_issues"]))
|
|
+ companion_values = sum(
|
|
+ p.get("value_origin") == "supplied_api_companion"
|
|
+ for r in rows
|
|
+ for p in json.loads(r["doc_json"])["params"]
|
|
+ )
|
|
+ assert (
|
|
+ companion_values == 294
|
|
+ and issues["companion_unverified"] == 6
|
|
+ and issues["environment_unchecked"] == 16
|
|
+ )
|
|
+ write(
|
|
+ "isolation.json",
|
|
+ {
|
|
+ "states": dict(Counter(r["import_state"] for r in rows)),
|
|
+ "count": 155,
|
|
+ "enabled_or_completed_or_executed": 0,
|
|
+ "issue_counts": dict(issues),
|
|
+ "companion_named_values": companion_values,
|
|
+ "reference_candidates_written_to_db": False,
|
|
+ "user_whole_row_protection": "executed affected tests",
|
|
+ },
|
|
+ )
|
|
+ from calliope.comfyui.companions import load_companions
|
|
+ from calliope.comfyui.library import import_library
|
|
+
|
|
+ # A separate in-memory copy proves the complete user row is preserved;
|
|
+ # the fresh catalogue under audit is never mutated by this protection check.
|
|
+ protected = sqlite3.connect(":memory:")
|
|
+ db.backup(protected)
|
|
+ protected.row_factory = sqlite3.Row
|
|
+ wid = rows[0]["id"]
|
|
+ protected.execute(
|
|
+ "UPDATE workflows SET description='用户整行保护测试' WHERE id=?", (wid,)
|
|
+ )
|
|
+ protected.commit()
|
|
+ snapshot = dict(
|
|
+ protected.execute("SELECT * FROM workflows WHERE id=?", (wid,)).fetchone()
|
|
+ )
|
|
+ rerun = import_library(
|
|
+ protected,
|
|
+ repo / "example_ComfyUI_workflows",
|
|
+ source_commit=BASE,
|
|
+ companions=load_companions(repo / "docs/hel-892/supplied-api/manifest.json"),
|
|
+ )
|
|
+ assert rerun["counts"] == {"conflict": 1, "skipped": 154, "user_excluded": 1}
|
|
+ assert (
|
|
+ dict(protected.execute("SELECT * FROM workflows WHERE id=?", (wid,)).fetchone())
|
|
+ == snapshot
|
|
+ )
|
|
+ write(
|
|
+ "user-row-protection.json",
|
|
+ {
|
|
+ "isolated_in_memory_copy": True,
|
|
+ "counts": rerun["counts"],
|
|
+ "all_columns_identical": True,
|
|
+ "column_count": len(snapshot),
|
|
+ "fresh_catalogue_mutated": False,
|
|
+ },
|
|
+ )
|
|
+ protected.close()
|
|
+ db.close()
|
|
+ report = audit_docs(repo, args.documents.resolve())
|
|
+ summary = {k: v for k, v in report.items() if k != "files"}
|
|
+ assert (
|
|
+ summary["named_values_preserved"] == 1217
|
|
+ and summary["unnamed_widget_nodes"] == 3660
|
|
+ )
|
|
+ assert summary["full_documents_completed"] == 0 and summary["real_executions"] == 0
|
|
+ write("document-audit-summary.json", summary)
|
|
+ packages = []
|
|
+ with (
|
|
+ zipfile.ZipFile(next((repo / "calliope-backend/dist").glob("*.whl"))) as wh,
|
|
+ tarfile.open(next((repo / "calliope-backend/dist").glob("*.tar.gz"))) as sd,
|
|
+ ):
|
|
+ for name in [
|
|
+ "h3_core_reference.py",
|
|
+ "structure_reference.py",
|
|
+ "serialization_reference.py",
|
|
+ "ui2api.py",
|
|
+ "protocol_references.json",
|
|
+ "source_reviews.json",
|
|
+ "delivery_scope.py",
|
|
+ "delivery_scope.json",
|
|
+ ]:
|
|
+ p = f"calliope-backend/src/calliope/comfyui/{name}"
|
|
+ raw = (repo / p).read_bytes()
|
|
+ assert wh.read(f"calliope/comfyui/{name}") == raw
|
|
+ member = next(
|
|
+ n for n in sd.getnames() if n.endswith(f"/src/calliope/comfyui/{name}")
|
|
+ )
|
|
+ assert sd.extractfile(member).read() == raw
|
|
+ packages.append(
|
|
+ {
|
|
+ "path": p,
|
|
+ "sha256": hashlib.sha256(raw).hexdigest(),
|
|
+ "wheel_matches": True,
|
|
+ "sdist_matches": True,
|
|
+ }
|
|
+ )
|
|
+ write("package-check.json", packages)
|
|
+ print(
|
|
+ json.dumps(
|
|
+ {
|
|
+ "ui": now["ui_total"],
|
|
+ "attempts": Counter(
|
|
+ a["status"] for r in now["cases"] for a in r["attempts"]
|
|
+ ),
|
|
+ "complete": len(now["coverage_delta"]["current_complete_paths"]),
|
|
+ "new_complete": now["coverage_delta"]["new_complete_paths"],
|
|
+ "inventory_nodes": len(inventory),
|
|
+ "inventory_paths": 1,
|
|
+ "gap_stats": stats(now),
|
|
+ },
|
|
+ ensure_ascii=False,
|
|
+ )
|
|
+ )
|
|
+
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ main()
|
|
diff --git a/docs/hel-892/h3-core-reference/make_manifest.py b/docs/hel-892/h3-core-reference/make_manifest.py
|
|
new file mode 100644
|
|
index 0000000..254bc34
|
|
--- /dev/null
|
|
+++ b/docs/hel-892/h3-core-reference/make_manifest.py
|
|
@@ -0,0 +1,155 @@
|
|
+"""Inventory immutable core bytes and reuse the SAME pinned frontend identity."""
|
|
+
|
|
+import hashlib
|
|
+import json
|
|
+from pathlib import Path
|
|
+
|
|
+ROOT = Path(__file__).resolve().parent
|
|
+CORE = "2f35f4a08176d993cded35dac3332be4f7287f41"
|
|
+FRONTEND = "743be3f4fe2e374b0ee39f0ded56e7cb65a837c5"
|
|
+ANCHORS = (
|
|
+ "class StringMultiline",
|
|
+ "class Float",
|
|
+ "class ResolutionSelector",
|
|
+ "class AspectRatio",
|
|
+ "class MathExpressionNode",
|
|
+ "class RandomNoise",
|
|
+ "class BasicScheduler",
|
|
+ "def define_schema",
|
|
+ "async def get_node_list",
|
|
+ "async def comfy_entrypoint",
|
|
+ "class MultiType",
|
|
+ "class Autogrow",
|
|
+ "class TemplateNames",
|
|
+ "def as_dict",
|
|
+ "def _expand_schema_for_dynamic",
|
|
+ "node_id",
|
|
+ "get_node_list()",
|
|
+ "schema.node_id",
|
|
+ "nodes_primitive.py",
|
|
+ "nodes_resolution.py",
|
|
+ "nodes_math.py",
|
|
+ "nodes_custom_sampler.py",
|
|
+ "SCHEDULER_HANDLERS =",
|
|
+ "SCHEDULER_NAMES =",
|
|
+ "def execute",
|
|
+ "noise_seed",
|
|
+ "control_after_generate",
|
|
+ "getRestoredWidgetValue",
|
|
+ "createWidgetRestorationState",
|
|
+ "restoreNamed",
|
|
+ "serializeValue",
|
|
+ "widgets_values_named",
|
|
+ "serialiseWidgetValues",
|
|
+ "widget.options?.serialize",
|
|
+ "inputs[input.name]",
|
|
+ "applyAutogrow",
|
|
+ "addAutogrowGroup",
|
|
+ "autogrowOrdinalToName",
|
|
+ "onConnectionsChange",
|
|
+ "getOrderedInputSpecs",
|
|
+ "for (const inputSpec of orderedInputSpecs)",
|
|
+ "mode === 'fixed'",
|
|
+ "beforeQueued",
|
|
+ "afterQueued",
|
|
+ "applyDynamicInputs",
|
|
+ "RESOLUTION",
|
|
+ "serialize: false",
|
|
+ "fallbackWidgetsValuesNames",
|
|
+)
|
|
+
|
|
+
|
|
+def main():
|
|
+ old = json.loads((ROOT.parent / "h3-reference/sources.json").read_bytes())
|
|
+ rows = []
|
|
+ for entry in old["sources"]:
|
|
+ if entry["id"].startswith("frontend:"):
|
|
+ row = dict(entry)
|
|
+ row["local_file"] = "../h3-reference/" + row["local_file"]
|
|
+ row["reuse"] = (
|
|
+ "same frontend1.53.10 full commit, no core0.30.0 identity reused"
|
|
+ )
|
|
+ rows.append(row)
|
|
+ existing = {r["id"] for r in rows}
|
|
+ for p in sorted(ROOT.glob("*__*")):
|
|
+ prefix, _, tail = p.name.partition("__")
|
|
+ if prefix not in ("core", "frontend"):
|
|
+ continue
|
|
+ filename = tail.replace("__", "/")
|
|
+ ident = f"{prefix}:{filename}"
|
|
+ if ident in existing:
|
|
+ # Already references the same full commit original, do not duplicate.
|
|
+ continue
|
|
+ repo, sha, tag = (
|
|
+ ("Comfy-Org/ComfyUI", CORE, "v0.33.0")
|
|
+ if prefix == "core"
|
|
+ else ("Comfy-Org/ComfyUI_frontend", FRONTEND, "v1.53.10")
|
|
+ )
|
|
+ lines = p.read_text().splitlines()
|
|
+ locations = {
|
|
+ f"{anchor}@{i}": [i, min(i + 4, len(lines))]
|
|
+ for anchor in ANCHORS
|
|
+ for i, line in enumerate(lines, 1)
|
|
+ if anchor in line
|
|
+ }
|
|
+ rows.append(
|
|
+ {
|
|
+ "id": ident,
|
|
+ "repository": f"https://github.com/{repo}",
|
|
+ "commit": sha,
|
|
+ "tag": tag,
|
|
+ "file": filename,
|
|
+ "lines": [[1, len(lines)]],
|
|
+ "rule_locations": locations,
|
|
+ "raw_url": f"https://raw.githubusercontent.com/{repo}/{sha}/{filename}",
|
|
+ "url": f"https://github.com/{repo}/blob/{sha}/{filename}",
|
|
+ "sha256": hashlib.sha256(p.read_bytes()).hexdigest(),
|
|
+ "local_file": p.name,
|
|
+ "license": "GPL-3.0",
|
|
+ "target_version_match": "unknown",
|
|
+ }
|
|
+ )
|
|
+ identities = []
|
|
+ for name, repo, ref, expected, local in (
|
|
+ ("core-tag", "Comfy-Org/ComfyUI", "v0.33.0", CORE, "core-tag.json"),
|
|
+ (
|
|
+ "frontend-tag",
|
|
+ "Comfy-Org/ComfyUI_frontend",
|
|
+ "v1.53.10",
|
|
+ FRONTEND,
|
|
+ "../h3-reference/ComfyUI_frontend-tag.json",
|
|
+ ),
|
|
+ ):
|
|
+ raw = (ROOT / local).read_bytes()
|
|
+ data = json.loads(raw)
|
|
+ assert data["object"]["sha"] == expected and data["object"]["type"] == "commit"
|
|
+ identities.append(
|
|
+ {
|
|
+ "id": name,
|
|
+ "raw_url": f"https://api.github.com/repos/{repo}/git/ref/tags/{ref}",
|
|
+ "local_file": local,
|
|
+ "sha256": hashlib.sha256(raw).hexdigest(),
|
|
+ "ref": f"refs/tags/{ref}",
|
|
+ "commit": expected,
|
|
+ }
|
|
+ )
|
|
+ (ROOT / "sources.json").write_text(
|
|
+ json.dumps(
|
|
+ {
|
|
+ "schema_version": 1,
|
|
+ "authority": "public_reference_only_not_object_info",
|
|
+ "sources": rows,
|
|
+ "identity_observations": identities,
|
|
+ "target_installation": "unknown",
|
|
+ "source_graph_identity": "unknown",
|
|
+ "upstream_code_executed": False,
|
|
+ },
|
|
+ ensure_ascii=False,
|
|
+ indent=2,
|
|
+ )
|
|
+ + "\n"
|
|
+ )
|
|
+
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ main()
|
|
diff --git a/docs/hel-892/h3-core-reference/verify_identity.py b/docs/hel-892/h3-core-reference/verify_identity.py
|
|
new file mode 100644
|
|
index 0000000..9e78718
|
|
--- /dev/null
|
|
+++ b/docs/hel-892/h3-core-reference/verify_identity.py
|
|
@@ -0,0 +1,47 @@
|
|
+"""Recheck mutable tag identity fields; byte SHA is only the saved observation."""
|
|
+
|
|
+import hashlib
|
|
+import json
|
|
+from pathlib import Path
|
|
+from urllib.request import urlopen
|
|
+
|
|
+ROOT = Path(__file__).resolve().parent
|
|
+
|
|
+
|
|
+def main():
|
|
+ manifest = json.loads((ROOT / "sources.json").read_bytes())
|
|
+ rows = []
|
|
+ for entry in manifest["identity_observations"]:
|
|
+ raw = (ROOT / entry["local_file"]).read_bytes()
|
|
+ assert hashlib.sha256(raw).hexdigest() == entry["sha256"]
|
|
+ with urlopen(entry["raw_url"], timeout=30) as response:
|
|
+ now = json.loads(response.read())
|
|
+ assert now["ref"] == entry["ref"] and now["object"]["type"] == "commit"
|
|
+ assert now["object"]["sha"] == entry["commit"]
|
|
+ rows.append(
|
|
+ {
|
|
+ "id": entry["id"],
|
|
+ "url": entry["raw_url"],
|
|
+ "ref": now["ref"],
|
|
+ "commit": now["object"]["sha"],
|
|
+ "saved_observation_sha256": entry["sha256"],
|
|
+ "byte_identity_required": False,
|
|
+ }
|
|
+ )
|
|
+ (ROOT.parent / "h3-core-evidence/identity-refetched.json").write_text(
|
|
+ json.dumps(
|
|
+ {
|
|
+ "observations": rows,
|
|
+ "target_installation": "unknown",
|
|
+ "source_graph_identity": "unknown",
|
|
+ "upstream_executed": False,
|
|
+ },
|
|
+ ensure_ascii=False,
|
|
+ indent=2,
|
|
+ )
|
|
+ + "\n"
|
|
+ )
|
|
+
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ main()
|