Files
MeltMind/tools/build_o2a_review.py

38 lines
2.0 KiB
Python

"""Package only approved analytic O2-A evidence and required source dependencies."""
from pathlib import Path
import hashlib
import json
import shutil
import zipfile
def main():
root=Path.cwd(); out=root/'artifacts/o2a-transverse-2026-11-14'
dest=root/'artifacts/o2a-review-delivery-2026-11-14'
dest.mkdir(exist_ok=False)
contract=json.loads((out/'execution_contract.json').read_text())
include={Path(p) for p in contract['input_sha256']}
include.update(p.relative_to(root) for p in out.iterdir() if p.is_file())
include.update(Path(p) for p in ['tools/verify_o2a_results.py','tools/build_o2a_review.py','docs/o2a-transverse-results-2026-11-14.md'])
old=Path(contract['reuse_directory'])
include.update(old/f'z24_{rule}.npz' for rule in ['lumped_vertex','tetra_four_point'])
manifest=[]
for rel in sorted(include):
data=(root/rel).read_bytes()
assert len(data)<5_000_000,rel
manifest.append(dict(path=str(rel),bytes=len(data),sha256=hashlib.sha256(data).hexdigest()))
archive=dest/'MeltMind-O2A-20261114.zip'
with zipfile.ZipFile(archive,'x',zipfile.ZIP_DEFLATED,compresslevel=6) as z:
for row in manifest: z.write(root/row['path'],row['path'])
z.writestr('PACKAGE_MANIFEST.json',json.dumps(manifest,indent=2)+'\n')
(dest/'PACKAGE_MANIFEST.json').write_text(json.dumps(manifest,indent=2)+'\n')
for name in ['execution_contract.json','O2A_result.json','work_receipt.json','verification.json','regions.csv','centers.csv','endpoints.csv','run.log']:
shutil.copy2(out/name,dest/name)
shutil.copy2(root/'docs/o2a-transverse-results-2026-11-14.md',dest/'README.md')
hashes={p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(dest.iterdir()) if p.is_file()}
(dest/'SHA256SUMS').write_text(''.join(f'{digest} {name}\n' for name,digest in hashes.items()))
print(json.dumps(dict(files=len(manifest),archive_bytes=archive.stat().st_size,archive_sha256=hashes[archive.name],destination=str(dest)),indent=2))
if __name__=='__main__': main()