HEL-892: add fixed Wan Animate2 loop reference and audited evidence
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
"""Every original typed value and scope survives, while trust stays closed to mutations."""
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import runpy
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from calliope.comfyui.fixed_document import DEFINITIONS, canonical
|
||||
from calliope.comfyui.library import build_document
|
||||
from calliope.comfyui.source_reviews import review_for
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
PATH = "example_ComfyUI_workflows/6-动作迁移/Wan_Animate2_动作迁移_for循环长视频.json"
|
||||
OUT = ROOT / "docs/hel-892/animate2-loop-document-evidence"
|
||||
RAW = (ROOT / PATH).read_bytes()
|
||||
SOURCE = json.loads(RAW)
|
||||
REVIEW = review_for(PATH, hashlib.sha1(RAW).hexdigest())
|
||||
BLOCK = REVIEW["fixed_version_document"]
|
||||
|
||||
|
||||
def at(obj, pointer):
|
||||
for k in pointer.strip("/").split("/"):
|
||||
key = k.replace("~1", "/").replace("~0", "~")
|
||||
obj = obj[int(key)] if isinstance(obj, list) else obj[key]
|
||||
return obj
|
||||
|
||||
|
||||
def document(source=SOURCE, review=REVIEW):
|
||||
return build_document(PATH, source, None, None, [], review)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", BLOCK["fields"], ids=lambda f: f["pointer"])
|
||||
def test_every_saved_value_has_its_original_pointer_and_type(field):
|
||||
value = at(SOURCE, field["pointer"])
|
||||
assert type(value).__name__ == field["json_type"]
|
||||
assert canonical(value) == canonical(field["value"])
|
||||
assert field["named_state"] == "missing"
|
||||
assert "named_pointer" not in field and "named_value" not in field
|
||||
rendered = document()["fixed_version"]["fields"]
|
||||
assert next(f for f in rendered if f["pointer"] == field["pointer"]) == field
|
||||
|
||||
|
||||
@pytest.mark.parametrize("note", BLOCK["comments"], ids=lambda n: n["node_id"])
|
||||
def test_complete_note_utf8_and_line_endings_survive(note):
|
||||
original = at(SOURCE, note["pointer"])
|
||||
assert original == note["text"]
|
||||
exported = next(n for n in document()["source_notes"] if str(n["node_id"]) == note["node_id"])
|
||||
assert exported["content"] == [original]
|
||||
assert (
|
||||
hashlib.sha256(exported["content"][0].encode()).digest()
|
||||
== hashlib.sha256(original.encode()).digest()
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mutation", ["value", "proxy", "boundary", "note", "unknown_mode"])
|
||||
def test_original_graph_mutations_do_not_inherit_trust(mutation):
|
||||
source = copy.deepcopy(SOURCE)
|
||||
if mutation == "value":
|
||||
next(n for n in source["nodes"] if n["id"] == 580)["widgets_values"][0] += 1
|
||||
elif mutation == "proxy":
|
||||
host = next(n for n in source["nodes"] if n["id"] == 606)
|
||||
host["properties"]["proxyWidgets"] = [["589", "forged"]]
|
||||
elif mutation == "boundary":
|
||||
source["definitions"]["subgraphs"][0]["outputs"][0]["linkIds"].append(99999)
|
||||
elif mutation == "note":
|
||||
next(n for n in source["nodes"] if n["id"] == 574)["widgets_values"][0] += "\n"
|
||||
else:
|
||||
next(n for n in source["nodes"] if n["id"] == 292)["mode"] = 0
|
||||
assert not document(source)["fixed_version"]["matched"]
|
||||
assert not document(source)["status"]["exec_verified"]
|
||||
|
||||
|
||||
def test_rehashed_editorial_cannot_replace_code_owned_pin():
|
||||
review = copy.deepcopy(REVIEW)
|
||||
review["fixed_version_document"]["user_overview"] = "forged"
|
||||
review["fixed_version_document"]["canonical_sha256"] = hashlib.sha256(
|
||||
canonical(SOURCE)
|
||||
).hexdigest()
|
||||
assert not document(review=review)["fixed_version"]["matched"]
|
||||
|
||||
|
||||
def test_exact_build_source_audit_and_closed_qualification():
|
||||
assert (
|
||||
hashlib.sha256(RAW).hexdigest()
|
||||
== "22b7853e22629822dd354b0b768e2961a53b4c2f480cfaceeaea9dc51c0f0d0b"
|
||||
)
|
||||
sys.path.insert(0, str(OUT))
|
||||
try:
|
||||
build = runpy.run_path(str(OUT / "build_definition.py"))["build"]
|
||||
assert canonical(build()) == canonical(BLOCK)
|
||||
runpy.run_path(str(OUT / "verify_sources.py"))["main"]()
|
||||
finally:
|
||||
sys.path.remove(str(OUT))
|
||||
assert DEFINITIONS[PATH] == hashlib.sha256(canonical(BLOCK)).hexdigest()
|
||||
doc = document()
|
||||
assert doc["fixed_version"]["matched"]
|
||||
assert not doc["status"]["doc_done"] and not doc["status"]["exec_verified"]
|
||||
assert doc["dependencies"]["check_state"] == "unchecked"
|
||||
|
||||
|
||||
def test_missing_proxy_and_host_caches_do_not_inherit_internal_values():
|
||||
hosts = {b["host_node_id"]: b for b in BLOCK["boundaries"]}
|
||||
assert set(hosts) == {"261", "291", "477", "606"}
|
||||
assert all(
|
||||
not b["proxy_mappings"] and "proxyWidgets" not in b["host"]["properties"]
|
||||
for b in hosts.values()
|
||||
)
|
||||
assert "widgets_values" not in hosts["606"]["host"]
|
||||
assert hosts["261"]["host"]["widgets_values"][13] == 807087399737133
|
||||
assert (
|
||||
next(f for f in BLOCK["fields"] if f["node_id"] == "261:19" and f["field"] == "noise_seed")[
|
||||
"value"
|
||||
]
|
||||
== 2
|
||||
)
|
||||
|
||||
|
||||
def test_vhs_exact_commit_gap_and_real_wan_classes_are_independent():
|
||||
gaps = {
|
||||
n["node_id"] for n in BLOCK["node_bindings"] if n["source_id"].startswith("unresolved-")
|
||||
}
|
||||
assert gaps == {"585", "586"}
|
||||
assert all(
|
||||
n["implementation_verified"]
|
||||
for n in BLOCK["node_bindings"]
|
||||
if n["class_type"] in ["WanAnimate2ToVideo", "WanAnimate2Cache", "ContextWindowsManual"]
|
||||
)
|
||||
nodes = {n["id"]: n for n in SOURCE["nodes"]}
|
||||
assert nodes[586]["widgets_values"] == {}
|
||||
assert nodes[477]["widgets_values"][3].endswith("\n")
|
||||
edges = {e[0]: e for e in SOURCE["links"]}
|
||||
assert edges[937][1:5] == [606, 0, 477, 2]
|
||||
assert edges[938][1:5] == [606, 1, 477, 3]
|
||||
assert edges[945][1:5] == [606, 2, 608, 0]
|
||||
Reference in New Issue
Block a user