"Verify exact text, Git/package provenance and source graph without upstream imports." import hashlib import json import zlib 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实现" elif "member_crc32" in e: root = REF / e["identity_root"] m = json.loads((root / (e["id"] + "-registry.json")).read_bytes()) members = json.loads((root / (e["id"] + "-members.json")).read_bytes()) member = next(x for x in members if x["name"] == e["file"]) assert m["version"] == e["tag"] assert member["crc"] == e["member_crc32"] == zlib.crc32(raw) assert e["package_sha256"].startswith("unknown") proof = "准确发布成员SHA/CRC;Range选定文本,完整包SHA与Git绑定未知" 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)) assert inv["sha256"] == "ed4a30da03245f35ff9006ac64cd045c1b9c64eb8b585520dbbb418f6793fc78" assert len(inv["fields"]) == 52 and len(inv["notes"]) == 2 assert [(s["nodes"], s["edges"], s["named_nodes"]) for s in inv["scopes"]] == [ (5, 3, 5), (18, 34, 14), ] assert all(set(s["modes"]) == {0} for s in inv["scopes"]) assert [(n["node"], n["state"]) for n in inv["empty"]] == [ (23, "missing"), (10, "missing"), (14, "missing"), (16, "missing"), ] from build_definition import PATHS, REPO g = json.loads((REPO / PATHS[0]).read_bytes()) d = g["definitions"]["subgraphs"][0] ns = {n["id"]: n for n in g["nodes"]} ins = {n["id"]: n for n in d["nodes"]} def pointer(obj, p): for x in p.strip("/").split("/"): x = x.replace("~1", "/").replace("~0", "~") obj = obj[int(x)] if isinstance(obj, list) else obj[x] return obj for a, f in zip(inv["fields"], block["fields"], strict=True): assert (a["pointer"], a["json_type"], canonical(a["value"])) == ( f["pointer"], f["json_type"], canonical(f["value"]), ) assert ( canonical(pointer(g, f["pointer"])) == canonical(pointer(g, f["named_pointer"])) == canonical(f["value"]) == canonical(f["named_value"]) ) for graph in [g, d]: nodes = {n["id"]: n for n in graph["nodes"]} for edge in graph["links"]: eid, a, ao, z, zi = ( edge[:5] if isinstance(edge, list) else [ edge[k] for k in ["id", "origin_id", "origin_slot", "target_id", "target_slot"] ] ) assert eid in ( nodes[a]["outputs"][ao]["links"] if a >= 0 else graph["inputs"][ao]["linkIds"] ) assert ( nodes[z]["inputs"][zi]["link"] == eid if z >= 0 else eid in graph["outputs"][zi]["linkIds"] ) assert len(ns[105]["widgets_values"]) == 10 and len(ns[105]["inputs"]) == len(d["inputs"]) == 12 assert d["widgets"] == [] and "proxyWidgets" not in ns[105] and "proxyWidgets" not in d assert ns[105]["inputs"][0]["link"] is None and ns[105]["inputs"][1]["link"] is None assert g["links"] == [ [194, 105, 0, 92, 0, "VIDEO"], [273, 143, 0, 105, 3, "INT"], [274, 143, 1, 105, 4, "INT"], ] edges = { e["id"]: (e["origin_id"], e["origin_slot"], e["target_id"], e["target_slot"]) for e in d["links"] } expected = { 287: (6, 0, 148, 0), 288: (148, 0, 128, 0), 249: (128, 0, 127, 0), 285: (127, 0, 9, 0), 286: (127, 0, 16, 0), 258: (-10, 11, 128, 1), 188: (104, 1, 14, 4), 225: (14, 0, 10, 0), 226: (14, 0, 23, 0), 199: (107, 1, 104, 7), } assert all(edges[k] == v for k, v in expected.items()) assert ins[91]["widgets_values"] == [24, "auto", "sRGB", "none"] and ns[92][ "widgets_values" ] == ["video/MiniMax_H3", "auto", "auto", "auto"] assert ins[148]["widgets_values"] == [10, 3] and ins[128]["widgets_values"] == [ "comfy kitchen attention" ] assert ins[127]["widgets_values"] == [ "vsa", 10, 0.2, 1, "", 12288, 256, "exact_kv_and_rows", False, ] assert ins[107]["inputs"][1]["link"] is None and all( ins[107]["outputs"][i]["links"] is None for i in [0, 2] ) assert ins[111]["widgets_values"] == [2] and type(ins[111]["widgets_values"][0]) is int unknown = {"143", "105:127", "105:128", "105:148"} assert {b["node_id"] for b in block["node_bindings"] if b["source_id"] == "unknown"} == unknown assert ( sum( b["source_id"] == "core0330" and len(b["candidates"]) == 1 for b in block["node_bindings"] ) == 16 ) for n in [ns[143], ins[127], ins[128], ins[148]]: assert all(k not in n["properties"] for k in ["cnr_id", "aux_id", "ver"]) for f in block["fields"]: if f["node_id"] in unknown: assert "未知" in f["unit"] and "未知" in f["schema_default"] and "未知" in f["limits"] notes = {n["node"]: n for n in inv["notes"]} for nid, count, lf, tail, sha in [ (139, 1118, 12, False, "f3e44546bbe8923b78cd216a3dae437384be8ed0d98ecdc7401202f6b295dfd8"), (140, 1707, 39, True, "7ab83e03f68db988e13ee697013ea23121a5f8a3d3e267cc377e952691ce8552"), ]: n = notes[nid] assert (n["characters"], n["lf_count"], n["ends_with_lf"], n["literal_backslash_n"]) == ( count, lf, tail, 0, ) assert hashlib.sha256(n["text"].encode()).hexdigest() == sha for text, count, lf, sha in [ ( ns[105]["widgets_values"][0], 3397, 2, "308dee785014a6a2449fbf858a42fdbbace53d3898212a5ec0c0d087d533f01b", ), ( ins[104]["widgets_values"][0], 980, 12, "21953b89529474d17901875cb7f5d5120c406dfbd680c88065f9b672c2f326d9", ), ]: assert ( len(text) == count and text.count("\n") == lf and text.count("\\n") == 0 and not text.endswith("\n") ) assert hashlib.sha256(text.encode()).hexdigest() == sha (OUT / "source-check.json").write_text( json.dumps( dict( files=checks, positions=52, standard_notes=2, edges_including_boundary=37, accurate_implementation_nodes=16, unknown_nodes=sorted(unknown), upstream_executed=False, expression_evaluated=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("PASS52 paired fields,2 notes,37 edges;16 exact core nodes/4 identity gaps") if __name__ == "__main__": main()