"""Exact original, named forms, source identity and interfaces; no upstream execution.""" import ast import hashlib import json from build_definition import OUT, PATHS, REF, REPO, build, canonical from inventory import inventory def object_hash(kind, raw): return hashlib.sha1(kind.encode() + b" " + str(len(raw)).encode() + b"\0" + raw).hexdigest() def main(): block, inv = build(), inventory() rows = json.loads((REF / "sources.json").read_bytes())["sources"] checks = [] for e in rows: raw = (REF / e["local_file"]).read_bytes() assert hashlib.sha256(raw).hexdigest() == e["sha256"] root = REF / e["identity_root"] key = e["identity_key"] commit = (root / (key + "-commit.txt")).read_bytes() tree = json.loads((root / (key + "-tree.json")).read_bytes()) assert object_hash("commit", commit) == e["commit"] assert commit.decode().splitlines()[0] == "tree " + e["tree"] == "tree " + tree["sha"] assert not tree["truncated"] assert ( next(t["sha"] for t in tree["tree"] if t["path"] == e["file"]) == e["git_blob_sha1"] == object_hash("blob", raw) ) tag = json.loads((root / (key + "-tag.json")).read_bytes()) tag_raw = (root / (key + "-tag.txt")).read_bytes() assert tag["commit"] == e["commit"] if tag["object"] == e["commit"]: assert tag_raw == commit else: assert object_hash("tag", tag_raw) == tag["object"] assert tag_raw.decode().startswith("object " + e["commit"] + "\n") license_row = next( x for x in rows if x["id"] == e["id"] and (REF / x["local_file"]).resolve() == (REF / e["license_file"]).resolve() ) assert ( hashlib.sha256((REF / e["license_file"]).read_bytes()).hexdigest() == license_row["sha256"] ) checks.append( dict( id=e["id"], file=e["file"], sha256=e["sha256"], proof=( "rehashed commit/tag/se" "lected blob; complete " "tree listing, not tree" "-object rehash" ), reverified_at=e["reverified_at"], ) ) assert inv["sha256"] == "599bb58d48d68de929e7ec476f77e9f7c736c00235b68570416d214d3b4e391c" assert [(s["nodes"], s["edges"], s["named_nodes"]) for s in inv["scopes"]] == [ (14, 11, 14), (20, 40, 18), ] assert len(inv["fields"]) == 83 and len(block["node_bindings"]) == 31 assert [ (n["node"], n["characters"], n["lf_count"], n["literal_backslash_n"], n["ends_with_lf"]) for n in inv["notes"] ] == [(48, 1551, 43, 0, True), (50, 1965, 30, 0, True), (297, 25, 1, 0, False)] assert inv["extra"]["frontendVersion"] == "1.47.10" g = json.loads((REPO / PATHS[0]).read_bytes()) sg = g["definitions"]["subgraphs"][0] root = {n["id"]: n for n in g["nodes"]} inside = {n["id"]: n for n in sg["nodes"]} assert all(n["mode"] == 0 for n in list(root.values()) + list(inside.values())) assert [(z["node"], z["state"]) for z in inv["empty"]] == [ (82, "empty_list"), (8, "missing"), (13, "missing"), (20, "empty_list"), ] for a, f in zip(inv["fields"], block["fields"], strict=True): assert a["pointer"] == f["pointer"] and a["json_type"] == f["json_type"] assert canonical(a["value"]) == canonical(f["value"]) == canonical(f["named_value"]) assert f["named_pointer"].startswith("/") for scope, nodes in [("root", root), ("30", inside)]: for nid, n in nodes.items(): if "widgets_values_named" not in n: continue key = str(nid) if scope == "root" else scope + ":" + str(nid) used = { f["named_pointer"].rsplit("/", 1)[1].replace("~1", "/").replace("~0", "~") for f in block["fields"] if f["node_id"] == key } if n["type"] in ["Note", "MarkdownNote"]: used = {"text"} assert used == set(n["widgets_values_named"]), (key, used) assert len(root[30]["widgets_values"]) == len(root[30]["inputs"]) == len(sg["inputs"]) == 14 assert ( "proxyWidgets" not in root[30] and "proxyWidgets" not in root[30]["properties"] and sg["widgets"] == [] ) assert root[30]["widgets_values"][10] == "niannian" assert root[30]["widgets_values"][9] == 0.8500000000000001 assert len(root[30]["widgets_values"][0]) == len(inside[19]["widgets_values"][0]) == 452 assert root[30]["widgets_values"][0].startswith("Ultra low angle") assert len(root[55]["widgets_values"][0]) == 447 and len(root[59]["widgets_values"][0]) == 1178 assert ( len(inside[6]["widgets_values"][0]) == 479 and len(inside[18]["widgets_values"][0]) == 2131 ) assert root[56]["outputs"][0]["links"] == [] and root[56]["outputs"][1]["links"] == [94] assert root[58]["outputs"][1]["links"] == [] for eid, a, ao, z, zi, _ in g["links"]: assert eid in root[a]["outputs"][ao]["links"] and root[z]["inputs"][zi]["link"] == eid for e in sg["links"]: assert e["id"] in ( sg["inputs"][e["origin_slot"]]["linkIds"] if e["origin_id"] == -10 else inside[e["origin_id"]]["outputs"][e["origin_slot"]]["links"] ) if e["target_id"] == -20: assert e["id"] in sg["outputs"][e["target_slot"]]["linkIds"] else: assert inside[e["target_id"]]["inputs"][e["target_slot"]]["link"] == e["id"] assert root[61]["widgets_values"] == [False] and root[62]["widgets_values"] == [True] assert root[85]["widgets_values"] == [11, "fixed"] and inside[24]["widgets_values"] == [True] assert not any(n["type"] == "SaveImage" for n in list(root.values()) + list(inside.values())) assert "ver" not in root[78]["properties"] and "cnr_id" not in root[78]["properties"] def source(key, file): return ( REF / next(e["local_file"] for e in rows if e["id"] == key and e["file"] == file) ).read_bytes() assert ( json.loads((REF / "easy-registry.json").read_bytes())["repository"].rstrip("/") == "https://github.com/yolain/ComfyUI-Easy-Use" ) prompt = source("easy", "py/nodes/prompt.py").decode() logic = source("easy", "py/nodes/logic.py").decode() assert all( name in prompt for name in [ '"easy prompt": prompt', '"easy wildcards": wildcardsPrompt', '"easy stylesSelector": stylesPromptSelector', ] ) assert '"easy showAnything": showAnything' in logic assert 'node["widgets_values"] = [values]' in logic and "return io.NodeOutput(text)" in prompt assert "process(text, seed)" in prompt and 'ui={"value": [seed]}' in prompt assert 'io.Custom(io_type="EASY_PROMPT_STYLES").Input("select_styles"' in prompt assert "random.seed(seed)" in source("easy", "py/libs/wildcards.py").decode() extension = source("easy", "web_version/v2/assets/extensions-BJNTnPC8.js").decode() assert all( term in extension for term in [ "onExecuted", "onConfigure", "Select the LoRA to add to the text", "easy showAnything", ] ) seed = source("core0342", "comfy_extras/nodes_seed.py").decode() assert ( "return [SeedNode]" in seed and "control_after_generate=io.ControlAfterGenerate.fixed" in seed ) core = ast.parse(source("core0250", "nodes.py")) clip = next(n for n in core.body if isinstance(n, ast.ClassDef) and n.name == "CLIPLoader") enums = [ ast.literal_eval(n) for n in ast.walk(clip) if isinstance(n, ast.List) and all(isinstance(v, ast.Constant) and isinstance(v.value, str) for v in n.elts) ] assert all("krea2" not in vals for vals in enums) newer = ast.parse(source("core0342", "nodes.py")) save = next(n for n in newer.body if isinstance(n, ast.ClassDef) and n.name == "SaveImage") ret = next( n.value for n in save.body if isinstance(n, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "RETURN_TYPES" for t in n.targets) ) assert ast.literal_eval(ret) == ("IMAGE",) assert json.loads(source("frontend", "package.json"))["version"] == "1.47.10" assert b"workspace:" in source("frontend", "pnpm-lock.yaml") (OUT / "source-check.json").write_text( json.dumps( dict( files=checks, all_checks_pass=True, saved_fields=83, source_notes=3, root_saved=39, internal_saved=44, named_forms_independently_preserved=True, host_proxyWidgets_missing=True, core0250_clip_krea2_enum=False, core0342_preview_image_data=True, setnode_provider_version_unknown=True, upstream_executed=False, ), ensure_ascii=False, indent=2, ) + "\n" ) (OUT / "node-version-bindings.json").write_text( json.dumps(block["node_bindings"], ensure_ascii=False, indent=2) + "\n" ) print( "PASS exact Git/source declarations,83 dual forms,3 true-LF notes and physical boundaries" ) if __name__ == "__main__": main()