Files
aigc-home/docs/hel-892/zimage-document-evidence/source_closure.py
T
2026-10-31 08:35:25 +08:00

51 lines
1.6 KiB
Python

"List source texts and their identity/permission evidence, without self hashing."
import hashlib
import json
from build_definition import OUT, REF, REPO
def main():
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
paths = {REF / "sources.json"}
for e in rows:
paths.add((REF / e["local_file"]).resolve())
if not e["license_file"].startswith("未知"):
paths.add((REF / e["license_file"]).resolve())
if e["id"] == "litegraph":
continue
base = REF / e["identity_root"]
paths.update(
(base / (e["identity_key"] + suffix)).resolve()
for suffix in ["-commit.txt", "-tag.txt", "-tag.json", "-tree.json"]
)
result = []
for p in sorted(paths):
raw = p.read_bytes()
result.append(
dict(
path=str(p.relative_to(REPO)),
sha256=hashlib.sha256(raw).hexdigest(),
purpose="准确来源原文、许可或Git对象绑定;静态读取未执行",
)
)
(OUT / "source-closure.json").write_text(
json.dumps(
dict(
files=result,
count=len(result),
upstream_executed=False,
note="commit/tag字节和选定blob已重算;tree列表非完整树对象重哈希。未声称完整发布包SHA或安装。",
),
ensure_ascii=False,
indent=2,
)
+ "\n"
)
print("PASS source closure", len(result))
if __name__ == "__main__":
main()