"""Prepare the exact QA code/build inventory; preserve sealed references and active files.""" from pathlib import Path import hashlib,json root=Path(__file__).resolve().parent.parent private=root/'storage/app/private/investmoz-v2/portal-audit' source=Path(json.loads((private/'portal-stability-latest.json').read_text())['source']) assert source.is_relative_to(private) old=root/'outputs/investmoz-opportunity-workflow-consolidated-final-20261011' prior=json.loads((old/'manifesto.json').read_text()) sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() assert sha(old/'manifesto.json')=='410bc74e6befde6e51a6e8afe8d55a699d600c1a857f1fc7d395baba30cd49ca' assert sha(old/'investmoz-workflow-8af63e2fe657.zip')=='feb7f4e8ae2608f08ef90d3a0acfbe71ba118480c967e784fa5037b645cc3403' names={n for n in prior['payload'] if n.startswith(('app/','resources/'))} names.update(['app/Services/VerifiedDocumentBinary.php','resources/js/pages/management/opportunity-resources.tsx']) code={n:sha(source/n) for n in sorted(names)} assert len(code)==14 build=json.loads((private/'functional-scope-production-build-20261011.json').read_text()) assert build['result']=='passed' and sha(source/'public/build/manifest.json')==build['manifest_sha256'] for n,h in json.loads((private/'functional-active-files-before-20261011.json').read_text()).items():assert sha(root/n)==h record={'code_files':code,'code_revision':hashlib.sha256(json.dumps(code,sort_keys=True,separators=(',',':')).encode()).hexdigest(),'production_manifest_sha256':build['manifest_sha256'],'previous_candidate':prior['revision'],'active_base_hashes':{n:sha(root/n) if (root/n).is_file() else None for n in code},'changed_from_previous':[n for n in code if prior['payload'].get(n)!=code[n]],'active_writes':0,'activation_ready':False} (private/'functional-delivery-scope-code-20261011.json').write_text(json.dumps(record,indent=2),encoding='utf8') print(json.dumps({k:v for k,v in record.items() if k not in ['code_files','active_base_hashes']}))