docs(HEL-892): bind single-loop avatar workflow reference
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
"""Bind actual GET, reversible values and complete Notes/text DOM SHA evidence."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from build_definition import OUT, REF, REPO, canonical
|
||||
from rebuild import BASE
|
||||
|
||||
BROWSER = REPO / ".local-evidence/singleloop-document/browser"
|
||||
|
||||
|
||||
def sha(raw):
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
def write(name, value):
|
||||
(OUT / name).write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
|
||||
def main():
|
||||
actual = json.loads((BROWSER / "actual-get.json").read_bytes())
|
||||
export = OUT / ("actual-" + actual["name"] + ".json")
|
||||
doc = json.loads(export.read_bytes())
|
||||
assert actual["doc_json"] == doc
|
||||
assert canonical(actual["doc_json"]) == canonical(doc)
|
||||
shutil.copyfile(BROWSER / "actual-get.json", OUT / "actual-get.json")
|
||||
write(
|
||||
"get-binding.json",
|
||||
dict(
|
||||
workflow_id=actual["id"],
|
||||
get_sha256=sha((BROWSER / "actual-get.json").read_bytes()),
|
||||
export_sha256=sha(export.read_bytes()),
|
||||
doc_json_equals_isolated_export=True,
|
||||
comparison=(
|
||||
"Parsed JSON content and per-value type equality; "
|
||||
"not original HTTP serialization bytes"
|
||||
),
|
||||
pins=json.loads((OUT / "pins.json").read_bytes()),
|
||||
),
|
||||
)
|
||||
for p in (REPO / ".local-evidence").glob("singleloop-*.txt"):
|
||||
shutil.copyfile(p, OUT / p.name)
|
||||
for p in (REPO / ".local-evidence").glob("*singleloop*.py"):
|
||||
shutil.copyfile(p, OUT / (p.name + ".txt"))
|
||||
b = doc["fixed_version"]
|
||||
browser = json.loads((OUT / "browser-results.json").read_bytes())
|
||||
backend = json.loads((OUT / "backend-request-counts.json").read_bytes())
|
||||
report = (OUT.parent / "单人循环官流数字人固定参考中文说明.md").read_text()
|
||||
original = json.loads((OUT / "definition-0.json").read_bytes())
|
||||
texts = []
|
||||
for n in b["comments"]:
|
||||
raw = n["text"]
|
||||
literal = json.dumps(raw, ensure_ascii=False, indent=2)
|
||||
assert "\n```json\n" + literal + "\n```" in report
|
||||
assert json.loads(literal) == raw
|
||||
renders = [r for r in browser["text_renderings"] if r["kind"] == "Note" + n["node_id"]]
|
||||
assert len(renders) == 2 and all(r["decoded_sha256"] == sha(raw.encode()) for r in renders)
|
||||
texts.append(
|
||||
dict(
|
||||
node_id=n["node_id"],
|
||||
raw_codepoints=len(raw),
|
||||
raw_sha256=sha(raw.encode()),
|
||||
report_json_sha256=sha(literal.encode()),
|
||||
decoded_sha256=sha(json.loads(literal).encode()),
|
||||
LF=raw.count("\n"),
|
||||
CR=raw.count("\r"),
|
||||
literal_backslash_n=raw.count("\\n"),
|
||||
tail_LF=raw.endswith("\n"),
|
||||
browser_renderings=renders,
|
||||
)
|
||||
)
|
||||
assert len(texts) == 5 and len(doc["source_notes"]) == 5
|
||||
fields = []
|
||||
source_texts = []
|
||||
for f, s in zip(b["fields"], original["fields"], strict=True):
|
||||
assert f["pointer"] == s["pointer"] and canonical(f["value"]) == canonical(s["value"])
|
||||
assert type(f["value"]).__name__ == f["json_type"] == type(s["value"]).__name__
|
||||
assert "named_pointer" not in f and "named_value" not in f
|
||||
literal = json.dumps(s["value"], ensure_ascii=False, indent=2)
|
||||
assert "\n```json\n" + literal + "\n```" in report
|
||||
fields.append(
|
||||
dict(
|
||||
pointer=f["pointer"],
|
||||
json_type=f["json_type"],
|
||||
get_value_type=type(f["value"]).__name__,
|
||||
source_order_report_json_sha256=sha(literal.encode()),
|
||||
get_json_sha256=sha(json.dumps(f["value"], ensure_ascii=False, indent=2).encode()),
|
||||
)
|
||||
)
|
||||
if isinstance(f["value"], str) and len(f["value"]) > 100:
|
||||
raw = f["value"]
|
||||
renders = [
|
||||
r
|
||||
for r in browser["text_renderings"]
|
||||
if r["kind"] == f["node_id"] + "." + f["field"]
|
||||
]
|
||||
assert len(renders) == 2 and all(
|
||||
r["rendered_utf8_sha256"] == sha(raw.encode()) for r in renders
|
||||
)
|
||||
source_texts.append(
|
||||
dict(
|
||||
node_id=f["node_id"],
|
||||
field=f["field"],
|
||||
characters=len(raw),
|
||||
LF=raw.count("\n"),
|
||||
CR=raw.count("\r"),
|
||||
tail_LF=raw.endswith("\n"),
|
||||
raw_sha256=sha(raw.encode()),
|
||||
report_json_sha256=sha(json.dumps(raw, ensure_ascii=False).encode()),
|
||||
decoded_sha256=sha(raw.encode()),
|
||||
browser_renderings=renders,
|
||||
)
|
||||
)
|
||||
history = next(f for f in b["fields"] if f["node_id"] == "245" and f["field"] == "videopreview")
|
||||
assert (
|
||||
history["value"]["params"]["score"] == "0"
|
||||
and type(history["value"]["params"]["frame_rate"]) is int
|
||||
)
|
||||
write(
|
||||
"rendered-text-sha256.json",
|
||||
dict(raw_json_decoded_separate=True, notes=texts, source_texts=source_texts),
|
||||
)
|
||||
write(
|
||||
"saved-value-evidence.json",
|
||||
dict(saved_entries=len(fields), fields=fields, history_nested_types_checked=True),
|
||||
)
|
||||
viewed = json.loads((OUT / "viewed-screenshots.json").read_bytes())
|
||||
write(
|
||||
"screenshot-review.json",
|
||||
dict(
|
||||
viewed=[dict(path=n, sha256=sha((BROWSER / n).read_bytes())) for n in viewed],
|
||||
total=len(list(BROWSER.glob("*.png"))),
|
||||
findings="代表默认用途、准确来源/两具体缺口/46无版本别名、两真LATENT/普通output、音频分叉/循环物理边/五完整注释/双历史实际查看;长文DOM/SHA不称逐字目验,无溢出,未改CSS/字体。",
|
||||
),
|
||||
)
|
||||
tests = int(re.search(r"(\d+) passed", (OUT / "singleloop-tests-first.txt").read_text())[1])
|
||||
closure = json.loads((OUT / "source-closure.json").read_bytes())
|
||||
frozen = json.loads((OUT / "baseline-frozen-files.json").read_bytes())
|
||||
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
|
||||
write(
|
||||
"validation-results.json",
|
||||
dict(
|
||||
base=BASE,
|
||||
backend_tests=tests,
|
||||
browser_assertions=browser["assertion_count"],
|
||||
browser_groups=browser["assertionGroups"],
|
||||
source_rows=len(rows),
|
||||
source_closure_files=closure["count"],
|
||||
accurate_nodes=42,
|
||||
unresolved_implementation_nodes=2,
|
||||
unknown_nodes=46,
|
||||
saved_entries=129,
|
||||
notes=5,
|
||||
screenshots=len(list(BROWSER.glob("*.png"))),
|
||||
viewed=len(viewed),
|
||||
backend_fixed_gets=backend["fixed_count"],
|
||||
browser_fixed_gets=browser["request_accounting"]["fixed_count"],
|
||||
backend_polling_gets=backend["polling_count"],
|
||||
browser_polling_gets=browser["request_accounting"]["polling_count"],
|
||||
fixture_interceptions=len(browser["interceptions"]),
|
||||
readiness_gets=1,
|
||||
forbidden_requests=0,
|
||||
frozen_baseline_files=frozen["count"],
|
||||
old_fixed_blocks=137,
|
||||
other_reviews=155,
|
||||
frontend_build="rerun this batch",
|
||||
full_browser="rerun this batch; no accumulation",
|
||||
upstream_executed=False,
|
||||
target_connected=False,
|
||||
),
|
||||
)
|
||||
print(
|
||||
"PASS actual GET/export and129 per-value types/canonical nested values; "
|
||||
"5 Notes and complete source text SHA"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user