from fractions import Fraction as F def run(load,check): old=load('PREVIOUS_DATA.json');anc=load('C271_REGISTER.json');complete={r['i'] for r in load('C287_DATA.json')['rows'] if r['complete']};rows=[] for r in old['rows']: j,i,g,rail=r['j'],r['i'],r['gear'],r['rail'];n,s,f,nd,d=r['biography_BC'];h=i-2 a=[x for x in anc if x['branch']=='Flood' and x['source_event']['gear']==g and x['source_event']['role']==r['selected_Flood_role']] check(f'j{j} unique original Flood ancestry',len(a)==1);a=a[0] check(f'j{j} inherited source role and index',a['cumulative_source']['source_role']=='Shem' and a['cumulative_source']['source_index']==i and a['source_event']['BC_Nisan']==f) p=-5890+i;q=-5290+i;u=-5290+h check(f'j{j} two equal output routes',p+8993==u+8395==f and q+8993==n and u-p==598) check(f'j{j} station domains',i in range(8) and h in range(8) and h+j==8) cases=[] for c in r['components']: e=F(c['Noah_ancestry_phase']);out=F(c['selected_Flood']) matches=[(k,z) for k in range(8) for z in [F(-1,4),F(1,4)] if F(-5290+k)+z+8395==out] check(f'j{j} {e} unique derived Flood antecedent',matches==[(h,e)]) ac=[x for x in a['phases'] if F(x['reflected_coordinate'])==out] check(f'j{j} {e} actual Shem ancestry',len(ac)==1 and F(ac[0]['cumulative_coordinate'])==F(p)+e) check(f'j{j} {e} source offset contributes two',F(q)+e-(F(u)+e)==2 and F(n)+e-out==8993-8395+2==600) cases.append({'phase':str(e),'Noah_Flood_ancestor':str(F(q)+e),'original_selectedFlood_Shem_ancestor':str(F(p)+e),'derived_selectedFlood_Flood_ancestor':str(F(u)+e),'selected_Flood':str(out)}) descent=bool(r['same_role_aliases']) if descent: check(f'j{j} admitted regular oneGear descent',r['same_role_aliases'][0]['gear']==g+1 and r['same_role_aliases'][0]['center']-2==f) rows.append({'j':j,'i':i,'h':h,'gear':g,'rail':rail,'biography_BC':r['biography_BC'],'selected_Flood_role':r['selected_Flood_role'],'inherited_ancestry_role':'Shem','inherited_ancestry_index':i,'derived_ancestry_role':'Flood','derived_ancestry_index':h,'C287_at_i':i in complete,'C287_at_j':j in complete,'C287_at_h':h in complete,'C287_at_all3':all(k in complete for k in [i,j,h]),'regular_descent_admitted':descent,'components':cases}) check('allthree C287 support onlyj5',[r['j'] for r in rows if r['C287_at_all3']]==[5]) return {'step':'C316','rows':rows,'counts':{'derived_8395_routes':5,'exact_components':10,'original_C271_Shem_routes':5,'regular_descent_admitted':3,'regular_descent_start_absent':2,'C287_at_i':sum(r['C287_at_i'] for r in rows),'C287_at_j':sum(r['C287_at_j'] for r in rows),'C287_at_h':sum(r['C287_at_h'] for r in rows),'C287_at_all3':1},'identity':'qFlood_i−qFlood_h=2; pShem_i+8993=qFlood_h+8395; source roles remain distinct','common_ancestor_repaired':False,'cumulative_Gear_applied':False}