71 lines
2.3 KiB
Python
71 lines
2.3 KiB
Python
"""Verify only original declaration evidence; do not seek or execute implementations."""
|
|
|
|
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 = json.loads(raw)
|
|
block = build()
|
|
types = Counter(f["json_type"] for f in block["fields"])
|
|
assert types == dict(str=18, int=15, float=5, bool=4)
|
|
assert block["sources"] == [] and all(
|
|
not n["implementation_verified"] for n in block["node_bindings"]
|
|
)
|
|
assert all(set(n) == {"inputs", "class_type", "_meta"} for n in graph.values())
|
|
strings = []
|
|
for nid, length, lf, tail, sha in [
|
|
("156", 218, 0, False, "af0dbeaec99705afebe078d6af9b97ce03fb892e9ff1e30254eba207c6bc5772"),
|
|
(
|
|
"171:155",
|
|
2131,
|
|
22,
|
|
True,
|
|
"08d820ffced5c3a45a9ce10c995dfaf93d7f9ae15d3cf61540cac168b2bb01b3",
|
|
),
|
|
]:
|
|
value = graph[nid]["inputs"]["value"]
|
|
assert len(value) == length and value.count("\n") == lf and value.endswith("\n") == tail
|
|
assert hashlib.sha256(value.encode()).hexdigest() == sha
|
|
strings.append(
|
|
dict(
|
|
node_id=nid,
|
|
characters=length,
|
|
LF=lf,
|
|
CR=value.count("\r"),
|
|
tail_LF=tail,
|
|
sha256=sha,
|
|
starts_space=value.startswith(" "),
|
|
)
|
|
)
|
|
(OUT / "original-audit.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
path=PATHS[0],
|
|
sha256=EXPECTED,
|
|
original_bytes=len(raw),
|
|
source_nodes=24,
|
|
scalars=42,
|
|
json_types=types,
|
|
references=block["api_references"],
|
|
node_identity_gaps=block["node_bindings"],
|
|
exact_implementation_sources=0,
|
|
original_fetch_time="unknown:未保留可证精确取得时刻",
|
|
strings=strings,
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print("PASS original24 / typed42 / references34 / exact implementation0 / full strings2")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|