"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"] == "77b665bf6bcd11195f424d42d88f5142b43b0c608af776eef5744aca896f4b56" assert len(inv["fields"]) == 52 and len(inv["notes"]) == 5 assert len(inv["scopes"]) == 1 scope = inv["scopes"][0] assert (scope["nodes"], scope["edges"], scope["named_nodes"]) == (32, 34, 25) assert scope["modes"] == [0] * 32 assert {e["node"] for e in inv["empty"]} == {126, 122, 176, 179, 172, 125, 188, 201} assert all( e["state"] == ("empty_list" if e["node"] == 188 else "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"]) if "named_value" in f: assert canonical(f["value"]) == canonical(f["named_value"]) else: assert ( f["node_id"] == "171" and f["field"] == "audioUI" and f["named_state"] == "missing" and "named_pointer" not in f ) assert sum("named_pointer" in f for f in block["fields"]) == 51 from build_definition import PATHS, REPO g = json.loads((REPO / PATHS[0]).read_bytes()) ns = {n["id"]: n for n in g["nodes"]} assert g["extra"]["frontendVersion"] == "1.23.0" 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 edges = {e[0]: e[1:5] for e in g["links"]} expected = { 251: [119, 0, 122, 1], 253: [129, 0, 125, 0], 254: [126, 0, 125, 1], 255: [123, 0, 125, 2], 256: [124, 0, 125, 3], 261: [132, 0, 131, 0], 270: [136, 0, 126, 1], 272: [128, 0, 136, 0], 273: [119, 0, 136, 1], 274: [120, 0, 136, 2], 275: [131, 1, 136, 12], 276: [115, 0, 136, 10], 277: [115, 1, 136, 11], 278: [137, 0, 136, 3], 279: [138, 0, 136, 9], 280: [125, 0, 122, 0], 285: [122, 0, 142, 0], 335: [136, 1, 172, 0], 337: [120, 0, 172, 2], 338: [172, 0, 125, 4], 339: [172, 1, 142, 1], 360: [179, 0, 132, 0], 393: [174, 0, 196, 0], 394: [196, 0, 197, 0], 395: [197, 0, 176, 0], 396: [198, 0, 126, 0], 397: [198, 0, 124, 0], 398: [176, 0, 198, 0], 399: [131, 1, 198, 5], 400: [171, 0, 199, 0], 401: [199, 0, 179, 0], 402: [199, 0, 188, 0], 403: [199, 0, 172, 1], 404: [199, 0, 136, 7], } assert edges == expected assert ns[171]["widgets_values"] == ["满天星辰不及你.WAV", None, None] assert ns[171]["widgets_values_named"] == dict(audio="满天星辰不及你.WAV", upload=None) assert "audioUI" not in ns[171]["widgets_values_named"] assert ns[188]["widgets_values"] == [] and ns[188]["widgets_values_named"] == {} assert ns[188]["outputs"][0]["name"] == "audio" and "links" not in ns[188]["outputs"][0] assert ns[125]["outputs"][0]["links"] == [280] and ns[125]["outputs"][1]["links"] == [] assert ns[142]["outputs"][0]["links"] == [] assert "links" not in ns[137]["outputs"][1] assert "link" not in ns[198]["inputs"][1] for i in ns[136]["inputs"]: if i["name"] in [ "ref_images.ref_image_1", "ref_videos.ref_video_0", "ref_video_audios.ref_video_audio_0", "ref_audios.ref_audio_1", "ref_audios.ref_audio_2", ]: assert "link" not in i import collections types = collections.Counter( f["json_type"] for f in inv["fields"] if isinstance(ns[f["node"]]["widgets_values"], list) ) assert types == dict(str=22, int=14, float=2, bool=1, NoneType=2) h = next(f for f in block["fields"] if f["field"] == "videopreview") assert h["json_type"] == "dict" and h["pointer"].endswith("/widgets_values/videopreview") assert h["value"]["params"]["score"] == 48 and type(h["value"]["params"]["score"]) is int assert ns[142]["widgets_values"]["save_metadata"] is False assert ( hashlib.sha256(json.dumps(h["value"], ensure_ascii=False, indent=2).encode()).hexdigest() == "891a3957530037e4f24fb6f5d2cf5f48c040fdd833c8b3090bc95a5b1f49cfac" ) text_checks = [ (117, 1670, 38, True, "3712abf649cd3bdd6b3aeaaa07a5fbeaff7e55d756abf0bd3fcc6b1311c09ad8"), (116, 2473, 26, False, "c5ae05e6eff86a704ca371deb45e1bf33cccb35fb37c75008b2416225fb87198"), (140, 452, 16, True, "e72ca08679fd91e2b0185be81dfd558a2b59613540df74d4fa3e5ea6cdb8e938"), (173, 268, 6, False, "21a1771e8ae39767991176addf4f84fdd8f702de9088d27c00b18f07456c16b0"), (202, 46, 0, False, "f96cf01295d074aee22ff2ed358cf22a552b99ea6922f0161810c320bb598c00"), (138, 2935, 12, False, "1d05a073db933eba5a0c1cc685351213b30e01404a4c68ead026a4e30ad5e93c"), ] for nid, length, lf, tail, sha in text_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"]) == 24 bind = {b["node_id"]: b for b in block["node_bindings"]} assert bind["179"]["source_id"] == "unresolved-soundflow" assert bind["172"]["source_version"] == "local" and bind["172"]["source_id"] == "unknown" assert bind["201"]["source_id"] == "unknown" assert bind["188"]["source_id"] == "core0300" and bind["171"]["source_id"] == "core070" assert all(bind[str(i)]["source_id"] == "core0342" for i in [196, 197, 199]) assert all(bind[str(i)]["source_id"] == "kjavatar" for i in [176, 198]) for name in ["soundflow-repo", "soundflow-exact-commit"]: req = json.loads((REF / (name + "-request.json")).read_bytes()) assert ( req["status"] == 404 and hashlib.sha256((REF / (name + "-response.txt")).read_bytes()).hexdigest() == req["sha256"] ) result = dict( sources=checks, positions=52, paired_positions=51, missing_named_positions=1, list_positions=41, list_types=types, dict_scalars=10, complete_history_objects=1, notes=5, edges=34, accurate_nodes=24, unknown_identity_nodes=[bind["172"], bind["201"]], unresolved_nodes=[bind["179"]], 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( "PASS52 source positions/51 named/1 missing named/5Notes/34edges;" "24 exact/2 unknown/1 unresolved" ) if __name__ == "__main__": main()