334 lines
13 KiB
Python
334 lines
13 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"] == "97ec7f73f32126aa24798fc65736734dfa839b74d25c4b2a94021abe063f06d7"
|
|
assert len(inv["fields"]) == 114 and not inv["notes"]
|
|
assert [(x["nodes"], x["edges"], x["named_nodes"]) for x in inv["scopes"]] == [
|
|
(58, 57, 50),
|
|
(3, 8, 3),
|
|
]
|
|
assert all(m == 0 for x in inv["scopes"] for m in x["modes"])
|
|
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"]
|
|
assert f["scope"] == ("root" if x["scope"] == "root" else "286")
|
|
assert canonical(f["value"]) == canonical(x["value"]) == canonical(f["named_value"])
|
|
import collections
|
|
|
|
from build_definition import PATHS, REPO
|
|
|
|
g = json.loads((REPO / PATHS[0]).read_bytes())
|
|
ns = {n["id"]: n for n in g["nodes"]}
|
|
sg = g["definitions"]["subgraphs"][0]
|
|
inner = {n["id"]: n for n in sg["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
|
|
edges = {e[0]: e[1:5] for e in g["links"]}
|
|
for eid, pair in {
|
|
642: [245, 0, 252, 0],
|
|
643: [252, 0, 285, 0],
|
|
644: [285, 0, 284, 0],
|
|
640: [284, 0, 283, 0],
|
|
639: [283, 0, 253, 0],
|
|
655: [254, 0, 289, 0],
|
|
660: [254, 0, 291, 0],
|
|
661: [261, 0, 291, 1],
|
|
584: [261, 0, 246, 0],
|
|
662: [246, 0, 291, 2],
|
|
664: [261, 1, 291, 4],
|
|
663: [250, 0, 291, 3],
|
|
653: [289, 0, 290, 0],
|
|
666: [290, 0, 291, 6],
|
|
665: [288, 0, 291, 5],
|
|
667: [291, 0, 238, 0],
|
|
668: [291, 0, 243, 0],
|
|
659: [238, 0, 262, 0],
|
|
645: [224, 0, 286, 0],
|
|
646: [286, 0, 226, 0],
|
|
568: [226, 0, 225, 2],
|
|
569: [224, 1, 225, 3],
|
|
567: [224, 2, 225, 1],
|
|
626: [225, 0, 279, 0],
|
|
627: [280, 0, 261, 5],
|
|
628: [262, 0, 227, 0],
|
|
}.items():
|
|
assert edges[eid] == pair, (eid, edges[eid], pair)
|
|
boundary = {
|
|
e["id"]: [e["origin_id"], e["origin_slot"], e["target_id"], e["target_slot"]]
|
|
for e in sg["links"]
|
|
}
|
|
assert boundary == {
|
|
1: [1, 0, 2, 0],
|
|
4: [2, 0, 5, 0],
|
|
2: [-10, 0, 2, 1],
|
|
5: [5, 0, -20, 0],
|
|
8: [-10, 1, 2, 2],
|
|
10: [-10, 3, 5, 1],
|
|
11: [-10, 4, 1, 0],
|
|
9: [-10, 2, 2, 4],
|
|
}
|
|
assert sg["widgets"] == [] and len(sg["inputs"]) == 5
|
|
assert "proxyWidgets" not in ns[286] and "proxyWidgets" not in ns[286]["properties"]
|
|
assert ns[286]["widgets_values"] == [9, 4, "depth", "moge_3_vitg_fp16.safetensors"]
|
|
assert inner[2]["widgets_values"] == [9, 0, 4, True, True, 3] and inner[5][
|
|
"widgets_values"
|
|
] == ["mask"]
|
|
types = collections.Counter(f["json_type"] for f in inv["fields"])
|
|
assert types == dict(str=72, int=32, bool=5, float=4, 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(),
|
|
) == (
|
|
36070,
|
|
0,
|
|
0,
|
|
416,
|
|
False,
|
|
"c30443f05d5052ffa08158c500873ab4376ae4d911af3dbcf2d557369dc1b75a",
|
|
)
|
|
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"] == 173
|
|
and state["frame_rate"] == 24
|
|
)
|
|
assert [t["type"] for t in state["tracks"]] == ["task", "video"]
|
|
assert all(
|
|
len(t["segments"]) == 1
|
|
and t["segments"][0]["start_frame"] == 0
|
|
and t["segments"][0]["end_frame"] == 173
|
|
for t in state["tracks"]
|
|
)
|
|
assert ns[291]["widgets_values"] == [
|
|
999,
|
|
"fixed",
|
|
1,
|
|
4,
|
|
0.5,
|
|
0,
|
|
0.5,
|
|
1,
|
|
"minimax_h3_latent_upscaler_3d_conv_v1_fp16.safetensors",
|
|
True,
|
|
"auto",
|
|
2,
|
|
"auto",
|
|
"",
|
|
]
|
|
assert next(i for i in ns[291]["inputs"] if i["name"] == "model_hires")["link"] is None
|
|
assert all(e[4] != 8 for e in g["links"] if e[3] == 291)
|
|
assert ns[276]["widgets_values"] == [1002069665555849, "randomize", None]
|
|
assert ns[283]["widgets_values"] == [
|
|
"vsa",
|
|
10,
|
|
0.2,
|
|
1,
|
|
"",
|
|
12288,
|
|
256,
|
|
"exact_kv_and_rows",
|
|
False,
|
|
]
|
|
assert ns[285]["widgets_values"] == [10, 3] and ns[290]["widgets_values"] == [
|
|
1,
|
|
0.7,
|
|
0,
|
|
"cosine",
|
|
]
|
|
assert ns[225]["widgets_values"] == ["images+audio", 24, "save", False, "video/ComfyUI"]
|
|
assert all(o["links"] is None for o in ns[227]["outputs"])
|
|
bind = {e["node_id"]: e for e in block["node_bindings"]}
|
|
assert len(bind) == 61 and sum(bool(e["candidates"]) for e in bind.values()) == 28
|
|
assert sum(e["source_id"] == "unknown" for e in bind.values()) == 32
|
|
assert bind["286"]["source_id"] == "subgraph-definition" and not bind["286"]["candidates"]
|
|
assert all(
|
|
e["source_id"] == "unknown"
|
|
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()
|
|
|
|
sl = text("selflift", "nodes.py")
|
|
cl = sl.split("class SelfLiftAvatarH3Sampler:")[1].split("NODE_CLASS_MAPPINGS")[0]
|
|
for k in ["tiling_mode", "tiling_tiles", "tiling_axis", "selflift_tiling_plan"]:
|
|
assert k not in cl
|
|
assert '"control_after_generate": True' in cl and "highres_tiling=False" in cl
|
|
assert (
|
|
"from .nodes import NODE_CLASS_MAPPINGS" in text("selflift", "__init__.py")
|
|
and '"SelfLiftAvatarH3Sampler": SelfLiftAvatarH3Sampler' in sl
|
|
)
|
|
assert "control_after_generate" in text("frontend", "src/scripts/widgets.ts")
|
|
mo = text("core0380", "comfy_extras/nodes_moge.py")
|
|
for cls in ["LoadMoGeModel", "MoGeInference", "MoGeRender"]:
|
|
assert "class " + cls in mo and cls + "," in mo.split("class MoGeExtension")[1]
|
|
assert "fov_x_degrees <= 0" in mo and "refine_steps" in mo
|
|
assert "class BlockSparseAttention" in text(
|
|
"core0380", "comfy_extras/nodes_sparse_attention.py"
|
|
)
|
|
assert "class MiniMaxH3SigmaShift" in text("core0380", "comfy_extras/nodes_minimax_h3.py")
|
|
assert "class ModelAttentionBackend" in text("core0380", "comfy_extras/nodes_model_advanced.py")
|
|
assert "importlib.import_module" in text("yc", "__init__.py") and '"H3SigmaRefiner"' in text(
|
|
"yc", "py/h3_sigma_refiner.py"
|
|
)
|
|
task = (
|
|
text("mediaout", "nodes/basic.py").split("class MultiTrackTaskOutput")[1].split("class ")[0]
|
|
)
|
|
assert "previous" not in task and "LOCKED_AUDIO" not in task
|
|
mini = (
|
|
text("media85", "nodes/minimax.py")
|
|
if any(e["id"] == "media85" and e["file"] == "nodes/minimax.py" for e in rows)
|
|
else ""
|
|
)
|
|
assert "locked_video_timing_frames" not in mini
|
|
result = dict(
|
|
sources=checks,
|
|
positions=114,
|
|
paired_positions=114,
|
|
list_types=types,
|
|
notes=0,
|
|
edges=65,
|
|
accurate_nodes=28,
|
|
unknown_identity_nodes=[e for e in bind.values() if e["source_id"] == "unknown"],
|
|
boundary_definition_nodes=1,
|
|
track_raw_sha256=hashlib.sha256(raw.encode()).hexdigest(),
|
|
parsed_track_data=state,
|
|
credential_keys_found=keys,
|
|
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("PASS114 root106/internal8;65edges/5boundaries;28exact/32unknown/1host;track36070")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|