from fractions import Fraction as Q from itertools import product def run(load,check): cum=load('C365_DATA.json')['cumulative_register'];reg=load('C286_DATA.json')['target_register'];trials=[];hits=[];phases=[] def cm(role,c,k):return next(r for r in cum if r['role']==role and r['Cainan']==c and r['annual_index']==k) for old in load('C287_DATA.json')['rows']: if not old['complete']:continue i=old['i'];k=i+2;N=next(r for r in old['Noah_records'] if r['tradition']=='SP');e=int(N['rail']=='companion');g=N['gear'] def rm(t,role,c,terah,rail=None):return next(r for r in reg if r['tradition']==t and r['gear']==g and r['role']==role and r['Cainan']==c and r['Terah60']==terah and r['full430']==1 and r.get('rail')==rail) M=rm('MT','Noah birth',1,1);D=rm('SP','Noah death',0,0,N['rail']);B=rm('MT','Noah death',1,1);regular=[N,M,D,B];rv=[z['center'] for z in regular] X=cm('Noah birth',1,k);S=cm('Shem',1,k);check('original native seam '+str(i),S['coordinate']==old['S']) for j in range(8): Y=cm('Noah birth',0,j);Z=cm('Shem',0,j);src=[X,Y,S,Z];cv=[z['coordinate'] for z in src];cs=[a+b for a,b in zip(cv,rv)];ok=len(set(cs))==1 check('exact index condition '+str((i,j)),ok==(j==k-e)) record={'i':i,'native_index':k,'OFF_index':j,'rail':N['rail'],'cumulative_records':src,'regular_records':regular,'cumulative_partition':[cv[t+1]-cv[t] for t in range(3)],'regular_partition':[rv[t]-rv[t+1] for t in range(3)],'shape_exact':ok,'coordinate_sums':cs};trials.append(record) if ok: check('950 preserved '+str(i),cv[2]-cv[0]==cv[3]-cv[1]==rv[0]-rv[2]==rv[1]-rv[3]==950) check('matched partition '+str(i),record['cumulative_partition']==record['regular_partition']==[460-e,490+e,460-e]);hits.append(record) for u,v in product([-Q(1,4),Q(1,4)],repeat=2): residual=[Q(cs[0])-(a+u)-(b+v) for a,b in zip(cv,rv)];passphase=all(x==0 for x in residual) check('reversing phase '+str((i,u,v)),passphase==(v==-u));phases.append({'i':i,'cumulative_offset':str(u),'regular_offset':str(v),'fixed_center_reversal_exact':passphase,'residual':list(map(str,residual)),'same_C287_offset':u==v}) check('four source lifts',len(trials)==32 and len(hits)==4) check('no one reversal constant across retained rows',len({r['coordinate_sums'][0] for r in hits})==4) check('phase totals',len(phases)==16 and sum(r['fixed_center_reversal_exact'] for r in phases)==8 and not any(r['same_C287_offset'] and r['fixed_center_reversal_exact'] for r in phases)) return {'step':'C366','trials':trials,'matched_rows':hits,'phase_controls':phases,'counts':{'annual_controls':32,'matched_rectangles':4,'phase_controls':16,'opposite_phase_passes':8,'same_phase_passes':0},'source_rule':'j=k-e; e is SP companion indicator. Native and OFF biographies each retain950. Companion459 is460 plus annual-index difference-1, not a changed Cainan lifespan.','new_axis_adopted':False,'interpretation':'Source interval correspondences cover all four complete C287 rows, but their diagnostic reversal constants differ and their phase orientation reverses. They do not lift the original same-phase rectangle under one reflection.'}