"Rehash exact sources and audit all saved values and physical endpoints; no repair." import hashlib import json from build_definition import OUT, REF, build, canonical from inventory import inventory def main(): block = build() 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": checks.append( dict( id=e["id"], file=e["file"], sha256=e["sha256"], proof="复用既有准确锁包成员;仅重算成员SHA,完整包摘要沿用、Git绑定未知", ) ) continue blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() assert blob == e["git_blob_sha1"] tree = json.loads((REF / (e["id"] + "-tree.json")).read_bytes()) assert not tree["truncated"] and tree["sha"] == e["tree"] assert next(t["sha"] for t in tree["tree"] if t["path"] == e["file"]) == blob commit = (REF / (e["id"] + "-commit.txt")).read_bytes() assert ( hashlib.sha1(b"commit " + str(len(commit)).encode() + b"\0" + commit).hexdigest() == e["commit"] ) assert commit.decode().splitlines()[0] == "tree " + e["tree"] tag = json.loads((REF / (e["id"] + "-tag.json")).read_bytes()) tag_raw = (REF / (e["id"] + "-tag.txt")).read_bytes() assert tag["commit"] == e["commit"] if tag["object"] == e["commit"]: assert tag_raw == commit else: assert ( hashlib.sha1(b"tag " + str(len(tag_raw)).encode() + b"\0" + tag_raw).hexdigest() == tag["object"] ) assert tag_raw.decode().startswith("object " + e["commit"] + "\n") if e["license_file"].startswith("未知"): assert not any( t["path"].lower().split("/")[-1].startswith(("license", "licence")) for t in tree["tree"] ) else: lic = next( x for x in rows if x["id"] == e["id"] and x["local_file"] == e["license_file"] ) assert ( hashlib.sha256((REF / e["license_file"]).read_bytes()).hexdigest() == lic["sha256"] ) checks.append( dict( id=e["id"], file=e["file"], sha256=e["sha256"], commit=e["commit"], tree=e["tree"], license_file=e["license_file"], proof=( "raw commit/tag + selected blob reh" "ashed; complete tree listing not t" "ree-object rehash" ), ) ) inv = inventory() assert len(inv["fields"]) == 42 and len(inv["notes"]) == 0 assert inv["scopes"][0]["nodes"] == 18 and inv["scopes"][0]["edges"] == 22 assert [(n["id"], n["mode"]) for n in inv["nodes"] if n["mode"] != 0] == [] for a, f in zip(inv["fields"], block["fields"], strict=True): assert (a["pointer"], a["json_type"], canonical(a["value"])) == ( f["pointer"], f["json_type"], canonical(f["value"]), ) for e in block["sources"]: raw = (OUT / e["local_file"]).read_bytes() assert hashlib.sha256(raw).hexdigest() == e["sha256"] assert 1 <= e["lines"][0] <= e["lines"][1] <= len(raw.decode().splitlines()) ns = {n["id"]: n for n in inv["nodes"]} endpoints = [] for edge in inv["links"]: eid, a, ao, z, zi, kind = edge src, dst = ns[a]["outputs"][ao], ns[z]["inputs"][zi] assert eid in (src.get("links") or []) and dst["link"] == eid # Reroutes retain literal * edge type instead of rewriting it. assert kind == "*" or src["type"] == "*" or kind == src["type"] assert kind == "*" or dst["type"] == "*" or kind == dst["type"] endpoints.append(dict(edge=edge, source_backref=True, target_backref=True)) ids = [e[0] for e in inv["links"]] assert len(set(ids)) == 22 for n in ns.values(): for slot in n["inputs"]: assert slot.get("link") is None or slot["link"] in ids for slot in n["outputs"]: assert all(x in ids for x in slot.get("links") or []) assert [(x["node"], x["state"]) for x in inv["empty"]] == [ (4, "empty_list"), (47, "missing"), (46, "missing"), ] assert inv["extra"]["frontendVersion"] == "1.37.11" assert all("link" not in x for x in ns[10]["inputs"]) assert "links" not in ns[35]["outputs"][0] assert ns[43]["widgets_values"] == [-1, "", "", ""] assert sum(f["role"] == "linked_saved_cache" for f in block["fields"]) == 6 assert sum(f["role"] == "frontend_reference_only" for f in block["fields"]) == 5 lock = (REF / "frontend__pnpm-lock.yaml").read_text() workspace = (REF / "frontend__pnpm-workspace.yaml").read_text() assert "lockfileVersion: '9.0'" in lock and "catalogs:" in lock assert "@comfyorg/comfyui-electron-types@0.6.2" in lock assert "'@comfyorg/comfyui-electron-types': 0.6.2" in workspace assert json.loads((REF / "frontend__package.json").read_bytes())["version"] == "1.37.11" assert ( "@/lib/litegraph/src/litegraph" in (REF / "frontend__src__scripts__widgets.ts").read_text() ) assert (REF / "frontend__src__lib__litegraph__src__LGraphNode.ts").is_file() assert not any(e["file"] == "package-lock.json" for e in rows if e["id"] == "frontend") dependency = dict( lock="同树pnpm-lock.yaml v9,catalogs及工作区声明;仅原文核对,不下载/执行依赖", litegraph="本版仓库src/lib/litegraph内置代码;不借上一图0.15.15包", catalog_example="@comfyorg/comfyui-electron-types 0.6.2", full_dependency_runtime_validated=False, ) (OUT / "dependency-check.json").write_text( json.dumps(dependency, ensure_ascii=False, indent=2) + "\n" ) (OUT / "source-check.json").write_text( json.dumps( dict( sources=checks, endpoints=endpoints, slot_states=inv["slots"], inventory_matched=True, upstream_executed=False, ), ensure_ascii=False, indent=2, ) + "\n" ) print( ( "PASS exact Git identities/selected blo" "bs/licenses, 22 bidirectional edges, 4" "2 positions, six overrides" ) ) if __name__ == "__main__": main()