Files
aigc-home/docs/hel-892/singleloop-document-evidence/render_report.py
T
2026-11-01 17:00:01 +08:00

142 lines
5.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"Offline batch evidence tooling; no upstream execution."
from __future__ import annotations
import hashlib
import json
from pathlib import Path
OUT = Path(__file__).resolve().parent
def main():
lines = [
"# 单人循环官流数字人固定参考中文说明",
"",
"新增129原保存条目/五完整注释,无具名;逐实例准确类与无版本别名缺口分列。",
"旧137块8351条目/241注释冻结,累计138参考8480条目/246注释;155定稿/实跑/新增转换0。",
"",
"完整prompt/标题/模型名只原数据,不执行或认证模型性质/人物/素材/目标环境。",
"",
]
index = []
for i in range(1):
b = json.loads((OUT / f"definition-{i}.json").read_bytes())
lines += [
"## " + Path(b["source_path"]).stem,
"",
b["user_overview"],
"",
b["notice"],
"",
"源路径:`" + b["source_path"] + "`",
"",
"SHA1:" + b["source_sha1"],
"",
"原字节SHA256:" + b["source_sha256"],
"",
"规范全图SHA256:" + b["canonical_sha256"],
"",
*[v + "\n" for v in b["versions"]],
"### 具体连线与处理条件",
"",
"```json",
json.dumps(b["flow"], ensure_ascii=False, indent=2),
"```",
"",
"### 使用与核对",
"",
*[v + "\n" for v in b["steps"]],
"### 逐保存位置说明",
"",
]
for j, f in enumerate(b["fields"], 1):
lines += [
f"#### {j}. 节点{f['node_id']} · {f['label']}({f['field']})",
"",
f["effect"],
"",
"```json",
json.dumps(f["value"], ensure_ascii=False, indent=2),
"```",
"",
(f"类:{f['class_type']};JSON类型:{f['json_type']};角色:{f['role']}。"),
"",
"源保存位置:`" + f["pointer"] + "`;源输入口:`" + f["input_pointer"] + "`",
"",
"具名保存位置:`"
+ f.get("named_pointer", "原件无具名保存,不造指针")
+ "`;作用域:"
+ f["scope"],
"",
"定义默认:" + f["schema_default"] + ";单位:" + f["unit"],
"",
"范围/条件:" + f["limits"],
"",
f["execution_note"],
"",
"依据:",
]
for k in f["evidence"]:
e = b["sources"][k]
lines += [
(
f"- [{k}] {e['claim']};"
f"{e['file']} {e['lines'][0]}~{e['lines'][1]}行;"
f"commit {e['commit']};"
f"SHA256 {e['sha256']};"
f"{e['url']}"
)
]
if "named_value" in f and f.get("named_value", "missing:原具名键缺失") != f["value"]:
lines += [
"具名保存完整形态(与位置列表分开保留):",
"",
"```json",
json.dumps(
f.get("named_value", "missing:原具名键缺失"), ensure_ascii=False, indent=2
),
"```",
"",
]
lines += [""]
lines += ["### 零保存节点与源注释", ""]
for z in b["zero_saved_nodes"]:
lines += [z["node_id"] + " " + z["class_type"] + ":" + z["effect"], ""]
for n in b["comments"]:
lines += [
"节点" + n["node_id"] + ",位置`" + n["pointer"] + "`",
"",
n["meaning"],
"",
"```json",
json.dumps(n["text"], ensure_ascii=False, indent=2),
"```",
"",
]
lines += ["### 固定原件索引", ""]
for k, e in enumerate(b["sources"]):
data = (OUT / e["local_file"]).read_bytes()
assert hashlib.sha256(data).hexdigest() == e["sha256"]
lines += [
(
f"{k}. {e['claim']};"
f"{e['file']} 第{e['lines'][0]}~{e['lines'][1]}行;"
f"提交{e['commit']};"
f"SHA256 {e['sha256']};"
f"{e['url']}"
),
"",
]
index.append(dict(document=b["source_path"], **e))
(OUT.parent / "单人循环官流数字人固定参考中文说明.md").write_text(
"\n".join(lines).rstrip() + "\n"
)
(OUT / "fixed-source-index.json").write_text(
json.dumps(index, ensure_ascii=False, indent=2) + "\n"
)
if __name__ == "__main__":
main()