Files
aigc-home/docs/hel-892/ace-document-evidence/verify_sources.py
T
2026-10-31 04:31:41 +08:00

86 lines
3.7 KiB
Python

"Check exact Git text/tag identity and independent raw-source inventory."
import hashlib
import json
from build_definition import OUT, REF, REPO, build, canonical
from inventory import inventory
def main():
block = build()
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
for e in rows:
raw = (REF / e["local_file"]).read_bytes()
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
assert blob == e["git_blob_sha1"]
t = json.loads((REF / (e["id"] + "-tree.json")).read_bytes())
c = json.loads((REF / (e["id"] + "-commit.json")).read_bytes())
assert c["sha"] == t["sha"] == e["commit"] and not t["truncated"]
assert c["tree"]["sha"] == e["tree"]
assert next(x["sha"] for x in t["tree"] if x["path"] == e["file"]) == blob
for key in ["core", "primitive", "frontend"]:
tag = json.loads((REF / (key + "-tag.json")).read_bytes())
commits = {r["commit"] for r in rows if r["id"] == key}
assert commits == {tag["object"]["sha"]} and tag["object"]["type"] == "commit"
inv = inventory()
assert len(inv["fields"]) == 38 and len(inv["notes"]) == 1
for a, f in zip(inv["fields"], block["fields"], strict=True):
assert (a["pointer"], a["scope"], a["json_type"], canonical(a["value"])) == (
f["pointer"],
f["scope"],
f["json_type"],
canonical(f["value"]),
)
assert inv["notes"][0]["value"] == block["comments"][0]["text"]
texts = set()
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())
texts.add(e["local_file"])
g = json.loads((REPO / block["source_path"]).read_bytes())
ns = {n["id"]: n for n in g["nodes"]}
assert g["extra"]["frontendVersion"] == "1.44.0"
assert not g.get("definitions") and all("widgets_values_named" not in n for n in g["nodes"])
assert sum(n["mode"] == 0 for n in g["nodes"]) == 13
for eid, src, slot, dst, inp, _ in g["links"]:
assert eid in ns[src]["outputs"][slot]["links"] and ns[dst]["inputs"][inp]["link"] == eid
ace = (REF / "core__comfy_extras__nodes_ace.py").read_text()
assert "TextEncodeAceStepAudio1.5" not in ace and "EmptyAceStep1.5LatentAudio" not in ace
loader = (
(REF / "core__nodes.py")
.read_text()
.split("class DualCLIPLoader:")[1]
.split("class CLIPVisionLoader:")[0]
)
assert '"ace"' not in loader.split("def load_clip")[0]
assert {n["id"] for n in g["nodes"] if n.get("widgets_values") == []} == {47, 18}
assert all("widgets_values" in n and n["widgets_values"] is not None for n in g["nodes"])
(OUT / "source-check.json").write_text(
json.dumps(
dict(
all_pass=True,
source_files=len(rows),
cited_texts=len(texts),
citations=len(block["sources"]),
counts=block["counts"],
local_file_base=str(OUT.relative_to(REPO)),
upstream_executed=False,
source_frontend="1.44.0",
ace15_missing_and_dual_clip_enum_conflict_preserved=True,
licenses="all exact GPL text pinned",
sdk_semantics="unknown; not loaded",
),
ensure_ascii=False,
indent=2,
)
+ "\n"
)
print(("PASS exact commit/tree/blob/tag, 38 raw positions, Note, 14 physical edges"))
if __name__ == "__main__":
main()