"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"] == "fae96106a128342a6903bd32680463d1be98c0d5ad738d2fff40fc0f52a35389" assert len(inv["fields"]) == 60 and len(inv["notes"]) == 1 assert ( len(inv["scopes"]) == 1 and inv["scopes"][0]["nodes"] == 23 and inv["scopes"][0]["edges"] == 30 ) assert inv["scopes"][0]["named_nodes"] == 19 and set(inv["scopes"][0]["modes"]) == {0, 4} assert {x["node"] for x in inv["empty"]} == {8, 11, 17, 10} and all( x["state"] == "missing" for x in inv["empty"] ) 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"]) from build_definition import PATHS, REPO g = json.loads((REPO / PATHS[0]).read_bytes()) ns = {n["id"]: n for n in g["nodes"]} edges = {e[0]: e[1:5] for e in g["links"]} expected = { 3: [3, 0, 6, 0], 4: [4, 0, 6, 1], 5: [5, 0, 6, 2], 6: [6, 1, 7, 1], 7: [7, 0, 8, 0], 8: [6, 0, 8, 1], 9: [9, 0, 10, 0], 10: [8, 0, 10, 1], 11: [7, 1, 10, 2], 12: [7, 2, 10, 3], 13: [6, 1, 10, 4], 14: [10, 0, 11, 0], 15: [4, 0, 11, 1], 16: [5, 0, 11, 2], 17: [11, 0, 12, 0], 18: [11, 1, 12, 1], 20: [14, 0, 15, 0], 21: [16, 0, 6, 16], 22: [16, 1, 6, 17], 23: [15, 1, 6, 18], 26: [1, 0, 17, 0], 27: [17, 0, 2, 0], 53: [36, 0, 6, 15], 56: [37, 0, 6, 7], 57: [2, 0, 38, 0], 58: [38, 0, 7, 0], 59: [15, 1, 38, 5], 60: [39, 0, 6, 8], 61: [40, 0, 6, 9], 62: [41, 0, 6, 10], } for k, v in expected.items(): assert edges[k] == v, (k, edges[k], v) assert ns[10]["outputs"][1]["links"] == [] and "links" not in ns[12]["outputs"][0] assert [n["id"] for n in g["nodes"] if n["mode"] == 4] == [41, 40] assert sum(n["mode"] == 0 for n in g["nodes"]) == 21 for nid, edge, slot in [(37, 56, 7), (39, 60, 8), (40, 61, 9), (41, 62, 10)]: assert ns[nid]["widgets_values"] == ["1.png", "image"] assert "links" not in ns[nid]["outputs"][1] assert ns[6]["inputs"][slot]["link"] == edge assert ns[nid]["properties"]["ver"] == "0.31.1" assert all( ("link" not in i) if nid == 37 else ("link" in i and i["link"] is None) for i in ns[nid]["inputs"] ) assert ns[6]["inputs"][11]["link"] is None assert all("link" not in ns[6]["inputs"][i] for i in [3, 4, 5, 6, 12, 13, 14]) assert not any( i["name"] in ["semantic_bridge", "allow_above_reference_area"] for i in ns[6]["inputs"] ) assert not any(i["name"] == "audio_vae" for i in ns[38]["inputs"]) assert ns[38]["widgets_values"] == [0, 80, True, 81, 24, "taeh3.safetensors", ""] assert ns[38]["inputs"][1]["link"] is None assert all(o["links"] == [] for o in ns[6]["outputs"][2:]) assert isinstance(ns[12]["widgets_values"], dict) and len(ns[12]["widgets_values"]) == 11 hs = next(f for f in block["fields"] if f["field"] == "videopreview") assert hs["json_type"] == "dict" and hs["pointer"].endswith("/widgets_values/videopreview") assert hs["value"] == ns[12]["widgets_values_named"]["videopreview"] assert ( hashlib.sha256(json.dumps(hs["value"], ensure_ascii=False, indent=2).encode()).hexdigest() == "d2e80509e3d7312df591a7c6d9f1afbca302fc94e4f077dcb860525cd868ac97" ) assert { b["node_id"] for b in block["node_bindings"] if b["source_id"].startswith("unresolved-") } == {"7"} assert sum(bool(b["candidates"]) for b in block["node_bindings"]) == 21 assert ns[6]["widgets_values_named"]["task_type"] == "Ref2VA — 参考生音视频" assert any("resolve_task_type仅lower" in x for x in block["steps"]) for nid, length, lf, tail, sha in [ (35, 452, 16, True, "e72ca08679fd91e2b0185be81dfd558a2b59613540df74d4fa3e5ea6cdb8e938"), (36, 174, 0, False, "8810e5e4871e482bfdbcf734112ef49e7ae18f7543f863dc048e52df4bbe5783"), ]: text = ns[nid]["widgets_values"][0] assert ( len(text) == length and text.count("\n") == lf and text.endswith("\n") == tail and text.count("\\n") == 0 ) assert hashlib.sha256(text.encode()).hexdigest() == sha result = dict( sources=checks, positions=60, list_scalars=49, dict_scalars=10, complete_history_objects=1, notes=1, edges=30, accurate_nodes=21, unresolved_nodes=[ b for b in block["node_bindings"] if b["source_id"].startswith("unresolved-") ], upstream_executed=False, ) (OUT / "source-check.json").write_text(json.dumps(result, 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 60 dual-save entries (49 list scalars/10 dict scalars/1 history object)," + "1 Note,30 edges;21 exact/1 unresolved" ) if __name__ == "__main__": main()