"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"] == "bdc93d36fb8a4728dfa8031d1f00782d68e8e6aedd718b166f57e54216f2882f" assert len(inv["fields"]) == 135 and len(inv["notes"]) == 3 sc = inv["scopes"][0] assert (sc["nodes"], sc["edges"], sc["named_nodes"]) == (75, 80, 66) assert collections.Counter(sc["modes"]) == {0: 74, 4: 1} assert collections.Counter(f["json_type"] for f in inv["fields"]) == dict( str=84, int=36, bool=8, float=5, NoneType=1, dict=1 ) assert len(inv["empty"]) == 12 and sum(x["state"] == "missing" for x in inv["empty"]) == 9 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") and g["extra"]["frontendVersion"] == "1.47.11" ) assert g["links"] == json.loads((OUT / "expected-edges.json").read_bytes()) 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 def inp(n, key): return next(i for i in ns[n]["inputs"] if i["name"] == key) assert ( ns[257]["mode"] == 4 and inp(266, "audio")["link"] == 555 and inp(266, "vocals")["link"] is None ) assert ns[232]["widgets_values"] == ["满天星辰不及你.WAV", None] and ns[232][ "widgets_values_named" ] == dict(audio="满天星辰不及你.WAV", upload=None) assert inp(261, "latent_image")["link"] == 511 and inp(261, "model_hires")["link"] is None assert inp(323, "duration")["link"] == 695 and inp(323, "prompt")["link"] == 694 assert inp(273, "audio")["link"] == 644 assert [o["links"] for o in ns[266]["outputs"]][-2:] == [[], []] assert ns[266]["properties"]["h3lv_project"] == ns[266]["widgets_values_named"]["project_id"] hist = ns[273]["widgets_values"] assert len(hist) == 11 and isinstance(hist["videopreview"], dict) assert hist == ns[273]["widgets_values_named"] and hist["videopreview"]["hidden"] is False notes = [] expected = { 252: (187, 2, 2, "a3dba7a1e338f5d7f876de8f659c948ecdf2c6378ffa2da5a40107792127365b"), 328: (280, 0, 9, "fe3b286a1fbb11f8dac656a6302142931d60f1351361ebde7fb956447c267caa"), 330: (18, 0, 0, "25e29ba39c99c47c0188a7f15cf903502dab47a48ab468e35ff2f5c36cfc666c"), } for nid, (chars, cr, lf, digest) in expected.items(): raw = ns[nid]["widgets_values"][0] assert ( len(raw), raw.count("\r"), raw.count("\n"), hashlib.sha256(raw.encode()).hexdigest(), ) == (chars, cr, lf, digest) assert not raw.endswith("\n") and raw.count("\\n") == 0 notes.append( dict( node=str(nid), characters=chars, CR=cr, LF=lf, sha256=digest, text=raw, tail_LF=False, ) ) credentials = [] def walk(o, p=""): if isinstance(o, dict): for k, v in o.items(): if ( any( t in k.lower() for t in [ "api_key", "apikey", "access_token", "password", "secret", "authorization", ] ) 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)) walk(g) assert not credentials 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 ) assert ( len(block["node_bindings"]) == 72 and sum(len(x["candidates"]) == 1 for x in block["node_bindings"]) == 26 ) assert [ x["node_id"] for x in block["node_bindings"] if x["source_id"].startswith("unresolved-") ] == ["242"] for file in ["__init__.py", "nodes/model_optimization_nodes.py", "nodes/minimax_nodes.py"]: assert not any( isinstance(c, ast.ClassDef) and c.name == "ModelAttentionBackend" for c in ast.parse(source("kjattention", file)).body ) assert '"H3LVUnified": Unified' in source("longvideo", "nodes.py") assert cl("longvideo", "nodes.py", "LoadSegment") and cl( "selflift", "nodes.py", "SelfLiftAvatarH3Sampler" ) assert "noise_mask is not compatible with highres_tiling" in source("selflift", "nodes.py") assert "tiling_mode" not in ast.unparse(cl("selflift", "nodes.py", "SelfLiftAvatarH3Sampler")) assert "local_files_only=False" in source("longvideo", "worker.py") assert "faster-whisper==1.2.1" in source("longvideo", "requirements.txt") assert "MiniMaxLowVRAMAttention" in source("kj", "__init__.py") and cl( "kj", "nodes/minimax_nodes.py", "MiniMaxChunkFeedForward" ) assert json.loads(source("frontend", "package.json"))["version"] == "1.47.11" assert "Permission is hereby granted" in source("frontend", "src/lib/litegraph/LICENSE") assert "@comfyorg/litegraph" not in source("frontend", "pnpm-lock.yaml") assert "GNU GENERAL PUBLIC LICENSE" in source("kj", "LICENSE") assert any("KJ GPLv3" in x for x in block["steps"]) assert not any("KJ MIT" in x for x in block["steps"]) result = dict( source_rows=len(rows), checks=checks, counts=block["counts"], bindings=block["node_bindings"], notes=notes, all_physical_edges=g["links"], credentials=credentials, accurate_classes=26, unresolved_declared=1, unknown=45, h3lv_accurate_output_count=5, source_h3lv_output_count=len(ns[266]["outputs"]), upstream_executed=False, ) (OUT / "source-check.json").write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n") print( "PASS sources", len(rows), "135 entries/3 notes;26 accurate/1 unresolved/45 unknown; no upstream execution", ) if __name__ == "__main__": main()