"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"] == "fab48be409cf423aaed7be268c6655ae39ecd1733218413c51874c5ba2ad0bdf" assert len(inv["fields"]) == 208 and len(inv["notes"]) == 4 assert len(inv["scopes"]) == 1 scope = inv["scopes"][0] assert (scope["nodes"], scope["edges"], scope["named_nodes"]) == (94, 95, 79) assert scope["modes"].count(0) == 77 and scope["modes"].count(4) == 17 assert {e["node"] for e in inv["empty"]} == { 32, 214, 215, 216, 256, 10, 17, 20, 19, 12, 153, 271, 210, 212, 208, } assert all(e["state"] == "missing" for e 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"]} # Every physical edge has exact source/target slot linkage. No alias edges invented. for e in g["links"]: eid, src, si, dst, di, typ = e assert eid in ns[src]["outputs"][si]["links"] assert ns[dst]["inputs"][di]["link"] == eid assert all( not (e[1] in [155, 162, 157, 159, 257, 258] and e[3] in [172, 171, 168, 169, 207, 206]) for e in g["links"] ) edges = {e[0]: e[1:5] for e in g["links"]} expected = { 7: [7, 1, 8, 1], 8: [8, 0, 9, 0], 9: [8, 0, 10, 0], 10: [7, 0, 10, 1], 11: [11, 0, 12, 0], 13: [8, 1, 12, 2], 14: [9, 0, 12, 3], 15: [7, 1, 12, 4], 16: [12, 1, 13, 0], 23: [13, 0, 15, 0], 24: [14, 1, 15, 1], 25: [14, 0, 15, 2], 27: [15, 0, 16, 1], 28: [9, 1, 16, 2], 29: [16, 0, 17, 0], 30: [15, 1, 17, 1], 33: [16, 1, 19, 2], 34: [16, 2, 19, 3], 35: [15, 0, 19, 4], 36: [19, 0, 20, 0], 50: [11, 0, 19, 0], 51: [32, 0, 33, 0], 87: [46, 0, 50, 0], 213: [153, 0, 154, 0], 214: [154, 0, 155, 0], 233: [172, 0, 32, 0], 271: [207, 0, 226, 0], 272: [206, 0, 226, 1], 299: [20, 0, 257, 0], 300: [20, 1, 258, 0], 304: [33, 0, 8, 0], 305: [33, 0, 16, 0], 306: [264, 0, 13, 3], 308: [50, 0, 153, 0], 231: [167, 0, 7, 18], 229: [164, 0, 7, 19], 230: [164, 1, 7, 20], 227: [165, 1, 7, 21], 226: [171, 0, 14, 0], 232: [167, 0, 14, 18], 17: [13, 1, 14, 19], 18: [13, 2, 14, 20], 228: [165, 1, 14, 21], } for k, v in expected.items(): assert edges[k] == v assert ns[12]["outputs"][0]["links"] is None and ns[12]["outputs"][1]["links"] == [16] assert ns[19]["outputs"][0]["links"] == [36] and ns[19]["outputs"][1]["links"] is None assert ns[8]["outputs"][2]["links"] is None assert all(o["links"] is None for o in ns[16]["outputs"][3:]) assert ns[226]["outputs"][0]["links"] is None for nid in [7, 14]: ins = {i["name"]: i for i in ns[nid]["inputs"]} assert ins["semantic_bridge"]["link"] is None for key in [ "drive_audio", "final_audio", "first_frame", "last_frame", "ref_videos.ref_video_0", "ref_video_audios.ref_video_audio_0", "ref_video_audios.ref_video_audio_1", "ref_video_audios.ref_video_audio_2", *[f"ref_images.ref_image_{i}" for i in [6, 7, 8]], ]: assert ins[key]["link"] is None assert ns[nid]["widgets_values_named"]["allow_above_reference_area"] is True assert ns[nid]["widgets_values_named"]["task_type"] == "Ref2VA — 参考生音视频" for nid in [222, 223, 225]: assert ns[nid]["widgets_values"][1] is None assert ns[228]["mode"] == 0 types = [ f["json_type"] for f in inv["fields"] if not isinstance(ns[f["node"]]["widgets_values"], dict) ] import collections assert collections.Counter(types) == dict(int=46, str=127, bool=10, float=12, NoneType=3) 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"]["params"]["score"] == 9 and type(hs["value"]["params"]["score"]) is int assert "trim_to_audio" not in ns[226]["widgets_values"] assert ( hashlib.sha256(json.dumps(hs["value"], ensure_ascii=False, indent=2).encode()).hexdigest() == "fe34c71a9afa0693b38c3d7f83f4c467310a1988fad40620e964fe7ad8f4b2e9" ) note_checks = [ (166, 452, 16, True, "e72ca08679fd91e2b0185be81dfd558a2b59613540df74d4fa3e5ea6cdb8e938"), (265, 49, 3, False, "30c3766c6f75909500394f0f0a0771e60b1f10d878c683f219354ce3790b52f8"), (262, 163, 8, False, "ace0b6af8706cfce6a5cd4dbe5b5c6a092981aa72262ccedd4b171eecaf54c93"), (267, 59, 5, False, "fa1c493d78602daece8566b14c8d90a8c3777f9c597300e5d2a1e9bc1dc8c386"), (167, 724, 14, True, "7069ab7fd0c570b6c20630c480e4ba8076aa231fcb30fd16c5f59304986df73e"), (7, 122, 0, False, "ebb3adcbbc793a06a0871882cdc614a9abbf74031982dc0b5271a757dfd4ac60"), (14, 122, 0, False, "ebb3adcbbc793a06a0871882cdc614a9abbf74031982dc0b5271a757dfd4ac60"), ] for nid, length, lf, tail, sha in note_checks: text = ns[nid]["widgets_values"][0] assert ( len(text), text.count("\n"), text.endswith("\n"), hashlib.sha256(text.encode()).hexdigest(), ) == (length, lf, tail, sha) assert text.count("\\n") == 0 assert sum(bool(b["candidates"]) for b in block["node_bindings"]) == 49 assert not any(b["source_id"].startswith("unresolved-") for b in block["node_bindings"]) assert all( b["class_type"] in ["SetNode", "GetNode", "Fast Groups Bypasser (rgthree)", "Label (rgthree)"] for b in block["node_bindings"] if b["source_id"] == "unknown" ) result = dict( sources=checks, positions=208, list_positions=198, list_types=collections.Counter(types), dict_scalars=9, complete_history_objects=1, notes=4, edges=95, accurate_nodes=sum(bool(b["candidates"]) for b in block["node_bindings"]), unknown_nodes=[b for b in block["node_bindings"] if b["source_id"] == "unknown"], 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("PASS208 dual-save entries/4Notes/95edges; exact new T8 classes; no execution") if __name__ == "__main__": main()