from fractions import Fraction as Q from itertools import product def run(load,check): E=Q(25,23);reg=load('C286_DATA.json')['target_register'];coords={r['center'] for r in reg};noah_components={Q(r['center'])+e for r in reg if r['role']=='Noah birth' for e in [Q(-1,4),Q(1,4)]};rows=[];phase=[] d=load('C379_DATA.json') for k,row in enumerate(load('PREVIOUS_DATA.json')['rows']): V=row['Noah_pivot'];x=row['higher_Noah'];y=row['lower_Noah'];A=row['J_Flood_pivot'];B=row['P_Flood_pivot'];g=row['source_records']['lower_Noah']['gear'] lower=next(h for h in d['qualified_regular_hits'] if h['coordinate_tuple'][:4]==[A,B,y,x]);N=lower['coordinate_tuple'][4] upper=next(h for h in d['qualified_regular_hits'] if h['coordinate_tuple']==[A+215,B+215,y+215,x+215,N+215]);state=next(s for s in d['original_rectangle_hits'] if s['regular_input_Gear']==g) check('original source branch translation '+str(k),upper is not None and state['full430']==1) u=x+215;v=y+215;required=Q(25*u-23*v,2) check('unique translated E pivot absent '+str(k),required==V+215 and required not in coords) retained=V+E*(u-V);check('retaining old E pivot fails '+str(k),retained-v==Q(430,23)) S=state['cumulative_native_Shem']['coordinate'];q=S+1058 check('old and new Mirror cross spans '+str(k),A-S==N-q==17*529-215 and (A+215)-S==(N+215)-q==17*529) check('E held Noah already upper branch '+str(k),row['source_records']['held_Noah']['full430']==1 and row['source_records']['lower_Noah']['full430']==0 and N-V==435) for ex,ey in product([Q(-1,4),Q(1,4)],repeat=2): p=Q(25*(u+ex)-23*(v+ey),2);found=p in noah_components check('no phase source pivot '+str((k,ex,ey)),not found) phase.append({'row':k,'higher_Noah_offset':str(ex),'lower_Noah_offset':str(ey),'required_held_E_component':str(p),'source_member':found}) rows.append({'lower_branch':{'J':A,'P':B,'lower_Noah':y,'higher_Noah':x,'outer_SP_LXX_Noah':N,'held_E_MT_Noah':V},'upper_branch':{'J':A+215,'P':B+215,'lower_Noah':v,'higher_Noah':u,'outer_SP_LXX_Noah':N+215},'required_upper_E_pivot':str(required),'required_pivot_source_records':[r for r in reg if r['center']==required],'retained_pivot_output_residual':str(retained-v),'original_cumulative_Shem':S,'lower_cross_span':17*529-215,'upper_cross_span':17*529,'whole_source_loop_transports':False}) return {'step':'C398','rows':rows,'phase_trials':phase,'counts':{'translated_common_P_J_edges':2,'sourced_translated_E_pivots':0,'complete_translated_E_P_J_loops':0,'phase_pivot_trials':8,'phase_pivot_hits':0},'interpretation':'The common P/J edge translates+215 to the original17K branch, but its unique return-E pivots3271/3273 are absent. The original held MT E pivot is already in the upper full430 branch; translating it would go beyond the supplied two-branch source menu. Holding it fixed leaves430/23 error. No phase choice supplies the missing Noah pivot.'}