the-custodian/docs/changes/netkingdom-target-2026-10-16/browser-adapter-next/integrate_r3.py
codex b53eed4073
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
Reject generated-only commits / generated-commit-guard (push) Successful in 13s
docs: preserve reviewed NetKingdom session artifacts
2026-11-01 22:46:55 +01:00

28 lines
2.1 KiB
Python

from pathlib import Path
import hashlib,json,subprocess
packet=Path(__file__).resolve().parent
owner=Path('/home/worsch/net-kingdom')
manifest=json.loads((packet/'manifest.json').read_text())
review=json.loads((packet/'coordinator-review-r3.json').read_text())
sha=lambda data:'sha256:'+hashlib.sha256(data).hexdigest()
if sha((packet/'manifest.json').read_bytes()) != review['manifest_sha256']:raise SystemExit('review manifest drift')
for rel,expected in manifest['postimages'].items():
if sha((packet/'postimages'/rel).read_bytes()) != expected: raise SystemExit('postimage drift '+rel)
current=owner/rel
if rel in manifest['preimages']:
if sha(current.read_bytes()) != manifest['preimages'][rel]:raise SystemExit('preimage drift '+rel)
elif current.exists():raise SystemExit('unexpected existing path '+rel)
backup=packet/'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 manifest['postimages']:
data=(packet/'postimages'/rel).read_bytes()
if rel.startswith('workplans/'):
data=data.replace(b'Exact root review/publication receipts are required on integration.',b'Independent root source review: Custodian browser-adapter-next/coordinator-review-r3.json. Source integration and normal publication/synchronization receipts: Custodian browser-adapter-next/canonical-integration.json. These receipts supply no other-owner assent or native authority.')
dest=owner/rel;dest.parent.mkdir(parents=True,exist_ok=True);dest.write_bytes(data)
(packet/'integrated-source-hashes.json').write_text(json.dumps({rel:sha((owner/rel).read_bytes()) for rel in manifest['postimages']},indent=2)+'\n')
print('Integrated four reviewed source files; retained exact brief/index and work-record preimages.')