15 lines
1.5 KiB
Python
15 lines
1.5 KiB
Python
from pathlib import Path
|
|
import hashlib,json,subprocess
|
|
p=Path(__file__).resolve().parent;owner=Path('/home/worsch/net-kingdom');m=json.loads((p/'manifest.json').read_text());r=json.loads((p/'coordinator-review.json').read_text());sha=lambda data:'sha256:'+hashlib.sha256(data).hexdigest()
|
|
if r['reviewed_postimages']!=m['postimages']:raise SystemExit('review source map differs')
|
|
for rel,expected in m['postimages'].items():
|
|
if sha((p/'postimages'/rel).read_bytes())!=expected:raise SystemExit('postimage drift '+rel)
|
|
target=owner/rel
|
|
if rel in m['preimages']:
|
|
if sha(target.read_bytes())!=m['preimages'][rel]:raise SystemExit('preimage race '+rel)
|
|
elif target.exists():raise SystemExit('unexpected existing target '+rel)
|
|
backup=p/'publication-backup';backup.mkdir(exist_ok=False);git=lambda *args:subprocess.check_output(['git','-C',str(owner),*args])
|
|
(backup/'brief.worktree').write_bytes((owner/'.custodian-brief.md').read_bytes());(backup/'brief.index').write_bytes(git('show',':.custodian-brief.md'));(backup/'index-record.txt').write_bytes(git('ls-files','--stage','.custodian-brief.md'));(backup/'status.txt').write_bytes(git('status','--porcelain=v1'));(backup/'work-records.preimage').write_bytes((owner/'WORK-RECORDS.md').read_bytes())
|
|
for rel in m['postimages']:
|
|
dest=owner/rel;dest.parent.mkdir(parents=True,exist_ok=True);dest.write_bytes((p/'postimages'/rel).read_bytes())
|
|
print('Integrated four exact reviewed postimages; original staged/working brief retained in private local backup.')
|