from fractions import Fraction as Q def run(load,check): reg=load('C286_DATA.json')['target_register'];cum=load('C365_DATA.json')['cumulative_register'];rc={r['center'] for r in reg};cc={r['coordinate'] for r in cum};rows=[];slots=[];reflections=[] common=next(f for f in load('C378_DATA.json')['fields'] if f['field']=='regular')['hits'] for gi,g in enumerate(load('C392_DATA.json')['graphs']): N=g['Noah_pivot'];units=[e for e in g['edges'] if e['input_distance_from_Noah']==23 and e['output_distance_from_Noah']==25] for e in units: x,y=e['input'],e['output'];gear=next(r['gear'] for r in g['pivot_contexts'] if r['tradition']=='SP') check('source E primitive '+str(N),N+Q(25,23)*(x-N)==y and y==N-215+130+60 and x==y+2) tests=[] for label,u,v in [('forward_E',x,y),('reverse_E',y,x)]: h=v-u for op,den in [('P',69),('J',299)]: a=u-den*h;ids=[i for i,r in enumerate(reg) if r['center']==a];expected=label=='reverse_E' and op=='J' check('unique pivot membership '+str((N,label,op)),bool(ids)==expected) if ids: check('typed return J Flood '+str(N),len(ids)==2 and all(reg[i]['role']=='Flood start' and reg[i]['tradition'] in ['SP','LXX'] and reg[i]['gear']==gear+1 and reg[i]['Cainan']==1 and reg[i]['Terah60']==1 and reg[i]['full430']==0 for i in ids)) tests.append({'orientation':label,'operator':op,'input':u,'output':v,'gain':h,'unique_required_pivot':a,'source_record_indices':ids,'source_records':[reg[i] for i in ids]}) check('not an earlier common P J edge '+str(N),not any(h['input'] in [x,y] and h['output'] in [x,y] for h in common)) state=next(s for s in load('C379_DATA.json')['original_rectangle_hits'] if s['regular_input_Gear']==gear);S=state['cumulative_native_Shem']['coordinate'];C=S+N;A=y-598 images={'held_Noah':C-N,'E_input':C-x,'E_output':C-y,'return_J_Flood':C-A} check('existing exchange source obstruction '+str(N),images['held_Noah'] in cc and all(images[k] not in cc for k in ['E_input','E_output','return_J_Flood'])) component_menu={Q(v)+off for v in cc for off in [Q(-1,4),Q(1,4)]} check('phase ancestry cannot supply absent images '+str(N),all(Q(images[k])-off not in component_menu for k in ['E_input','E_output','return_J_Flood'] for off in [Q(-1,4),Q(1,4)])) reflections.append({'Noah_pivot':N,'existing_corner_sum':C,'cumulative_native_Shem':S,'reflected_coordinates':images,'only_held_pivot_sourced':True}) rows.append({'Noah_pivot':N,'Noah_pivot_records':g['pivot_contexts'],'E_input':x,'E_output':y,'input_source_records':[reg[i] for i in e['input_record_indices']],'output_source_records':[reg[i] for i in e['output_record_indices']],'pivot_tests':tests,'return_J_pivot':A,'source_endpoint_loop':[x,y,x]});slots+=tests check('finite inventory',len(rows)==2 and len(slots)==8 and sum(bool(s['source_record_indices']) for s in slots)==2) return {'step':'C394','rows':rows,'reflections':reflections,'counts':{'primitive_E_edges':2,'orientation_operator_trials':8,'sourced_required_pivots':2,'forward_P_J_realizations':0,'reverse_J_realizations':2,'reverse_P_realizations':0,'complete_cumulative_reflections':0},'interpretation':'The E arrow has no same-orientation P/J realization. Its reverse arrow is an existing J edge held at the next-Gear SP/LXX Flood in the edge context. This closes a two-edge source endpoint loop, but whole-map inverse/commutation has not been established. The original17K corner exchanges do not supply the cumulative endpoints or return pivot.'}