HEL-892: add pinned case04 saved-state serialization contract
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -19,10 +19,12 @@ from calliope.comfyui.companions import load_companions
|
||||
from calliope.comfyui.delivery_scope import exclusion_for
|
||||
from calliope.comfyui.serialization_reference import (
|
||||
AUX_PROFILE,
|
||||
CASE04_PROFILE,
|
||||
PREVIEW_PROFILE,
|
||||
PRIMITIVE_PROFILE,
|
||||
PROFILE,
|
||||
resolve_reference_link,
|
||||
serialize_case04_node,
|
||||
serialize_promoted_node,
|
||||
serialize_reference_widgets,
|
||||
)
|
||||
@@ -30,6 +32,22 @@ from calliope.comfyui.structure_reference import PROMOTED_PROFILES, STRUCTURE_PR
|
||||
from calliope.comfyui.ui2api import convert, convert_reference
|
||||
|
||||
|
||||
def saved_named_pointer(source, nid, name):
|
||||
"""Locate immutable original named bytes by scoped IDs, never API values."""
|
||||
graph, prefix = source, ""
|
||||
definitions = (source.get("definitions") or {}).get("subgraphs", [])
|
||||
parts = nid.split(":")
|
||||
for depth, part in enumerate(parts):
|
||||
index, node = next((i, n) for i, n in enumerate(graph["nodes"]) if str(n["id"]) == part)
|
||||
if depth == len(parts) - 1:
|
||||
if name in (node.get("widgets_values_named") or {}):
|
||||
escaped = name.replace("~", "~0").replace("/", "~1")
|
||||
return prefix + f"/nodes/{index}/widgets_values_named/" + escaped
|
||||
return None
|
||||
dindex, graph = next((i, d) for i, d in enumerate(definitions) if d["id"] == node["type"])
|
||||
prefix = f"/definitions/subgraphs/{dindex}"
|
||||
|
||||
|
||||
def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
rows = []
|
||||
records = load_companions(repo / "docs/hel-892/supplied-api/manifest.json")
|
||||
@@ -43,7 +61,11 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
source, api = json.loads(raw), json.loads(record["raw"])
|
||||
assert convert(api).prompt is not None
|
||||
selected = profile
|
||||
if profile in ("structure-batch-reference", "promoted-batch-reference"):
|
||||
if profile in (
|
||||
"structure-batch-reference",
|
||||
"promoted-batch-reference",
|
||||
"case04-batch-reference",
|
||||
):
|
||||
version = source.get("extra", {}).get("frontendVersion")
|
||||
structural = f"comfy-frontend-{version}-structure-reference"
|
||||
selected = (
|
||||
@@ -54,7 +76,7 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
if any(n.get("type") == "PrimitiveNode" for n in source["nodes"])
|
||||
else AUX_PROFILE
|
||||
)
|
||||
if profile == "promoted-batch-reference":
|
||||
if profile in ("promoted-batch-reference", "case04-batch-reference"):
|
||||
selected = (
|
||||
selected.replace("-structure-reference", "-promoted-reference")
|
||||
if selected.replace("-structure-reference", "-promoted-reference")
|
||||
@@ -63,6 +85,8 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
if selected == PRIMITIVE_PROFILE
|
||||
else selected
|
||||
)
|
||||
if profile == "case04-batch-reference" and binding["id"] == "04":
|
||||
selected = CASE04_PROFILE
|
||||
candidate = convert_reference(source, selected)
|
||||
projected = candidate.diagnostic_graph or source
|
||||
nodes = {str(n["id"]): n for n in projected["nodes"]}
|
||||
@@ -77,7 +101,9 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
continue
|
||||
try:
|
||||
values = (
|
||||
serialize_promoted_node(node, PROMOTED_PROFILES[selected])
|
||||
serialize_case04_node(node)
|
||||
if selected == CASE04_PROFILE
|
||||
else serialize_promoted_node(node, PROMOTED_PROFILES[selected])
|
||||
if selected in PROMOTED_PROFILES
|
||||
else serialize_reference_widgets(node, selected)
|
||||
)
|
||||
@@ -94,10 +120,26 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
"node_id": nid,
|
||||
"field": name,
|
||||
"source_reference": value,
|
||||
**(
|
||||
{
|
||||
"source_value_pointer": next(
|
||||
(
|
||||
b["value_pointer"]
|
||||
for b in candidate.resolved_boundaries
|
||||
if b["node_id"] == nid and b["input_name"] == name
|
||||
),
|
||||
saved_named_pointer(source, nid, name),
|
||||
),
|
||||
"serializer_contract": "case04-reference/sources.json; "
|
||||
"case04-reference/contracts.json",
|
||||
}
|
||||
if selected == CASE04_PROFILE
|
||||
else {}
|
||||
),
|
||||
"api": expected,
|
||||
"differences": (
|
||||
differences({}, {name: value})
|
||||
if selected in (PREVIEW_PROFILE, *PROMOTED_PROFILES)
|
||||
if selected in (PREVIEW_PROFILE, CASE04_PROFILE, *PROMOTED_PROFILES)
|
||||
and name not in api.get(nid, {}).get("inputs", {})
|
||||
else differences(expected, value)
|
||||
),
|
||||
@@ -162,8 +204,9 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
"source_frontend_version": source.get("extra", {}).get("frontendVersion"),
|
||||
"export_frontend_version": binding["frontend_version"],
|
||||
"whole_prompt_available": candidate.prompt is not None,
|
||||
"serialization_stage": candidate.serialization_stage,
|
||||
"candidate_prompt": candidate.prompt
|
||||
if profile == "promoted-batch-reference"
|
||||
if profile in ("promoted-batch-reference", "case04-batch-reference", CASE04_PROFILE)
|
||||
else None,
|
||||
"whole_prompt_differences": differences(api, candidate.prompt)
|
||||
if candidate.prompt is not None
|
||||
@@ -201,7 +244,13 @@ def audit(repo: Path, profile: str = PROFILE) -> dict:
|
||||
"diagnostic structures never prove widget values, full equivalence or execution",
|
||||
"reference_conditions": {
|
||||
"unmodified_frontend_widgets_assumed": True,
|
||||
"promoted_named_positional": "1.53.6 requires both representations to agree when named values exist; 1.48.7 ignores unknown named keys",
|
||||
"promoted_named_positional": (
|
||||
"1.53.6 requires both representations to agree when named values exist; "
|
||||
"1.48.7 ignores unknown named keys"
|
||||
),
|
||||
"case04_stage": "restored_saved_state_before_queue_hooks; fixed controls only",
|
||||
"case04_uncovered": "queue history/settings, non-fixed seed, other dynamic branches, "
|
||||
"dynamic text/filename expressions, unknown extension overrides",
|
||||
"promoted_missing_or_null": "no silent default; typed scalar consumption rejects null",
|
||||
"primitive_inside_promoted_profile": "unsupported; whole prompt remains closed",
|
||||
"combo_availability": "not evaluated; fixed scalar constructor only",
|
||||
@@ -233,6 +282,8 @@ def main():
|
||||
PREVIEW_PROFILE,
|
||||
*STRUCTURE_PROFILES,
|
||||
*PROMOTED_PROFILES,
|
||||
CASE04_PROFILE,
|
||||
"case04-batch-reference",
|
||||
"promoted-batch-reference",
|
||||
"structure-batch-reference",
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user