338 lines
12 KiB
Python
338 lines
12 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))
|
|
import collections
|
|
|
|
from build_definition import PATHS, REPO
|
|
|
|
assert inv["sha256"] == "d2850f5fb3e5b54e3e4ec9e17f34bdb11bf7009728b5e585c769fb2f11f80275"
|
|
assert len(inv["fields"]) == 81 and len(inv["notes"]) == 1 and len(inv["scopes"]) == 1
|
|
sc = inv["scopes"][0]
|
|
assert (sc["nodes"], sc["edges"], sc["named_nodes"]) == (54, 50, 47)
|
|
assert sc["modes"].count(0) == 53 and sc["modes"].count(4) == 1
|
|
assert {e["node"] for e in inv["empty"]} == {13, 18, 11, 23, 72, 70, 73} and 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"])
|
|
types = collections.Counter(x["json_type"] for x in inv["fields"])
|
|
assert types == dict(str=61, int=16, bool=3, NoneType=1)
|
|
g = json.loads((REPO / PATHS[0]).read_bytes())
|
|
ns = {n["id"]: n for n in g["nodes"]}
|
|
assert (
|
|
not g.get("definitions", {}).get("subgraphs") and 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
|
|
assert {e[0]: e[1:5] for e in g["links"]} == {
|
|
7: [9, 0, 6, 0],
|
|
8: [6, 0, 7, 0],
|
|
9: [9, 0, 7, 1],
|
|
11: [17, 0, 9, 0],
|
|
12: [15, 0, 10, 0],
|
|
13: [11, 0, 10, 1],
|
|
15: [14, 0, 11, 0],
|
|
17: [14, 0, 13, 0],
|
|
20: [20, 0, 14, 1],
|
|
21: [23, 0, 14, 2],
|
|
22: [20, 1, 14, 3],
|
|
24: [13, 0, 15, 0],
|
|
26: [29, 0, 18, 0],
|
|
36: [29, 0, 21, 0],
|
|
37: [29, 1, 21, 1],
|
|
38: [29, 2, 21, 2],
|
|
39: [29, 3, 21, 3],
|
|
41: [20, 0, 23, 0],
|
|
60: [10, 0, 31, 0],
|
|
69: [1, 0, 39, 0],
|
|
70: [8, 0, 40, 0],
|
|
71: [2, 0, 41, 0],
|
|
72: [42, 0, 13, 1],
|
|
73: [43, 0, 11, 1],
|
|
74: [44, 0, 20, 0],
|
|
75: [45, 0, 20, 1],
|
|
76: [46, 0, 20, 2],
|
|
77: [21, 1, 48, 0],
|
|
78: [21, 3, 49, 0],
|
|
79: [21, 4, 50, 0],
|
|
82: [21, 5, 51, 0],
|
|
83: [21, 6, 52, 0],
|
|
84: [47, 0, 20, 3],
|
|
85: [53, 0, 20, 4],
|
|
86: [54, 0, 20, 6],
|
|
87: [18, 0, 55, 0],
|
|
88: [18, 1, 56, 0],
|
|
89: [18, 3, 57, 0],
|
|
90: [58, 0, 10, 2],
|
|
91: [59, 0, 20, 8],
|
|
92: [61, 0, 20, 9],
|
|
93: [62, 0, 20, 10],
|
|
95: [63, 0, 14, 0],
|
|
96: [19, 0, 65, 0],
|
|
97: [66, 0, 7, 2],
|
|
98: [67, 0, 68, 0],
|
|
100: [69, 0, 14, 4],
|
|
103: [7, 0, 73, 0],
|
|
104: [73, 0, 38, 0],
|
|
105: [38, 0, 64, 0],
|
|
}
|
|
assert ns[21]["outputs"][0]["links"] == [] and ns[21]["outputs"][1]["links"] == [77]
|
|
assert (
|
|
ns[21]["outputs"][2]["links"] == []
|
|
and "links" not in ns[21]["outputs"][7]
|
|
and ns[21]["outputs"][8]["links"] is None
|
|
)
|
|
assert "link" not in next(i for i in ns[20]["inputs"] if i["name"] == "videos")
|
|
assert "link" not in next(i for i in ns[20]["inputs"] if i["name"] == "mode")
|
|
assert ns[14]["widgets_values"] == [304583185482826, "fixed", 8, 1, "euler", "beta", 1]
|
|
assert ns[67]["widgets_values"] == [0, "randomize", None] and ns[19]["widgets_values"] == [
|
|
False
|
|
]
|
|
assert ns[14]["outputs"][0]["links"] == [15, 17]
|
|
assert ns[15]["mode"] == 4 and ns[15]["widgets_values"] == [
|
|
1920,
|
|
1920,
|
|
"nvidia_rtx_vsr",
|
|
"resize",
|
|
"0, 0, 0",
|
|
"center",
|
|
32,
|
|
"cpu",
|
|
]
|
|
assert all("links" not in x for x in ns[31]["outputs"])
|
|
raw = ns[29]["widgets_values"][-1]
|
|
state = json.loads(raw)
|
|
assert raw == ns[29]["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(),
|
|
) == (
|
|
40418,
|
|
0,
|
|
0,
|
|
425,
|
|
False,
|
|
"f7724df6ecd18533da9ce9229dd76a132a22d9c5720b2275d71ed8efaf3c07ae",
|
|
)
|
|
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 state["volume_db"] == 0 and type(state["volume_db"]) is int
|
|
assert (
|
|
state["task_markers"] == []
|
|
and state["task_overview"] is False
|
|
and state["total_length"] == 240
|
|
and state["frame_rate"] == 24
|
|
)
|
|
assert [t["type"] for t in state["tracks"]] == ["task", "video"] and [
|
|
len(t["segments"]) for t in state["tracks"]
|
|
] == [1, 0]
|
|
assert (
|
|
state["tracks"][0]["segments"][0]["start_frame"] == 0
|
|
and state["tracks"][0]["segments"][0]["end_frame"] == 240
|
|
)
|
|
note = ns[30]["widgets_values"][0]
|
|
assert (
|
|
len(note),
|
|
note.count("\n"),
|
|
note.count("\\n"),
|
|
note.endswith("\n"),
|
|
hashlib.sha256(note.encode()).hexdigest(),
|
|
) == (813, 12, 0, False, "15c6be6b87e756890d954458294e2bc5f4c5becf5a4053935b6f1456675d206f")
|
|
assert (
|
|
note == ns[30]["widgets_values_named"]["text"]
|
|
and not ns[30]["inputs"]
|
|
and not ns[30]["outputs"]
|
|
)
|
|
binds = block["node_bindings"]
|
|
assert (
|
|
len(binds) == 53
|
|
and sum(bool(x["candidates"]) for x in binds) == 22
|
|
and sum(x["source_id"] == "unknown" for x in binds) == 31
|
|
)
|
|
assert all(
|
|
x["source_id"] == "unknown" and not x["candidates"]
|
|
for x in binds
|
|
if x["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()
|
|
|
|
kj = text("kjmemory", "nodes/ltxv_nodes.py")
|
|
cl = kj.split("class MiniMaxH3MemoryEfficientSageAttentionPatch")[1].split(
|
|
"class LTX2LoraLoaderAdvanced"
|
|
)[0]
|
|
assert (
|
|
'io.Model.Input("model")' in cl
|
|
and "if _cuda_archs is None:" in cl
|
|
and "if _ck is None:" in cl
|
|
and "is_experimental=True" in cl
|
|
)
|
|
assert (
|
|
"isinstance(diffusion_model, _MiniMaxH3Model)" in cl
|
|
and "diffusion_model.blocks.{idx}.attn.forward" in cl
|
|
)
|
|
assert "MiniMaxH3MemoryEfficientSageAttentionPatch" in text("kjmemory", "__init__.py")
|
|
assert (
|
|
"_sageattn_int8_fp8_nhd" in kj
|
|
and "_quant_query_per_thread_int8_i64_kernel" in kj
|
|
and "v_pad_len = 128" in kj
|
|
)
|
|
assert (
|
|
json.loads((REF / "kjmemory-registry-response.txt").read_bytes())["repository"]
|
|
== "https://github.com/kijai/ComfyUI-KJNodes"
|
|
)
|
|
ed = text("mediaeditor", "nodes/basic.py")
|
|
assert "class MultiTrackEditor" in ed and "def _parse_override_segments" in ed
|
|
assert "return None, lambda: None, set()" in text("swap", "block_swap.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
|
|
result = dict(
|
|
sources=checks,
|
|
positions=81,
|
|
paired_positions=81,
|
|
list_types=types,
|
|
notes=1,
|
|
edges=50,
|
|
accurate_nodes=22,
|
|
unknown_identity_nodes=[e for e in binds if e["source_id"] == "unknown"],
|
|
track_raw_sha256=hashlib.sha256(raw.encode()).hexdigest(),
|
|
parsed_track_data=state,
|
|
note_sha256=hashlib.sha256(note.encode()).hexdigest(),
|
|
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(binds, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print("PASS81 positions/named,1Note813,50edges,22exact/31unknown,40418state; static only")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|