117 lines
4.2 KiB
Python
117 lines
4.2 KiB
Python
"""Bind final narrow GET/DOM/screenshots to unchanged values and corrected history."""
|
|
|
|
import hashlib
|
|
import json
|
|
import re
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[4]
|
|
HERE = Path(__file__).resolve().parent
|
|
BROWSER = ROOT / ".local-evidence/animate2-history-document/browser"
|
|
|
|
|
|
def digest(raw):
|
|
return hashlib.sha256(raw).hexdigest()
|
|
|
|
|
|
def main():
|
|
actual = json.loads((BROWSER / "actual-get.json").read_bytes())
|
|
export = HERE / ("actual-" + actual["name"] + ".json")
|
|
document = json.loads(export.read_bytes())
|
|
assert document == actual["doc_json"]
|
|
shutil.copyfile(BROWSER / "actual-get.json", HERE / "actual-get.json")
|
|
browser = json.loads((HERE / "browser-results.json").read_bytes())
|
|
block = document["fixed_version"]
|
|
notes = []
|
|
for note in block["comments"]:
|
|
renders = [r for r in browser["text_renderings"] if r["kind"] == "Note" + note["node_id"]]
|
|
assert len(renders) == 2
|
|
sha = digest(note["text"].encode())
|
|
assert all(r["decoded_sha256"] == sha for r in renders)
|
|
notes.append(
|
|
dict(
|
|
node=note["node_id"],
|
|
sha256=sha,
|
|
LF=note["text"].count("\n"),
|
|
CR=note["text"].count("\r"),
|
|
tail_LF=note["text"].endswith("\n"),
|
|
)
|
|
)
|
|
assert len(notes) == 5 and len(block["fields"]) == 230
|
|
for value in block["fields"]:
|
|
assert type(value["value"]).__name__ == value["json_type"]
|
|
viewed = json.loads((HERE / "viewed-screenshots.json").read_bytes())
|
|
assert len(viewed) == 10
|
|
screenshots = [
|
|
dict(path=p.name, sha256=digest(p.read_bytes())) for p in sorted(BROWSER.glob("*.png"))
|
|
]
|
|
assert len(screenshots) == 14
|
|
(HERE / "screenshot-review.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
final_screenshots=screenshots,
|
|
viewed=[dict(path=n, sha256=digest((BROWSER / n).read_bytes())) for n in viewed],
|
|
findings="最终两尺寸五来源截图实际查看,日期/未知fetch/零旧引用/身份可核;未见横向溢出。DOM/解析值核准,不称长文逐字目验。",
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
(HERE / "get-binding.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
workflow_id=actual["id"],
|
|
actual_get_sha256=digest((BROWSER / "actual-get.json").read_bytes()),
|
|
isolated_export_sha256=digest(export.read_bytes()),
|
|
doc_json_equals_isolated_export=True,
|
|
equality=(
|
|
"JSON content/per-value parsed type/canonical; "
|
|
"not original HTTP serialization bytes"
|
|
),
|
|
notes=notes,
|
|
pins=json.loads((HERE / "pins.json").read_bytes()),
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
for p in (ROOT / ".local-evidence").glob("a2history-*.txt"):
|
|
shutil.copyfile(p, HERE / p.name)
|
|
protection = json.loads((HERE / "import-protection.json").read_bytes())
|
|
assert protection["base"] == "fa5863349e114b30aaee95a6f10eada8d2edb5ab"
|
|
tests = int(
|
|
re.search(r"(\d+) passed", (ROOT / ".local-evidence/a2history-tests.txt").read_text())[1]
|
|
)
|
|
result = dict(
|
|
base=protection["base"],
|
|
backend_tests=tests,
|
|
narrow_browser_assertions=browser["assertion_count"],
|
|
final_screenshots=14,
|
|
actually_viewed=10,
|
|
corrected_sources=5,
|
|
frozen_other_sources=81,
|
|
valid_prior_references=175,
|
|
rejected_prior_cases=15,
|
|
rejected_fetch_cases=5,
|
|
full_browser_rerun=False,
|
|
full_js_frontend_build="inherited chief independent batch164 results",
|
|
original_construction_browser="8304 historical, not accumulated or called correction rerun",
|
|
final_documents=0,
|
|
new_conversions=0,
|
|
real_executions=0,
|
|
)
|
|
(HERE / "validation-results.json").write_text(
|
|
json.dumps(result, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print(
|
|
"PASS narrow GET/export equality;230 typed values/5 Notes;"
|
|
"14 final screenshots/10 actually viewed"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|