"""Assemble separate approved originals, product evidence and reproducible metadata.""" import argparse import hashlib import json import shutil import subprocess import zipfile from pathlib import Path parser = argparse.ArgumentParser() parser.add_argument("--approved", type=Path, required=True) parser.add_argument("--evidence", type=Path, required=True) parser.add_argument("--output", type=Path, required=True) parser.add_argument("--matrix-run", default="delivery") parser.add_argument("--states-run", default="default-verification") args = parser.parse_args() root = Path(__file__).resolve().parents[2] evidence = args.evidence.resolve() output = args.output.resolve() output.mkdir(parents=True, exist_ok=True) kit = output / "review" kit.mkdir(exist_ok=True) def copy(source, target): target = kit / target target.parent.mkdir(parents=True, exist_ok=True) shutil.copy2(source, target) for p in (args.approved / "四主题三窗口").rglob("*.png"): copy(p, Path("originals") / p.relative_to(args.approved / "四主题三窗口")) for name in [ "HEL-837-视觉规范-v2.md", "HEL-838-技术方案-v2.txt", "整合说明.txt", "HEL-837-交互样本-v2.html", ]: copy(args.approved / name, Path("originals") / name) for p in (evidence / args.matrix_run / "matrix").rglob("*.png"): copy(p, Path("product") / p.relative_to(evidence / args.matrix_run / "matrix")) for p in (evidence / args.states_run / "states").glob("*.png"): copy(p, Path("states") / p.name) for p in (evidence / "motion-hd/motion").glob("*.png"): copy(p, Path("motion") / p.name) for run, name in [(args.states_run, "interactions"), ("motion-hd", "motion-hd")]: for i, p in enumerate((evidence / run / "recordings").glob("*.webm")): copy(p, Path("recordings") / f"{name}-{i}.webm") for run, name in [ (args.matrix_run, "geometry.json"), (args.matrix_run, "token-comparison.json"), (args.states_run, "interaction-checks.json"), ("motion-hd", "motion-checks.json"), ("restart", "restart-check.json"), ]: copy(evidence / run / name, Path("metadata") / name) for name in [ "lint-840.log", "check-840.log", "webtest-840.log", "build-840.log", "regression-840.log", "llm-regression-840.log", "test-840-py311.log", "ruff-840.log", "capture-840.log", "default-ui-840.log", "motion-840.log", ]: copy(root / name, Path("logs") / name) for run in dict.fromkeys([args.matrix_run, args.states_run, "motion-hd"]): copy(evidence / run / "server.log", Path("logs") / f"{run}-server.log") copy( evidence / run / "fixture/provider.jsonl", Path("logs") / f"{run}-provider.jsonl", ) copy(evidence / "restart/restart-server.log", Path("logs/restart-server.log")) for p in (root / "scripts/hel840").glob("*"): if p.is_file(): copy(p, Path("reproduction/scripts/hel840") / p.name) copy(root / "docs/changelogs/2026-10-24-hel840-v2.md", Path("实现与自测说明.md")) # Fake-only snapshots; never include daemon roster/state or installed configuration. for p in (evidence / args.states_run / "fixture/assets/uploads").glob("*"): if p.is_file(): copy(p, Path("reproduction/fixture/assets/uploads") / p.name) for name in ["before-empty.db", "calliope_config.json"]: copy( evidence / args.states_run / "fixture" / name, Path("reproduction/fixture") / name, ) head = subprocess.check_output( ["git", "rev-parse", "HEAD"], cwd=root, text=True ).strip() base = "415fb782362b2ac5b725e312ecbdbc9a782e9aa3" patch = subprocess.check_output(["git", "diff", "--binary", base, head], cwd=root) (kit / "reproduction/changes.patch").write_bytes(patch) manifest = { "head": head, "base": base, "branch": subprocess.check_output( ["git", "branch", "--show-current"], cwd=root, text=True ).strip(), "approved_archive_sha256": "dfe02579065200e8f0edaa3114709fc44286f232fdaa76c34acd3f3814523508", "counts": { "original_matrix": 60, "product_matrix": 60, "interaction_states": len(list((kit / "states").glob("*.png"))), "motion_stills": len(list((kit / "motion").glob("*.png"))), }, "data_mapping": { "projects": "5 fixture projects matching loaded/covered/placeholder/completed states; W01 adds 7 long titles; W02 deletes only fixture projects via real API.", "models": "3 fixture profiles; first 2 probed by real settings test API; third untested. Translation follows active, polish assigned separately.", "media": "Generated QA files decoded in browser; one valid 69-byte PNG, corrupt PNG, and real WebM. No product hardcoded samples.", "queue": "20 real fixture DB rows, paused worker; 12 done plus running/pending/failed/cancelled. No GPU calls.", "originals": "Approved design originals remain unchanged; media/text/address/latency data differs, so pixel equality is not claimed.", }, "files": {}, } for p in kit.rglob("*"): if p.is_file(): manifest["files"][str(p.relative_to(kit))] = hashlib.sha256( p.read_bytes() ).hexdigest() (kit / "metadata/manifest.json").write_text( json.dumps(manifest, ensure_ascii=False, indent=2) ) (kit / "index.html").write_text( """
左:批准原稿;右:本地构建实际产品,经真实前后端与 HTTP 假服务取数。项目、图片、地址和计数为分别保留的数据,不声称逐像素相同。对比布局、样式和操作状态;实际 DOM、字体/颜色、token 核对、交互和进程重启记录见 metadata,脚本见 reproduction。最终部署由总工独立重拍。
版本 / 数据映射 / 哈希清单 · 实际产品 DOM · 原件 token 核对 · 48 项交互断言 · 九组动效 / 双环记录 · 真实进程重启
""", encoding="utf-8", ) for path, source in [ (output / "HEL-840-原样本与实际产品证据.zip", kit), (output / "HEL-840-前端构建.zip", root / "calliope-web/build"), ]: with zipfile.ZipFile( path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=6 ) as archive: for p in source.rglob("*"): if p.is_file(): archive.write(p, p.relative_to(source)) print( json.dumps( { "head": head, "counts": manifest["counts"], "artifacts": [ { "name": p.name, "bytes": p.stat().st_size, "sha256": hashlib.sha256(p.read_bytes()).hexdigest(), } for p in output.glob("*.zip") ], }, ensure_ascii=False, ) )