"Verify exact text, Git/package provenance and source graph without upstream imports." import ast import collections import hashlib import json from build_definition import OUT, REF, 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"] if e["id"] == "litegraph": root = REF / e["identity_root"] assert ( json.loads((root / "litegraph__package__package.json").read_bytes())["version"] == "0.15.15" ) front = next( x for x in rows if x["id"] == "frontend" and x["file"] == "package-lock.json" ) lock = json.loads((REF / front["local_file"]).read_bytes()) assert ( lock["packages"]["node_modules/@comfyorg/litegraph"]["integrity"] == "sha512-" + e["artifact_sha512_base64"] ) proof = ( "Pinned frontend1.23.0 lock, exact0.15." "15 member SHA; whole artifact digest r" "eused, Git unknown" ) elif "package_record" in e: package = json.loads((REF / e["package_record"]).read_bytes()) reg = json.loads((REF / e["registry_record"]).read_bytes()) member = next(x for x in package["members"] if x["path"] == e["file"]) assert member["saved"] and member["sha256"] == e["sha256"] assert reg["version"] == e["tag"] == "1.0.0" assert package["sha256"] == e["artifact_sha256"] proof = ( "复用已审准确发布成员SHA/registry/历史整包摘要记录;本轮未获取整包,不证明Git绑定" ) elif e["id"] == "llama-unavailable": proof = "准确20571提交不可得的有界调查原记录,仅缺口,不作为schema实现" else: 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") proof = ( "Rehashed commit/tag/selected blo" "b; complete tree listing, not fu" "ll tree-object rehash" ) if not e["license_file"].startswith("未知"): 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=proof)) from build_definition import PATHS, REPO assert inv["sha256"] == "c8a442bd8cae8dcd75a6a01847ca99b75dcc37ef8ff0a855c82213ed25e943e0" assert len(inv["fields"]) == 118 and len(inv["notes"]) == 1 sc = inv["scopes"][0] assert (sc["nodes"], sc["edges"], sc["named_nodes"]) == (85, 87, 68) assert sc["modes"].count(0) == 84 and sc["modes"].count(4) == 1 assert {x["node"] for x in inv["empty"]} == { 51, 11, 127, 104, 4, 20, 50, 159, 160, 162, 161, 6, 53, 60, 64, 55, 165, } assert all(x["state"] == "missing" for x in inv["empty"]) assert collections.Counter(x["json_type"] for x in inv["fields"]) == dict( str=85, int=26, bool=4, float=3 ) for f, x in zip(block["fields"], inv["fields"], strict=True): assert f["pointer"] == x["pointer"] and f["json_type"] == x["json_type"] assert canonical(f["value"]) == canonical(x["value"]) == canonical(f["named_value"]) g = json.loads((REPO / PATHS[0]).read_bytes()) ns = {n["id"]: n for n in g["nodes"]} assert not g.get("definitions", {}).get("subgraphs") assert g["extra"]["frontendVersion"] == "1.23.0" assert {n["id"] for n in g["nodes"] if n["mode"] == 4} == {64} for eid, src, si, dst, di, typ in g["links"]: assert eid in ns[src]["outputs"][si]["links"] and ns[dst]["inputs"][di]["link"] == eid expected = json.loads((OUT / "expected-edges.json").read_bytes()) assert g["links"] == expected assert all( "widgets_values" not in ns[i] and "widgets_values_named" not in ns[i] for i in {51, 11, 127, 104, 4, 20, 50, 159, 160, 162, 161, 6, 53, 60, 64, 55, 165} ) assert all(i["link"] is None for i in ns[64]["inputs"]) assert ns[64]["outputs"][0]["links"] == [] and ns[62]["outputs"][1]["links"] == [] assert next(i for i in ns[16]["inputs"] if i["name"] == "audio")["link"] is None assert all( next(i for i in ns[102]["inputs"] if i["name"] == name)["link"] is None for name in ["first_frame", "last_frame"] ) assert ( ns[102]["inputs"][7]["name"] == "ref_images.ref_image_0" and ns[102]["inputs"][7]["link"] == 325 ) assert ( ns[59]["widgets_values"][2] == 0.20000000000000004 and type(ns[48]["widgets_values"][2]) is int ) assert ( ns[14]["type"] == "LoraLoaderBypassModelOnly" and type(ns[14]["widgets_values"][1]) is float ) raw = ns[103]["widgets_values_named"]["track_data"] state = json.loads(raw) assert (len(raw), raw.count("\r"), raw.count("\n"), raw.count("\\n"), raw.endswith("\n")) == ( 4841, 0, 0, 138, False, ) assert ( hashlib.sha256(raw.encode()).hexdigest() == "074fc3189ed9a536726ef6241ef86cf97cebe2563e4e45fcf9179a402917d296" ) assert state["muted"] is False and type(state["volume_db"]) is int and state["volume_db"] == 0 assert ( state["total_length"] == 648 and state["frame_rate"] == 24 and state["task_markers"] == [] and state["task_overview"] is False ) assert [(t["type"], len(t["segments"])) for t in state["tracks"]] == [("task", 2), ("video", 0)] strings = [] credentials = [] def walk(o, p=""): if isinstance(o, dict): for k, v in o.items(): if ( any( x in k.lower() for x in ["api_key", "apikey", "auth", "access_token", "password", "secret"] ) and v ): credentials.append(p + "/" + k) walk(v, p + "/" + k) elif isinstance(o, list): for i, v in enumerate(o): walk(v, p + "/" + str(i)) elif isinstance(o, str): strings.append( dict(pointer=p, characters=len(o), sha256=hashlib.sha256(o.encode()).hexdigest()) ) walk(state) assert not credentials note = ns[147]["widgets_values"][0] assert note == "截取最后一帧" and len(note) == 6 and not note.endswith("\n") assert len(block["node_bindings"]) == 84 assert sum(len(b["candidates"]) == 1 for b in block["node_bindings"]) == 36 assert sum(b["source_id"] == "unknown" for b in block["node_bindings"]) == 48 def source(key, file): return ( REF / next(e["local_file"] for e in rows if e["id"] == key and e["file"] == file) ).read_text() def cl(key, file, name): return next( c for c in ast.parse(source(key, file)).body if isinstance(c, ast.ClassDef) and c.name == name ) c = cl("mediaeditor", "nodes/basic.py", "MultiTrackEditor") m = next(m for m in c.body if isinstance(m, ast.FunctionDef) and m.name == "execute") assert any( isinstance(n, ast.Call) and isinstance(n.func, ast.Name) and n.func.id == "build_multitrack_data_from_prompt_override" for n in ast.walk(m) ) assert any( isinstance(n, ast.Name) and n.id == "prompt_override" and isinstance(n.ctx, ast.Load) for n in ast.walk(m) ) bypass = cl("core0300", "comfy_extras/nodes_lora_debug.py", "LoraLoaderBypassModelOnly") assert ast.unparse(bypass.bases[0]) == "LoraLoaderBypass" assert "load_bypass_lora_for_models" in source("core0300", "comfy_extras/nodes_lora_debug.py") for key, file, name in [ ("core0300", "comfy_extras/nodes_custom_sampler.py", "SamplerCustomAdvanced"), ("core0320", "nodes.py", "VAEEncodeTiled"), ("core0320", "nodes.py", "VAEDecodeTiled"), ("easy", "py/nodes/logic.py", "forLoopStart"), ("easy", "py/nodes/logic.py", "forLoopEnd"), ("easy", "py/nodes/logic.py", "indexAnything"), ("easy", "py/nodes/logic.py", "batchAnything"), ("kjmemory", "nodes/ltxv_nodes.py", "MiniMaxH3MemoryEfficientSageAttentionPatch"), ("essentials", "misc.py", "SimpleMathDual"), ("t8", "nodes.py", "MiniMaxH3AudioConditioningT8"), ]: assert cl(key, file, name) assert "_cuda_archs is None" in source( "kjmemory", "nodes/ltxv_nodes.py" ) and "_ck is None" in source("kjmemory", "nodes/ltxv_nodes.py") assert "latent.unbind()[-1]" in source("core0300", "comfy_extras/nodes_audio.py") assert "source_video.save_to" in source("mediaeditor", "nodes/video.py") result = dict( source_rows=len(rows), checks=checks, counts=block["counts"], bindings=block["node_bindings"], track=dict( characters=len(raw), sha256=hashlib.sha256(raw.encode()).hexdigest(), state=state, nested_strings=strings, credentials=credentials, ), note=dict(text=note, sha256=hashlib.sha256(note.encode()).hexdigest()), all_physical_edges=expected, editor_prompt_override_used=True, upstream_executed=False, ) (OUT / "source-check.json").write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n") print( "PASS source rows", len(rows), "118 fields/1 note,85 nodes/87 edges,36 accurate/48 unknown; no upstream execution", ) if __name__ == "__main__": main()