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

64 lines
2.1 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"] in ["essentials", "rgthree"]:
base = REF / e["identity_root"]
names = [e["id"] + "-registry.json", e["id"] + "-members.json"]
names += (
["essentials-source.tar.gz"]
if e["id"] == "essentials"
else ["rgthree-range-proof.json"]
)
paths.update((base / n).resolve() for n in names)
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"]
)
paths.update(p.resolve() for p in REF.glob("*registry*.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来自准确包采集记录,成员重哈希;包到Git未知,未安"
"装。"
),
),
ensure_ascii=False,
indent=2,
)
+ "\n"
)
print("PASS source closure", len(result))
if __name__ == "__main__":
main()