Files
aigc-home/docs/hel-892/qwen21-vnccs-document-evidence/verify_sources.py
T
2026-11-01 04:43:13 +08:00

172 lines
6.8 KiB
Python

"""Verify only original identity gaps and bounded metadata; no upstream imports/media decode."""
import hashlib
import json
from build_definition import OUT, PATHS, REF, REPO, build, canonical
from inventory import inventory
def main():
block, inv = build(), inventory()
raw = (REPO / PATHS[0]).read_bytes()
g = json.loads(raw)
assert (
hashlib.sha256(raw).hexdigest()
== "a5a675500a473214eaeb1d25dc1eda83b57bba3a17d18f1f0042bee62b474314"
)
assert len(inv["fields"]) == 24 and len(inv["notes"]) == 1
assert [(s["nodes"], s["edges"], s["named_nodes"]) for s in inv["scopes"]] == [(12, 13, 11)]
assert inv["scopes"][0]["modes"] == [0] * 12
assert [(z["node"], z["state"]) for z in inv["empty"]] == [
(8, "missing"),
(10, "empty_list"),
(11, "empty_list"),
]
assert sum(f["json_type"] == "NoneType" for f in inv["fields"]) == 1
assert all(f["json_type"] not in ["list", "dict"] for f in inv["fields"])
ns = {n["id"]: n for n in g["nodes"]}
assert not g.get("definitions") and "frontendVersion" not in g["extra"]
assert all(
not any(k in n.get("properties", {}) for k in ["cnr_id", "aux_id", "ver"])
for n in g["nodes"]
)
assert "widgets_values" not in ns[8] and "widgets_values_named" not in ns[8]
assert ns[10]["widgets_values"] == ns[11]["widgets_values"] == []
assert ns[10]["widgets_values_named"] == ns[11]["widgets_values_named"] == {}
assert ns[6]["widgets_values"][-1] is None
assert ns[6]["widgets_values_named"]["打开自由姿势编辑器"] is None
assert len(ns[6]["inputs"]) == 8
assert all(i["name"] != "打开自由姿势编辑器" for i in ns[6]["inputs"])
for eid, a, ao, z, zi, _ in g["links"]:
assert eid in ns[a]["outputs"][ao]["links"]
assert ns[z]["inputs"][zi]["link"] == eid
assert ns[7]["inputs"][3]["link"] == 8
assert ns[6]["outputs"][2]["links"] == [8]
assert ns[6]["outputs"][3]["links"] == [13] and ns[6]["outputs"][4]["links"] == [12]
assert ns[5]["outputs"][1]["links"] in [None, []]
assert ns[9]["widgets_values"] == ["image/Qwen_image2.1"]
def pointer(obj, p):
for bit in p.strip("/").split("/"):
bit = bit.replace("~1", "/").replace("~0", "~")
obj = obj[int(bit)] if isinstance(obj, list) else obj[bit]
return obj
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"]),
)
assert (
canonical(pointer(g, f["named_pointer"]))
== canonical(f["named_value"])
== canonical(f["value"])
)
assert all("未知" in f[k] for k in ["schema_default", "unit", "limits"])
for i, n in enumerate(g["nodes"]):
if n["type"] in ["Note", "MarkdownNote"]:
continue
expected = {
f"/nodes/{i}/widgets_values_named/" + k.replace("~", "~0").replace("/", "~1")
for k in n.get("widgets_values_named", {})
}
assert expected == {
f["named_pointer"] for f in block["fields"] if f["pointer"].startswith(f"/nodes/{i}/")
}
assert all(
b["source_id"] == "unknown" and b["candidates"] == [] for b in block["node_bindings"]
)
assert len(block["node_bindings"]) == 11 and not block["boundaries"]
t = ns[6]["widgets_values"][4]
assert (len(t), t.count("\n"), t.count("\\n"), t.endswith("\n")) == (496597, 0, 0, False)
assert (
hashlib.sha256(t.encode()).hexdigest()
== "2c0d3ecb142fd359d6c919034470d6cd4302de03c0865d49a904252213833974"
)
assert t == ns[6]["widgets_values_named"]["pose_json"]
pose = json.loads(t) # Static JSON metadata only; never decode poseReference.
assert (
type(pose["version"]) is int and pose["version"] == 2 and pose["kind"] == "vnccs-free-pose"
)
assert set(pose) == {
"version",
"kind",
"mesh",
"pose",
"proportions",
"transform",
"width",
"height",
"openpose",
"camera",
"poseReference",
}
assert pose["mesh"]["age"] == 25
assert len(pose["poseReference"]) == 493714 and pose["poseReference"].startswith(
"data:image/png;base64,"
)
assert [
(n["characters"], n["lf_count"], n["literal_backslash_n"], n["ends_with_lf"])
for n in inv["notes"]
] == [(19, 0, 0, False)]
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
for e in rows:
assert e["id"] == "identity-metadata" and e["file"].endswith(".json")
assert hashlib.sha256((REF / e["local_file"]).read_bytes()).hexdigest() == e["sha256"]
assert "不是" in e["commit"] and e["license_file"].startswith("未知")
acquisition = json.loads((REF / "acquisition.json").read_bytes())
assert [(e["id"], e["status"]) for e in acquisition] == [
("fisher-registry-candidate", 404),
("fisher-repository-candidate", 200),
]
assert not json.loads((REF / "identity-audit.json").read_bytes())[
"exact_upstream_identity_established"
]
metadata = {k: v for k, v in pose.items() if k != "poseReference"}
metadata["poseReference_summary_only"] = dict(
json_type="str",
characters=len(pose["poseReference"]),
utf8_sha256=hashlib.sha256(pose["poseReference"].encode()).hexdigest(),
prefix_text="data:image/png;base64,",
decoded=False,
rendered=False,
complete_original_in="原件及definition字段/实际doc_json/GET中的完整pose_json原字符串",
)
metadata["interpretation"] = (
"只静态保存元数据,不是后端schema/单位/实际图像/相机恢复;mesh.age不是参考人物信息"
)
(OUT / "pose-metadata.json").write_text(
json.dumps(metadata, ensure_ascii=False, indent=2) + "\n"
)
result = dict(
positions=24,
scalar_positions=23,
null_positions=1,
history_lists=0,
notes=1,
physical_edges_verified=13,
unknown_implementation_nodes=11,
pose_characters=len(t),
pose_utf8_sha256=hashlib.sha256(t.encode()).hexdigest(),
data_uri_characters=len(pose["poseReference"]),
schema_sources_verified=0,
metadata_rows=len(rows),
upstream_executed=False,
data_uri_decoded=False,
media_rendered=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(
"PASS 24 dual positions,complete496597-char string,1 Note,13 edges; "
"all implementation identities unknown"
)
if __name__ == "__main__":
main()