informed-decision/docs/evidence/2026-10-11-zlib-release-product-reference-confirmation/check_references.py
tegwick 312ab97e87 Prepare owner-reviewed zlib-only native release decision
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a126e1-76f8-7643-8cf3-e93336539ade
2026-10-11 12:37:05 +02:00

22 lines
3.4 KiB
Python

from pathlib import Path
import json,hashlib,sys,base64
H=lambda b:hashlib.sha256(b).hexdigest();O=Path('/tmp/infd-zlib-product-reference-confirmation-stage');S=Path('/tmp/infd-zlib-release-owner-packet-stage/informed-decision');P=S/'docs/evidence/2026-10-11-zlib-image-release'
oldm=Path('/tmp/infd-zlib-release-postcontract-stage/manifest.json');newm=Path('/tmp/infd-zlib-release-owner-packet-stage/manifest.json');oldraw=oldm.read_bytes();raw=newm.read_bytes();assert H(oldraw)=='767c6e93adfa1a844b1e25947f33e782b087a747452575f056b3df25bc88873c';assert H(raw)=='acb1262b56f10d117c702e62908db008c323a0acb5df4ed108d7868aa371bce9';old=json.loads(oldraw);new=json.loads(raw);assert len(old)==509 and len(new)==519
for e in new:assert H(Path(e['staged_path']).read_bytes())==e['staged_sha256']
by={e['path']:e for e in new};changed=[]
for e in old:
assert e['path'] in by
if by[e['path']]['staged_sha256']!=e['staged_sha256']:changed.append(e['path'])
diffraw=(P/'owner-packet-reference-diff.json').read_bytes();assert H(diffraw)=='e12cd9be56d785a55f3516716fb9ab9cbc7c1fa5c75b501fd890f584d49c49c1';diff=json.loads(diffraw);assert sorted(changed)==sorted(diff['changed_existing_paths']) and len(changed)==4 and 509-len(changed)==505
oldroot=Path('/tmp/infd-zlib-release-postcontract-stage/informed-decision/docs/evidence/2026-10-11-zlib-image-release');a=json.loads((oldroot/'memo.json').read_text());b=json.loads((P/'memo.json').read_text());assert [k for k in a if a[k]!=b[k]]==['packet'];assert b['packet'][:len(a['packet'])]==a['packet']
assert H((P/'memo.json').read_bytes())=='5dea0d404e4d13683fbf71d56273c06db7a6a916ab68759a90d7394005eee206';assert H((P/'lifecycle-commands.json').read_bytes())=='4cf81acb7d42f52d81f8ba624a6b2349a0b8948477a14c09bd069d2a4acab7cf'
sys.path.insert(0,'/home/worsch/informed-decision');from informed_decision.lifecycle_commands import decode_memo,decode_documents
from informed_decision.intake import SubmitterGrant,validate_submission
commands=json.loads((P/'lifecycle-commands.json').read_text());r=commands[0]['register'];memo=decode_memo(r['memo']);docs=decode_documents(r['documents'],memo);assert len(docs)==15 and len(memo.packet)==16;assert len(json.dumps(r).encode())==237367
validate_submission(json.loads((P/'intake.json').read_text()),submitter_id='state-hub',grant=SubmitterGrant('state-hub',frozenset({'decision-record'}),frozenset({'net-kingdom-admins'})))
content={d['digest']:base64.b64decode(d['content_base64'],validate=True) for d in r['documents']}
for item in diff['exact_attachments']:
bb=Path(item['source_path']).read_bytes();assert H(bb)==item['sha256'] and len(bb)==item['bytes'];assert content['sha256:'+item['sha256']]==bb
root=content['sha256:94d5757bfd612c489d419f421c0abbaf3d5a991cc1a49d04a33f957aed3ddd8a'].decode();assert '| 19 |' in root and 'Proposed only; no exception approved or used.' in root
result=dict(exact519_hashes_verified=True,original509_paths_preserved=True,changed_existing_paths=changed,unchanged_existing_paths=505,memo_only_packet_extension=True,exact_three_attachment_bytes_verified=True,root_row19_proposed_only=True,typed_memo_documents_intake=True,unique_contents=15,packet_labels=16,register_bytes=237367,body_headroom_bytes=262144-237367,executor_plan_render_runtime_unchanged=True,native_actions=False,human_approval=False)
(O/'validation.json').write_text(json.dumps(result,indent=2)+'\n');print('Exact519 reference diff, all attachment bytes, typed15contents/16labels and intake validate.')