159 lines
7.9 KiB
Python
159 lines
7.9 KiB
Python
"""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(
|
|
"""<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>HEL-840 原件 / 实际产品对照</title><style>body{margin:20px;background:#10131a;color:#eee;font:14px system-ui}select{margin:8px;padding:8px}main{display:grid;grid-template-columns:1fr 1fr;gap:12px}img{width:100%;border:1px solid #454b58}a{color:#a8d7ff}p{max-width:1100px;line-height:1.7}h2{font-size:15px}</style><h1>HEL-840 · 原件与实际产品</h1><p>左:批准原稿;右:本地构建实际产品,经真实前后端与 HTTP 假服务取数。项目、图片、地址和计数为分别保留的数据,不声称逐像素相同。对比布局、样式和操作状态;实际 DOM、字体/颜色、token 核对、交互和进程重启记录见 metadata,脚本见 reproduction。最终部署由总工独立重拍。</p><select id="theme"><option>night</option><option>day</option><option>grade</option><option>bluehour</option></select><select id="size"><option>1440x900</option><option>1366x768</option><option>1280x720</option></select><select id="page"><option>01-工作室</option><option>02-素材库</option><option>03-模型连接</option><option>04-创作台翻译结果</option><option>05-设置</option></select><main><section><h2>批准原件</h2><img id="original"></section><section><h2>实际产品</h2><img id="product"></section></main><p><a href="metadata/manifest.json">版本 / 数据映射 / 哈希清单</a> · <a href="metadata/geometry.json">实际产品 DOM</a> · <a href="metadata/token-comparison.json">原件 token 核对</a> · <a href="metadata/interaction-checks.json">48 项交互断言</a> · <a href="metadata/motion-checks.json">九组动效 / 双环记录</a> · <a href="metadata/restart-check.json">真实进程重启</a></p><script>function show(){const path=theme.value+'/'+page.value+'-'+size.value+'.png';original.src='originals/'+path;product.src='product/'+path}document.querySelectorAll('select').forEach(s=>s.onchange=show);show()</script></html>""",
|
|
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,
|
|
)
|
|
)
|