"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"] == "soundflow": proof = "本轮规范身份与准确提交API请求原记录,未取得类,不作为接口实现" elif "member_crc32" in e: import zlib members = json.loads((REF / "vhspkg-members.json").read_bytes()) member = next(m for m in members if m["name"] == e["file"]) assert e["member_crc32"] == member["crc"] == zlib.crc32(raw) assert member["size"] == len(raw) and e["tag"] == "1.7.9" reg = json.loads((REF / "vhs-version-registry-response.json").read_bytes()) assert reg["version"] == e["tag"] and reg["downloadUrl"] == e["url"] assert e["package_sha256"] == "unknown-not-downloaded-whole-archive" proof = "准确1.7.9发布身份/Range必要成员SHA与CRC;整包SHA和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"] == "903e32248fc0c53df36c5841f4f4ccdb5fb8190a39c6c9015d3e55a451aaf7eb" assert len(inv["fields"]) == 94 and len(inv["notes"]) == 3 sc = inv["scopes"][0] assert (sc["nodes"], sc["edges"], sc["named_nodes"]) == (54, 52, 41) assert sc["modes"] == [0] * 54 assert collections.Counter(f["json_type"] for f in inv["fields"]) == dict( str=49, int=31, bool=8, float=4, NoneType=1, dict=1 ) assert len(inv["empty"]) == 15 and sum(x["state"] == "missing" for x in inv["empty"]) == 13 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.51.10" ) 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[34]["widgets_values"] == ["满天星辰不及你.WAV", None] and ns[34][ "widgets_values_named" ] == dict(audio="满天星辰不及你.WAV", upload=None) assert inp(78, "latent_image")["link"] == 135 and inp(78, "model_hires")["link"] is None assert inp(68, "duration")["link"] == 110 and inp(68, "prompt")["link"] == 184 assert inp(65, "audio")["link"] == 186 and inp(65, "images")["link"] == 82 assert [o["links"] for o in ns[63]["outputs"]] == [[80], None] assert [o["links"] for o in ns[71]["outputs"]] == [[], [146, 171], []] assert inp(71, "values.b")["link"] is None assert ns[78]["widgets_values"][:4] == [999, "fixed", 1, 4] assert ns[68]["widgets_values"][7:9] == [1100, "fixed"] hist = ns[65]["widgets_values"] assert len(hist) == 11 and isinstance(hist["videopreview"], dict) assert hist == ns[65]["widgets_values_named"] and hist["crf"] == 12 notes = [] expected = { 105: (68, 2, "a2644e8c88b9ed27142dbf6476e2b9dea7dbe104026d23c51e8fe8b6351ff819"), 109: (35, 0, "1c11f32699316d80cae9c215e96e69bc474e7d52b72b4597c0f16ab60a67725f"), 110: (325, 10, "6f8bb9786e44748d969c27aef1e37f53c47016f724bb33daa788a94c2a47143b"), } for nid, (chars, 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, 0, lf, digest) assert not raw.endswith("\n") and raw.count("\\n") == 0 notes.append( dict( node=str(nid), characters=chars, CR=0, LF=lf, sha256=digest, text=raw, tail_LF=False ) ) text = ns[103]["widgets_values"][0] assert len(text) == 40 texts = [ dict( node="103", field="value", characters=40, sha256=hashlib.sha256(text.encode()).hexdigest(), text=text, ) ] 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"]) == 51 and sum(bool(x["candidates"]) for x in block["node_bindings"]) == 31 ) assert [ x["node_id"] for x in block["node_bindings"] if x["source_id"].startswith("unresolved-") ] == ["72"] assert sum(x["source_id"] == "unknown" for x in block["node_bindings"]) == 19 assert cl("core0350", "comfy_extras/nodes_model_advanced.py", "ModelAttentionBackend") assert cl("core0350", "comfy_extras/nodes_minimax_h3.py", "MiniMaxH3ReferenceToVideo") assert cl("qwen", "node.py", "QwenH3Prompt") and 'node_id="QwenH3PromptLocal"' in source( "qwen", "node.py" ) assert "return [QwenH3Prompt]" in source("qwen", "node.py") and "WEB_DIRECTORY" not in source( "qwen", "__init__.py" ) assert "MIT License" in source("qwen", "LICENSE") assert "GNU GENERAL PUBLIC LICENSE" in source( "kj", "LICENSE" ) and "GNU GENERAL PUBLIC LICENSE" in source("vhspkg", "LICENSE") assert "noise_mask is not compatible with highres_tiling" in source("selflift", "nodes.py") assert "sigmas.numel() < 2" in source("selflift", "nodes.py") assert "ComfyNumberConvert" in source("core0340", "comfy_extras/nodes_number_convert.py") assert json.loads(source("frontend", "package.json"))["version"] == "1.51.10" assert "Permission is hereby granted" in source("frontend", "src/lib/litegraph/LICENSE") assert "@comfyorg/litegraph" not in source("frontend", "pnpm-lock.yaml") ranges = json.loads((REF / "vhspkg-range-proof.json").read_bytes()) assert ranges["ranges"] and all( r["end"] - r["start"] + 1 < ranges["size"] for r in ranges["ranges"] ) for name in ["soundflow-repo", "soundflow-exact-commit"]: assert json.loads((REF / (name + "-request.json")).read_bytes())["status"] == 404 mask_field = next(f for f in block["fields"] if f["node_id"] == "40" and f["field"] == "value") time_field = next( f for f in block["fields"] if f["node_id"] == "85" and f["field"] == "start_index" ) assert mask_field["json_type"] == "int" and "布尔" not in mask_field["label"] assert "秒" in time_field["unit"] and "行" not in time_field["label"] result = dict( source_rows=len(rows), checks=checks, counts=block["counts"], bindings=block["node_bindings"], notes=notes, texts=texts, all_physical_edges=g["links"], credentials=credentials, accurate_classes=31, unresolved_declared=1, unknown=19, vhs_exact_release="1.7.9", whole_archive_acquired=False, upstream_executed=False, ) (OUT / "source-check.json").write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n") print( "PASS sources", len(rows), "94 entries/3 notes;31 accurate/1 unresolved/19 unknown; no upstream execution", ) if __name__ == "__main__": main()