HEL-892: add pinned H3 saved-state reference conversion
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -41,6 +41,7 @@ from calliope.comfyui.serialization_reference import (
|
||||
)
|
||||
from calliope.comfyui.structure_reference import (
|
||||
GRID_PROFILE,
|
||||
H3_PROFILE,
|
||||
PROMOTED_PROFILES,
|
||||
SCAIL_LOAD_PROFILES,
|
||||
SETGET_COMMIT,
|
||||
@@ -305,6 +306,7 @@ REFERENCE_PROFILES = (
|
||||
*VIDEOINFO_PROFILES,
|
||||
*SCAIL_LOAD_PROFILES,
|
||||
GRID_PROFILE,
|
||||
H3_PROFILE,
|
||||
)
|
||||
|
||||
|
||||
@@ -339,7 +341,9 @@ def node_inventory(source, *, include_aux=False):
|
||||
or (props.get("aux_id") if include_aux else None),
|
||||
"version": props.get("ver"),
|
||||
"mode": node.get("mode", 0),
|
||||
"widget_count": len(node.get("widgets_values", [])),
|
||||
"widget_count": len(node["widgets_values"])
|
||||
if isinstance(node.get("widgets_values"), (list, dict))
|
||||
else 0,
|
||||
"widget_layout": type(node.get("widgets_values", [])).__name__,
|
||||
"ue_version": (props.get("ue_properties") or {}).get("version"),
|
||||
}
|
||||
@@ -551,12 +555,59 @@ def grid_field_evidence(source, prompt):
|
||||
return fields
|
||||
|
||||
|
||||
def h3_field_evidence(source, prompt):
|
||||
"""Exact typed dual-save pointers or physical links; no generated text."""
|
||||
from calliope.comfyui.serialization_reference import H3_CHECK_LAYOUT, H3_WRITER_LAYOUT
|
||||
|
||||
fields = []
|
||||
for i, node in enumerate(source["nodes"]):
|
||||
nid = str(node["id"])
|
||||
layout = H3_WRITER_LAYOUT if node["type"] == "MiniMaxH3GuidedWriter" else H3_CHECK_LAYOUT
|
||||
for name, value in prompt[nid]["inputs"].items():
|
||||
socket = next((s for s in node["inputs"] if s["name"] == name), {})
|
||||
pointers = []
|
||||
shadowed = []
|
||||
if socket.get("link") is not None:
|
||||
j, edge = next(
|
||||
(j, e) for j, e in enumerate(source["links"]) if e[0] == socket["link"]
|
||||
)
|
||||
expected, pointer = [str(edge[1]), edge[2]], f"/links/{j}"
|
||||
if name in layout and name in node.get("widgets_values_named", {}):
|
||||
shadowed = [
|
||||
f"/nodes/{i}/widgets_values/{layout.index(name)}",
|
||||
f"/nodes/{i}/widgets_values_named/{name}",
|
||||
]
|
||||
else:
|
||||
w = layout.index(name)
|
||||
expected, pointer = node["widgets_values"][w], f"/nodes/{i}/widgets_values/{w}"
|
||||
pointers = [f"/nodes/{i}/widgets_values_named/{name}"]
|
||||
assert type(value) is type(expected) and value == expected
|
||||
fields.append(
|
||||
{
|
||||
"node_id": nid,
|
||||
"field": name,
|
||||
"value": value,
|
||||
"json_type": type(value).__name__,
|
||||
"source_pointer": pointer,
|
||||
"corroborating_pointers": pointers,
|
||||
"shadowed_saved_pointers": shadowed,
|
||||
"class_pointer": f"/nodes/{i}/type",
|
||||
"title_pointer": f"/nodes/{i}/title"
|
||||
if node.get("title")
|
||||
else f"/nodes/{i}/type",
|
||||
"contract_manifest": "h3-reference/sources.json",
|
||||
}
|
||||
)
|
||||
return fields
|
||||
|
||||
|
||||
def profile_attempt(source, profile):
|
||||
expected = {
|
||||
**STRUCTURE_PROFILES,
|
||||
**PROMOTED_PROFILES,
|
||||
CASE04_PROFILE: "1.53.6",
|
||||
GRID_PROFILE: "1.41.20",
|
||||
H3_PROFILE: "1.53.10",
|
||||
**VHS_PROFILES,
|
||||
**SETGET_PROFILES,
|
||||
**VIDEOINFO_PROFILES,
|
||||
@@ -737,6 +788,13 @@ def profile_attempt(source, profile):
|
||||
if profile in VHS_PROFILES
|
||||
else "crop-split-reference/verified-facts.json"
|
||||
)
|
||||
if profile == H3_PROFILE:
|
||||
assumptions["h3_contract"] = "h3-reference/sources.json"
|
||||
assumptions["reference_sources"] = ["h3-reference/sources.json"]
|
||||
assumptions["core_version"] = "0.30.0"
|
||||
assumptions["h3_commit"] = "a59888df88a69385d429b6865ea441e7844f49c9"
|
||||
assumptions["restoration_policy"] = "named_and_positional_exact_typed_agreement"
|
||||
assumptions["model_library_and_inference"] = "not_checked_or_executed"
|
||||
if profile == GRID_PROFILE:
|
||||
assumptions["grid_contract"] = "grid-reference/sources.json"
|
||||
assumptions["core_version"] = "0.17.0"
|
||||
@@ -838,7 +896,9 @@ def profile_attempt(source, profile):
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
{"field_evidence": grid_field_evidence(source, result.prompt)}
|
||||
{"field_evidence": h3_field_evidence(source, result.prompt)}
|
||||
if profile == H3_PROFILE
|
||||
else {"field_evidence": grid_field_evidence(source, result.prompt)}
|
||||
if profile == GRID_PROFILE
|
||||
else {"field_evidence": asr_field_evidence(source, result.prompt)}
|
||||
if profile == ASR_PROFILE
|
||||
@@ -956,7 +1016,9 @@ def audit_library(repo: Path, profiles=REFERENCE_PROFILES, *, baseline_profiles=
|
||||
}
|
||||
if baseline_profiles is None:
|
||||
excluded_profiles = (
|
||||
(GRID_PROFILE,)
|
||||
(H3_PROFILE,)
|
||||
if H3_PROFILE in profiles
|
||||
else (GRID_PROFILE,)
|
||||
if GRID_PROFILE in profiles
|
||||
else SCAIL_LOAD_PROFILES
|
||||
if any(p in SCAIL_LOAD_PROFILES for p in profiles)
|
||||
|
||||
Reference in New Issue
Block a user