"""Exact finite transport of C269 closing rectangle into C266's local display.""" from pathlib import Path from fractions import Fraction as F import argparse,hashlib,json,csv ROOT=Path(__file__).resolve().parents[1] p=argparse.ArgumentParser();p.add_argument('--output',type=Path,default=ROOT/'evidence') OUT=p.parse_args().output;OUT.mkdir(parents=True,exist_ok=True) checks=[] def check(name,ok): if not ok:raise AssertionError(name) checks.append(name) def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() def read(name):return json.loads((ROOT/'sources'/name).read_text()) def dump(name,o):(OUT/name).write_text(json.dumps(o,indent=2,ensure_ascii=False,default=str)+'\n') def pair(x):return [F(x)-F(1,4),F(x)+F(1,4)] def apply(a,x):return a[0]*x+a[1] def compose(a,b):return (a[0]*b[0],a[0]*b[1]+a[1]) def label(x): x=F(x);part=x%1 check('physical quarter-year '+str(x),part in [F(1,4),F(3,4)]) season='n' if part==F(1,4) else 't' year=(x+(F(3,4) if season=='n' else F(1,4))) if x>0 else ((F(1,4) if season=='n' else F(3,4))-x) check('nonzero civil year '+str(x),year.denominator==1 and year>0) return f'AD {year}{season}' if x>0 else f'{year}{season} BC' for name,row in json.loads((ROOT/'SOURCE_MANIFEST.json').read_text()).items(): f=ROOT/'sources'/name;check('frozen '+name,sha(f)==row['sha256'] and f.stat().st_size==row['bytes']) prev=read('C269_CERTIFICATE.json') for name,key in [('C269_REPORT.md','report_sha256'),('C269_CHECKPOINT.md','checkpoint_sha256'),('C269_RESULTS.json','results_sha256')]:check('C269 certificate '+name,sha(ROOT/'sources'/name)==prev[key]) for name,h in [('FILE_18.md','68301ab760bfbe2e874aedc5c8d943ced7a6219d34bc2859332a70713f9630d5'),('FILE_09.md','45851004c5864229ebf6a896f9099819a08d8926715d3e97e4bc3985c4a3876e')]:check('controlling '+name,sha(ROOT/'sources'/name)==h) rect=read('C269_RECTANGLE.json');points=rect['source_centers'];src=rect['source_records'] check('fixed closing rectangle',points=={'Shem_close':-5883,'Flood_close':-5283,'SP_G3_Flood_start':3110,'SP_G3_primary_Noah_birth':3710}) d=F(rect['translation']);check('retained17K translation',d==17*529==8993) T=(F(1),d);Ti=(F(1),-d);M=(F(-1),F(0));J=(F(-1),F(2));eta=(F(1000),F(-1000)) cf=(F(1),F(src['Flood_close']['translation'])) cs=(F(-1),-F(src['Shem_close']['translation'])) rf=compose(cf,Ti);rs=compose(cs,Ti) check('cumulative maps retained',cf==(1,5290) and cs==(-1,-5888)) check('induced maps derived',rf==(1,-3703) and rs==(-1,3105)) check('positive commutation coefficients',compose(rf,T)==cf) check('negative commutation coefficients',compose(rs,T)==cs) check('induced shifts difference',3703-3105==5888-5290==598) check('transport slopes unit magnitude',rf[0]==1 and rs[0]==-1) events=read('C01_RESULTS.json')['events'];check('held register size',len(events)==48) for name,expected in [('SP_G3_primary_Noah_birth',('SP','Noah birth',3,'primary',3710)),('SP_G3_Flood_start',('SP','Flood start',3,None,3110))]: e=src[name] check('existing source '+name,e in events and tuple(e[k] for k in ['tradition','role','gear','rail','BC_Nisan'])==expected) classified=read('C267_CLASSIFICATION.json');known={int(row['marker']):row for row in classified} ledger=[];branches=[] for cname,rname,C,R in [('Flood_close','SP_G3_primary_Noah_birth',cf,rf),('Shem_close','SP_G3_Flood_start',cs,rs)]: q=F(points[cname]);y=F(points[rname]);e=src[rname] check('source center correspondence '+cname,apply(T,q)==y) local_center=apply(C,q) check('transported center '+rname,apply(R,y)==local_center==src[cname]['pair_center']) out=[] for index,qphase in enumerate(pair(q)): yphase=apply(T,qphase);x=apply(C,qphase);z=apply(R,yphase);bc_original=apply(M,yphase);marker=apply(eta,x) check(cname+' component commutation '+str(index),z==x) check(cname+' regular reflected component '+str(index),yphase==pair(y)[index]) check(cname+' original BC membership '+str(index),bc_original in pair(-y)) check(cname+' retainedC267 component '+str(index),marker in known and x==F(known[int(marker)]['preimage'])) row={'cumulative_role':cname,'cumulative_source_phase':label(qphase),'cumulative_coordinate':qphase,'translation':d,'regular_reflected_phase':label(yphase),'regular_reflected_coordinate':yphase,'regular_original_BC_phase':label(bc_original),'regular_source':e,'induced_map':R,'local_coordinate':x,'local_physical_phase':label(x),'eta':marker,'component_order_reversed':R[0]<0} ledger.append(row);out.append(x) check(cname+' exact local phase set',sorted(out)==pair(local_center)) check(cname+' half-year width preserved',abs(out[1]-out[0])==F(1,2)) check(cname+' orientation explicit',(out[1]>out[0])==(R[0]>0)) branches.append({'cumulative_role':cname,'regular_role':rname,'cumulative_map':C,'induced_regular_map':R,'center':local_center,'raw_component_order':out,'chronological_components':sorted(out),'phase_restoration_used':False}) by_marker={int(r['eta']):r for r in ledger} desired={5750:('5284t BC','AD 3710t','3710n BC','AD 7t'),6250:('5283n BC','AD 3711n','3711t BC','AD 8n'),-6250:('5883n BC','AD 3111n','3111t BC','6t BC'),-5750:('5884t BC','AD 3110t','3110n BC','5n BC')} for marker,labels in desired.items(): r=by_marker[marker] check('four-way source labels '+str(marker),tuple(r[k] for k in ['cumulative_source_phase','regular_reflected_phase','regular_original_BC_phase','local_physical_phase'])==labels) check('complete signed bracket',sorted(by_marker)==[-6250,-5750,5750,6250]) check('Key ratio retained',F(6250,5750)==F(25,23)) check('direct originalBC Noah map',compose(rf,M)==(-1,-3703)) check('direct originalBC Flood map',compose(rs,M)==(1,3105)) # Source600 relation induces the same J1 reflection, component by component. check('bilateral relation coefficients',compose(rs,(F(1),F(-600)))==compose(J,rf)) for delta in [F(-1,4),F(0),F(1,4)]: check('same-phase600 inducesJ1 '+str(delta),apply(rs,F(3110)+delta)==apply(J,apply(rf,F(3710)+delta))) check('chart signs underJ1 '+str(delta),apply(eta,apply(rs,F(3110)+delta))==-apply(eta,apply(rf,F(3710)+delta))) # Retained internal598+2 member follows the Flood-source branch only. c=F(rect['internal598plus2']['cumulative']);n=F(rect['internal598plus2']['regular']) check('inherited intermediate translation',apply(T,c)==n==3708) check('intermediate correct branch',apply(cf,c)==apply(rf,n)==5) check('pre-reflection co-location retains roles',-apply(cs,F(-5883))==apply(cf,c)==5) check('intermediate branch swap fails',apply(rs,n)==-603 and apply(rs,n)!=5) for delta in [F(-1,4),F(1,4)]:check('intermediate phase transport '+str(delta),apply(rf,n+delta)==apply(cf,c+delta)) # Full bilateral span accounting in the fixed display. lo_outer=F(-21,4);lo_inner=F(-19,4);hi_inner=F(27,4);hi_outer=F(29,4) check('same-season bilateral widths',[hi_inner-lo_outer,hi_outer-lo_inner]==[12,12]) check('inner and outer cross-season widths',[hi_inner-lo_inner,hi_outer-lo_outer]==[F(23,2),F(25,2)]) check('scaled bilateral widths',[1000*(hi_inner-lo_inner),12000,1000*(hi_outer-lo_outer)]==[11500,12000,12500]) # A hypothetical common affine map through both centers cannot carry both phase pairs. slope=F(7-(-5),3710-3110) check('common-center affine slope diagnostic',slope==F(1,50)) check('single-map half-year mismatch',slope*F(1,2)==F(1,100) and slope*F(1,2)!=F(1,2)) check('branch maps distinct',rf!=rs) dump('INDUCED_MAPS.json',{'correspondence':T,'inverse_correspondence':Ti,'cumulative_Flood_map':cf,'cumulative_reflected_Shem_map':cs,'regular_reflected_Noah_map':rf,'regular_reflected_Flood_map':rs,'direct_originalBC_Noah_map':compose(rf,M),'direct_originalBC_Flood_map':compose(rs,M),'coefficient_convention':'(slope,intercept)','new_fitted_scale':False}) dump('COMPONENT_LEDGER.json',ledger) dump('TRANSPORT_CERTIFICATE.json',{'branches':branches,'positive_identity':'R_Noah(T8993(q))=q+5290','negative_identity':'R_Flood(T8993(q))=-(q+5888)','bilateral_identity':'R_Flood(y-600)=J1(R_Noah(y))','intermediate':{'cumulative':c,'regular_reflected':n,'local':5,'branch':'cumulativeFlood / regularNoah','wrong_branch_image':-603},'phase_restoration_used':False}) dump('LIMITS_AND_SPANS.json',{'same_season_bilateral_width':12,'inner_cross_season_width':F(23,2),'outer_cross_season_width':F(25,2),'scaled_widths':[11500,12000,12500],'common_affine_center_fit_slope':slope,'resulting_halfyear_width':F(1,100),'common_map_admitted':False,'source_domain':'C269 closing rectangle and its inherited3708 intermediate; no new Gear/companion campaign','source_status':'dependent transport of an existing source correspondence, not an independent witness or universal chronology action'}) dump('RESULTS.json',{'step':'C270','status':'passed','check_count':len(checks),'checks':checks,'main_result':'Induced SP G3 maps reproduce every local LXX closing phase and signed5750/6250 marker using derived translations and reflection only; role-dependent branches preserve source lineage','canonical_sources_modified':False,'prior_graph_modified':False}) with (OUT/'COMPONENT_LEDGER.csv').open('w',newline='') as f: w=csv.writer(f);keys=['cumulative_source_phase','regular_original_BC_phase','regular_reflected_phase','local_physical_phase','local_coordinate','eta'] w.writerow(keys) for r in sorted(ledger,key=lambda r:r['eta']):w.writerow([r[k] for k in keys]) print(json.dumps({'step':'C270','status':'passed','checks':len(checks),'output_files':6}))