from fractions import Fraction as Q def run(load,check): E=Q(25,23);J=Q(300,299);cum=load('C365_DATA.json')['cumulative_register'];rows=[];phase=[] def aff(a,k):return(k,(1-k)*a) def comp(a,b):return(a[0]*b[0],a[0]*b[1]+a[1]) def ids(x):return[i for i,r in enumerate(cum) if r['coordinate']==x] for k,state in enumerate(load('C379_DATA.json')['original_rectangle_hits']): g=state['regular_input_Gear'];S=state['cumulative_native_Shem']['coordinate'];row=next(r for r in load('C385_DATA.json')['rows'] if r['source_context_lifts'][0]['Noah_input_record']['full430']==1 and r['source_context_lifts'][0]['Noah_input_record']['gear']==g) A,B,x,y,N=row['original_tuple'];z=Q(row['E_image_input']);w=Q(row['E_image_output_with_next_Noah']);D=Q(row['required_J_pivot']);C=S+N;refl=(-Q(1),Q(C)) v={'Noah_center':N,'next_Noah_center':N+2,'J_Flood_pivot':A,'MT_Noah_input':x,'MT_Noah_output':y,'Shem_input':z,'Shem_output':w,'J_Shem_death_pivot':D};out=[] for name,p in v.items(): dest=C-p;found=ids(dest);expect=name not in ['Shem_input','Shem_output','J_Shem_death_pivot'] check('finite reflected membership '+str((k,name)),bool(found)==expect) out.append({'regular_point':name,'regular_coordinate':str(p),'reflected_coordinate':str(dest),'cumulative_record_indices':found,'source_member':bool(found)}) check('original cumulative repair recovered '+str(k),C-A==S+1058 and C-x==S+460 and C-y==S+458) check('new points shifted beyond menu '+str(k),C-z==S+500 and C-w==S+498 and C-D==S+1098) left=comp(aff(N+2,E),aff(A,J));right=comp(aff(D,J),aff(N,E)) reflected_left=comp(refl,comp(left,refl));reflected_right=comp(aff(C-D,J),aff(S,E)) check('reflected algebra exact '+str(k),left==right and reflected_left==reflected_right and reflected_left==comp(aff(S-2,E),aff(C-A,J))) check('new cumulative outer side1100 '+str(k),(C-D)-(S-2)==1100 and 1100-1058==42) for e in [Q(-1,4),Q(1,4)]: check('reflection reverses ancestry phase '+str((k,e)),C-(x+e)==(C-x)-e) for p in [z,w,D]: val=C-(p+e);found=[i for i,r in enumerate(cum) if val in [Q(r['coordinate'])-Q(1,4),Q(r['coordinate'])+Q(1,4)]] check('phase does not rescue missing source '+str((k,e,p)),not found) phase.append({'state':k,'regular_offset':str(e),'reflected_offset':str(-e),'new_images_source_members':False}) rows.append({'cumulative_index':state['cumulative_index'],'regular_input_Gear':g,'existing_corner_sum':C,'source_native_Shem':S,'reflected_points':out,'reflected_affine_coefficients':list(map(str,reflected_left)),'algebraic_identity':True,'cumulative_source_square_complete':False,'new_side':1100}) return {'step':'C389','rows':rows,'phase_tests':phase,'counts':{'original17K_exchanges':2,'reflected_point_slots':16,'admitted_reflected_point_slots':10,'missing_reflected_point_slots':6,'source_complete_cumulative_squares':0},'interpretation':'Existing corner exchange conjugates the regular affine identity exactly and recovers the known cumulative J repair. The new Shem-input, Shem-output and Shem-death images are absent from the frozen cumulative menu in both cases. Opposite ancestry phases do not rescue membership. The required1100 side exceeds2K by42; no cumulative endpoint or axis is adopted.'}