the-custodian/docs/changes/netkingdom-target-2026-10-17/publish_rollout_checkpoint.py

19 lines
1.8 KiB
Python

"""Publish explicit rollout/repair evidence while retaining all unrelated work."""
from pathlib import Path
import hashlib,json,subprocess
root=Path('/home/worsch/the-custodian');base=Path(__file__).resolve().parent;backup=base/'custodian-publication-backup'
def git(*a):return subprocess.check_output(['git','-C',str(root),*a],stderr=subprocess.PIPE)
manifest=json.loads((base/'rollout-publication-inputs.json').read_text());paths=[r['path'] for r in manifest['files']]+[str((base/'rollout-publication-inputs.json').relative_to(root))]
assert git('rev-parse','HEAD').decode().strip()=='f8c7dfa2a9c7919879b62c77eb39582b3e23654e'
for r in manifest['files']:assert hashlib.sha256((root/r['path']).read_bytes()).hexdigest()==r['sha256'],r['path']
originals=json.loads((backup/'originals.json').read_text());other=json.loads((backup/'other-dirty-hashes.json').read_text())
def check():
for name,index in originals.items():
assert (root/name).read_bytes()==(backup/(name+'.worktree')).read_bytes()
assert git('ls-files','--stage','--',name).decode()==index
assert all(hashlib.sha256((root/name).read_bytes()).hexdigest()==pin for name,pin in other.items())
check();git('add','--',*paths)
r=subprocess.run(['git','-C',str(root),'commit','--only','-m','Record verified receiver rollout and frozen-binding guard successor','--',*paths],capture_output=True,text=True,timeout=240)
head=git('rev-parse','HEAD').decode().strip();receipt={'status':'committed' if r.returncode==0 else 'commit-refused','head':head,'exit_code':r.returncode,'paths':paths,'stdout':r.stdout,'stderr':r.stderr,'unrelated_work_preserved':True}
(base/'rollout-checkpoint-commit.json').write_text(json.dumps(receipt,indent=2)+'\n');check()
print(json.dumps({k:receipt[k] for k in ['status','head','exit_code','unrelated_work_preserved']}));raise SystemExit(r.returncode)