381 lines
14 KiB
Python
381 lines
14 KiB
Python
"Verify exact text, Git/package provenance and source graph without upstream imports."
|
|
|
|
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"] == "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))
|
|
assert inv["sha256"] == "40f92a22aa66c9d87b876784e33b02471339d64504e22e1672155608fbcbf079"
|
|
assert len(inv["fields"]) == 97 and not inv["notes"] and len(inv["scopes"]) == 1
|
|
sc = inv["scopes"][0]
|
|
assert (sc["nodes"], sc["edges"], sc["named_nodes"]) == (61, 59, 53)
|
|
assert sc["modes"].count(0) == 60 and sc["modes"].count(4) == 1
|
|
assert {e["node"] for e in inv["empty"]} == {238, 243, 246, 270, 226, 224, 281, 282}
|
|
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"]
|
|
and f["scope"] == "root"
|
|
)
|
|
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"]}
|
|
assert g["extra"]["frontendVersion"] == "1.45.20"
|
|
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
|
|
assert {e[0]: e[1:5] for e in g["links"]} == {
|
|
549: [221, 0, 222, 0],
|
|
550: [224, 0, 222, 1],
|
|
551: [222, 0, 223, 0],
|
|
559: [223, 0, 226, 0],
|
|
567: [224, 2, 225, 1],
|
|
568: [226, 0, 225, 2],
|
|
569: [224, 1, 225, 3],
|
|
572: [238, 0, 229, 0],
|
|
573: [230, 0, 231, 0],
|
|
574: [232, 0, 233, 0],
|
|
575: [234, 0, 235, 0],
|
|
576: [260, 0, 236, 0],
|
|
577: [236, 0, 237, 0],
|
|
578: [260, 0, 237, 1],
|
|
579: [255, 0, 237, 2],
|
|
580: [258, 0, 238, 0],
|
|
581: [241, 0, 238, 1],
|
|
582: [258, 0, 243, 0],
|
|
583: [239, 0, 243, 1],
|
|
584: [261, 0, 246, 0],
|
|
585: [237, 0, 252, 0],
|
|
586: [252, 0, 253, 0],
|
|
587: [254, 0, 258, 0],
|
|
588: [261, 0, 258, 1],
|
|
589: [246, 0, 258, 2],
|
|
590: [261, 1, 258, 3],
|
|
591: [259, 0, 258, 4],
|
|
592: [245, 0, 260, 0],
|
|
593: [251, 0, 261, 0],
|
|
594: [250, 0, 261, 1],
|
|
595: [249, 0, 261, 2],
|
|
596: [248, 0, 261, 3],
|
|
597: [247, 0, 261, 4],
|
|
598: [257, 0, 261, 6],
|
|
599: [256, 0, 261, 8],
|
|
600: [240, 0, 261, 9],
|
|
601: [242, 0, 261, 10],
|
|
602: [229, 0, 262, 0],
|
|
603: [243, 0, 262, 1],
|
|
604: [244, 0, 262, 2],
|
|
609: [263, 5, 264, 0],
|
|
610: [263, 3, 265, 0],
|
|
611: [263, 4, 266, 0],
|
|
612: [263, 1, 267, 0],
|
|
613: [270, 1, 268, 0],
|
|
614: [270, 0, 269, 0],
|
|
616: [270, 3, 271, 0],
|
|
617: [276, 0, 273, 0],
|
|
618: [263, 6, 274, 0],
|
|
619: [272, 0, 275, 0],
|
|
620: [213, 0, 270, 0],
|
|
621: [213, 1, 263, 1],
|
|
622: [213, 0, 263, 0],
|
|
623: [213, 2, 263, 2],
|
|
624: [213, 3, 263, 3],
|
|
625: [278, 0, 224, 0],
|
|
626: [225, 0, 279, 0],
|
|
627: [280, 0, 261, 5],
|
|
628: [262, 0, 227, 0],
|
|
}
|
|
import collections
|
|
|
|
types = collections.Counter(f["json_type"] for f in inv["fields"])
|
|
assert types == dict(str=73, int=18, bool=5, NoneType=1)
|
|
raw = ns[213]["widgets_values"][3]
|
|
state = json.loads(raw)
|
|
assert raw == ns[213]["widgets_values_named"]["track_data"]
|
|
assert (
|
|
len(raw),
|
|
raw.count("\r"),
|
|
raw.count("\n"),
|
|
raw.count("\\n"),
|
|
raw.endswith("\n"),
|
|
hashlib.sha256(raw.encode()).hexdigest(),
|
|
) == (
|
|
35148,
|
|
0,
|
|
0,
|
|
417,
|
|
False,
|
|
"8caa7d545534a1af3656e71608699eada1e78c076f8d545512afc8ebd88030db",
|
|
)
|
|
keys = []
|
|
|
|
def scan(v, p=""):
|
|
if isinstance(v, dict):
|
|
for k, x in v.items():
|
|
if (
|
|
any(
|
|
t in k.lower()
|
|
for t in [
|
|
"api_key",
|
|
"apikey",
|
|
"authorization",
|
|
"access_token",
|
|
"password",
|
|
"secret",
|
|
]
|
|
)
|
|
and x
|
|
):
|
|
keys.append(p + "/" + k)
|
|
scan(x, p + "/" + k)
|
|
elif isinstance(v, list):
|
|
for i, x in enumerate(v):
|
|
scan(x, p + "/" + str(i))
|
|
|
|
scan(state)
|
|
assert not keys
|
|
assert state["muted"] is False and type(state["volume_db"]) is int and state["volume_db"] == 0
|
|
assert (
|
|
state["task_markers"] == []
|
|
and state["task_overview"] is False
|
|
and state["total_length"] == 163
|
|
and state["frame_rate"] == 24
|
|
)
|
|
assert [t["type"] for t in state["tracks"]] == ["task", "video"] and all(
|
|
len(t["segments"]) == 1
|
|
and t["segments"][0]["start_frame"] == 0
|
|
and t["segments"][0]["end_frame"] == 163
|
|
for t in state["tracks"]
|
|
)
|
|
assert ns[229]["mode"] == 4 and ns[229]["widgets_values"] == [
|
|
1920,
|
|
1920,
|
|
"nvidia_rtx_vsr",
|
|
"resize",
|
|
"0, 0, 0",
|
|
"center",
|
|
32,
|
|
"cpu",
|
|
]
|
|
assert ns[272]["widgets_values"] == [False] and ns[276]["widgets_values"] == [
|
|
0,
|
|
"randomize",
|
|
None,
|
|
]
|
|
assert (
|
|
ns[261]["widgets_values"][1] == "reference"
|
|
and next(i for i in ns[261]["inputs"] if i["name"] == "mode")["link"] is None
|
|
)
|
|
assert next(i for i in ns[263]["inputs"] if i["name"] == "previous")["link"] is None
|
|
assert (
|
|
ns[263]["outputs"][8]["name"] == "LOCKED_AUDIO" and ns[263]["outputs"][8]["links"] is None
|
|
)
|
|
assert (
|
|
ns[263]["outputs"][0]["links"] == ns[263]["outputs"][2]["links"] == []
|
|
and "links" not in ns[263]["outputs"][7]
|
|
)
|
|
assert (
|
|
"links" not in ns[224]["outputs"][3]
|
|
and ns[224]["outputs"][3]["type"] == "COMBO"
|
|
and ns[224]["outputs"][4]["links"] is None
|
|
)
|
|
assert ns[258]["outputs"][0]["links"] == [580, 582] and all(
|
|
"links" not in o for o in ns[227]["outputs"]
|
|
)
|
|
assert (
|
|
ns[281]["title"] == "视频动作参考+多参图-8步极速生成"
|
|
and ns[282]["title"] == "MiniMax_H3_导演台_动作模仿_1080P"
|
|
)
|
|
assert all(
|
|
ns[i]["properties"]["fontSize"] == 200 and ns[i]["properties"]["fontFamily"] == "Arial"
|
|
for i in [281, 282]
|
|
)
|
|
bind = {e["node_id"]: e for e in block["node_bindings"]}
|
|
assert len(bind) == 61
|
|
assert (
|
|
sum(len(e["candidates"]) == 1 for e in bind.values()) == 27
|
|
and sum(e["source_id"] == "unknown" for e in bind.values()) == 34
|
|
)
|
|
assert all(
|
|
e["source_id"] == "unknown" and not e["candidates"]
|
|
for e in bind.values()
|
|
if e["class_type"] in ["SetNode", "GetNode", "Label (rgthree)"]
|
|
)
|
|
|
|
def text(key, file):
|
|
return (
|
|
REF / next(e["local_file"] for e in rows if e["id"] == key and e["file"] == file)
|
|
).read_text()
|
|
|
|
da = text("core0290", "comfy_extras/nodes_depth_anything_3.py")
|
|
for cls in ["LoadDA3Model", "DA3Inference", "DA3Render"]:
|
|
assert (
|
|
"class " + cls + "(io.ComfyNode)" in da
|
|
and cls + "," in da.split("class DA3Extension")[1]
|
|
)
|
|
assert (
|
|
'"nodes_depth_anything_3.py"' in text("core0290", "nodes.py")
|
|
and "async def comfy_entrypoint() -> DA3Extension:" in da
|
|
)
|
|
assert 'mode_val = mode["mode"]' in da and 'output_val = output["output"]' in da
|
|
prep = text("core0290", "comfy/ldm/depth_anything_3/preprocess.py")
|
|
assert (
|
|
"low_quantile: float = 0.01" in prep
|
|
and "high_quantile: float = 0.99" in prep
|
|
and "torch.randint" in prep
|
|
and "norm = 1.0 - norm" in prep
|
|
)
|
|
task = (
|
|
text("mediaout", "nodes/basic.py").split("class MultiTrackTaskOutput")[1].split("class ")[0]
|
|
)
|
|
assert "previous" not in task and "LOCKED_AUDIO" not in task
|
|
plugin = text("mediaout", "nodes/video.py")
|
|
assert (
|
|
"class EasySaveVideo(io.ComfyNode)" in plugin
|
|
and 'input_mode.get("input_mode", "images+audio")' in plugin
|
|
and "source_video.save_to(" in plugin
|
|
and "return io.NodeOutput(source_video, relative_path)" in plugin
|
|
)
|
|
assert "EasySaveVideo," in text("mediaout", "__init__.py") and "from .video import *" in text(
|
|
"mediaout", "nodes/__init__.py"
|
|
)
|
|
comp = (
|
|
text("core0290", "comfy_extras/nodes_video.py")
|
|
.split("class GetVideoComponents")[1]
|
|
.split("class ")[0]
|
|
)
|
|
assert 'io.Int.Output(display_name="bit_depth")' in comp and "color_space" not in comp
|
|
clip = text("core0290", "nodes.py").split("class CLIPLoader:")[1].split("class ")[0]
|
|
assert (
|
|
'"minimax"' not in clip
|
|
and "getattr(comfy.sd.CLIPType, type.upper(), comfy.sd.CLIPType.STABLE_DIFFUSION)" in clip
|
|
)
|
|
audio = (
|
|
text("core0290", "comfy_extras/nodes_audio.py")
|
|
.split("def vae_decode_audio(")[1]
|
|
.split("class VAEDecodeAudio")[0]
|
|
)
|
|
assert "unbind" not in audio
|
|
video = text("core0302", "comfy_extras/nodes_video.py")
|
|
assert 'codec_name = codec["codec"]' in video
|
|
create = video.split("class CreateVideo")[1].split("class ")[0]
|
|
assert '"color_space"' not in create and '"codec"' not in create
|
|
result = dict(
|
|
sources=checks,
|
|
positions=97,
|
|
paired_positions=97,
|
|
list_types=types,
|
|
notes=0,
|
|
edges=59,
|
|
accurate_nodes=27,
|
|
unknown_identity_nodes=[e for e in bind.values() if e["source_id"] == "unknown"],
|
|
track_raw_sha256=hashlib.sha256(raw.encode()).hexdigest(),
|
|
parsed_track_data=state,
|
|
credential_keys_found=keys,
|
|
schema_conflicts=[
|
|
"DA3 mode/output typed dict vs saved strings",
|
|
"DA3 tooltip mean/std vs percentile helper",
|
|
"TaskOutput extra previous/LOCKED_AUDIO absent exact829a",
|
|
"GetVideoComponents COMBO and extra color_space vs exactINT/four outputs",
|
|
"core029 minimax CLIP absent/audio no nested extraction",
|
|
"easy saveVideo typed modes/relative returned path",
|
|
"CreateVideo extra fields/bit_depth COMBO",
|
|
"SaveVideo single data output/typed codec",
|
|
"swap no container3 vs4unpack",
|
|
],
|
|
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("PASS97 positions/named;0Note/59edges;27 exact/34 unknown; raw35148/SHA")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|