"""Close only referenced exact text, identity metadata, licenses and source graph.""" import hashlib import json from build_definition import OUT, PATHS, REF, REPO def main(): manifest = json.loads((REF / "sources.json").read_bytes())["sources"] paths = { REPO / PATHS[0], REF / "sources.json", OUT / "independent-inventory.json", OUT / "expected-edges.json", OUT / "source-check.json", OUT / "exact-source-check.json", OUT / "identity-gaps.json", } for e in manifest: p = (REF / e["local_file"]).resolve() assert hashlib.sha256(p.read_bytes()).hexdigest() == e["sha256"] paths.add(p) if not e["license_file"].startswith("未知"): paths.add((REF / e["license_file"]).resolve()) if e.get("identity_root"): root = (REF / e["identity_root"]).resolve() key = e.get("identity_key", e["id"]) for suffix in ["-tree.json", "-commit.txt", "-commit.json", "-tag.txt", "-tag.json"]: p = root / (key + suffix) if p.is_file(): paths.add(p) if e.get("canonical_identity_record"): paths.add((REF / e["canonical_identity_record"]).resolve()) # This batch's bounded acquisition/redirect/range/gap records, not old unrelated code. for p in REF.iterdir(): if p.is_file() and "__" not in p.name: paths.add(p) files = [] for p in sorted(paths): assert p.is_file() files.append( dict( path=str(p.relative_to(REPO)), sha256=hashlib.sha256(p.read_bytes()).hexdigest(), purpose="本图准确必要源码/直接依赖/许可/身份元数据或原件与具体协议缺口;只静态审计", ) ) data = dict( count=len(files), files=files, implementation_sources=len(manifest), accurate_instances=42, unresolved_instances=2, unknown_instances=46, upstream_executed=False, scope=( "准确声明逐实例;未取得候选整包/模型/媒体/运行库。" "rgthree/VHS仅发布成员;LiteGraph为同树内置并另列许可;Git/整包未知分列。" ), ) (OUT / "source-closure.json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n") print("PASS closed necessary sources and metadata", len(files), "source rows", len(manifest)) if __name__ == "__main__": main()