"""Freeze per-side expected complete DTOs from readonly native preflight, before HTTP."""
from pathlib import Path
import json,hashlib
from oracle_lib import expected
HERE=Path(__file__).resolve().parent;RUN=Path('/tmp/cdx-ai-api-customer-read12-20261011')
for lane in ['B','C']:
 p=RUN/f'preflight-{lane}';pre=json.loads((p/'preflight-read.json').read_text());cases=json.loads((p/'cases.json').read_text());out=expected(pre,cases);dst=p/'expected.json';assert not dst.exists();dst.write_text(json.dumps(out,ensure_ascii=False,indent=2)+'\n');dst.chmod(0o600)
 ready=p/'oracle-ready.json';ready.write_text(json.dumps({'expected_SHA':hashlib.sha256(dst.read_bytes()).hexdigest(),'source_oracle_SHA':hashlib.sha256((HERE/'oracle_lib.py').read_bytes()).hexdigest(),'cases':list(out),'HTTP':0,'DML':0})+'\n');ready.chmod(0o600)
 print(json.dumps({'lane':lane,'full_expected_DTOs':len(out),'classification':{k:v['classification'] for k,v in out.items()},'SQL':0,'HTTP':0},ensure_ascii=False))
