Files
digital-drosophila/tools/publish_phase4ad.py
T
2026-09-30 07:23:09 +08:00

36 lines
1.8 KiB
Python

"""Publish sealed new-branch evidence only; never copy environment or bulk states."""
import json
from pathlib import Path
import shutil
import sys
ROOT=Path('/data/digital-drosophila')
MODEL=ROOT/'models/male-cns-lif/author-semantics-lab-v1'
EXP=ROOT/'experiments/phase4ad-author-semantics'
sys.path.insert(0,str(MODEL))
from context import digest,save,check_prereg
sys.path.insert(0,str(ROOT/'models/male-cns-lif/terminal-scope-diagnostic-v1'))
from diagnostic import manifest_check
check_prereg()
verification={str(p.relative_to(ROOT)):manifest_check(p,digest) for p in (MODEL,EXP)}
assert all(v['pass'] for v in verification.values())
registry=ROOT/'registry/phase4ad-author-semantics';registry.mkdir(exist_ok=False)
records=[]
manifest=json.loads((EXP/'manifest.json').read_text())
paths=[EXP/row['path'] for row in manifest['files']]+[EXP/'manifest.json',EXP/'checksums.sha256']
for p in paths:
assert '.venv' not in p.parts and '__pycache__' not in p.parts
external=p.parent==EXP/'external-resources'
if p.stat().st_size>4*1024**2:continue
if p.suffix not in ('.json','.csv','.md','.sha256') and not external:continue
dst=registry/'evidence'/p.relative_to(EXP);dst.parent.mkdir(parents=True,exist_ok=True)
with p.open('rb') as src,dst.open('xb') as out:shutil.copyfileobj(src,out)
assert digest(p)==digest(dst)
records.append(dict(source=str(p.relative_to(ROOT)),copy=str(dst.relative_to(registry)),sha256=digest(p),bytes=p.stat().st_size))
save(registry/'evidence-index.json',records)
save(registry/'seal-verification.json',verification)
target=ROOT/'docs/progress/phase4ad-author-semantics.md'
with (EXP/'REPORT.md').open('rb') as src,target.open('xb') as out:shutil.copyfileobj(src,out)
print('Published',len(records),'small evidence records; no bulk states, datasets or environment copied')