106 lines
3.5 KiB
Python
106 lines
3.5 KiB
Python
"Bounded original API declaration and typed-value audit, with zero implementation sources."
|
|
|
|
import hashlib
|
|
import json
|
|
from collections import Counter
|
|
|
|
from build_definition import EXPECTED, OUT, PATHS, REPO, build
|
|
|
|
|
|
def main():
|
|
raw = (REPO / PATHS[0]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == EXPECTED
|
|
graph, block = json.loads(raw), build()
|
|
types = Counter(f["json_type"] for f in block["fields"])
|
|
assert types == dict(str=35, int=27, float=4, bool=4)
|
|
assert all(nid.isdecimal() and ":" not in nid for nid in graph)
|
|
assert all(set(n) == {"inputs", "class_type", "_meta"} for n in graph.values())
|
|
assert block["sources"] == []
|
|
assert len(block["node_bindings"]) == 35
|
|
assert all(not n["implementation_verified"] for n in block["node_bindings"])
|
|
assert "pixels" not in graph["117"]["inputs"]
|
|
assert not {"117", "121"}.intersection(e["source_node_id"] for e in block["api_references"])
|
|
assert graph["53"]["inputs"]["latent_image"] == ["135", 0]
|
|
assert graph["120"]["inputs"]["source_latent"] == ["73", 0]
|
|
assert graph["123"]["inputs"]["image"] == ["147", 0]
|
|
assert graph["161"]["inputs"]["value"] is True and graph["160"]["inputs"]["value"] is False
|
|
assert graph["156"]["inputs"]["value"] == ""
|
|
strings = []
|
|
for nid, key, length, lf, tail, digest in [
|
|
(
|
|
"119",
|
|
"prompt",
|
|
138,
|
|
0,
|
|
False,
|
|
"ebdc3a3c4aadd8ae56a47dcecff163ff0523d1f7b7b1e4cb79195f1c0fc23c72",
|
|
),
|
|
(
|
|
"155",
|
|
"value",
|
|
2131,
|
|
22,
|
|
True,
|
|
"08d820ffced5c3a45a9ce10c995dfaf93d7f9ae15d3cf61540cac168b2bb01b3",
|
|
),
|
|
]:
|
|
value = graph[nid]["inputs"][key]
|
|
assert len(value) == length and value.count("\n") == lf and value.endswith("\n") == tail
|
|
assert hashlib.sha256(value.encode()).hexdigest() == digest
|
|
strings.append(
|
|
dict(
|
|
node_id=nid,
|
|
field=key,
|
|
characters=length,
|
|
LF=lf,
|
|
CR=value.count("\r"),
|
|
tail_LF=tail,
|
|
sha256=digest,
|
|
)
|
|
)
|
|
empty = [
|
|
dict(node_id=f["node_id"], field=f["field"], pointer=f["pointer"])
|
|
for f in block["fields"]
|
|
if f["value"] == "" and type(f["value"]) is str
|
|
]
|
|
(OUT / "original-audit.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
path=PATHS[0],
|
|
sha256=EXPECTED,
|
|
original_bytes=len(raw),
|
|
source_nodes=35,
|
|
scalars=70,
|
|
json_types=types,
|
|
references=block["api_references"],
|
|
node_identity_gaps=block["node_bindings"],
|
|
exact_implementation_sources=0,
|
|
original_fetch_time="unknown:未保留可证精确取得时刻",
|
|
strings=strings,
|
|
empty_strings=empty,
|
|
missing_inputs=[
|
|
dict(
|
|
node_id="117",
|
|
missing_key="pixels",
|
|
state="key absent, not null/array/material",
|
|
)
|
|
],
|
|
no_referenced_outputs=["117", "121"],
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print(
|
|
(
|
|
"PASS original35 / typed70 / references46 / im"
|
|
"plementation0 / full strings2 / original miss"
|
|
"ing keys"
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|