from fractions import Fraction as Q from collections import Counter def run(load,check): reg=load('C286_DATA.json')['target_register'];shem=[r for r in reg if r['role'].startswith('Shem')] def key(r):return tuple(r.get(k) for k in ['tradition','rail','Cainan','Terah60','full430']) groups={} for r in shem:groups.setdefault(key(r),[]).append(r) check('32 separate tradition rail context families',len(groups)==32) rows=[];same=[] for k,rr in sorted(groups.items(),key=str): by={(r['role'],r['gear']):r for r in rr} for g in [1,2,3]: u=by['Shem birth',g];v=by['Shem death',g] check('matched600 '+str(k)+' G'+str(g),u['center']-v['center']==600) same.append({'birth':u,'death':v,'span':600}) for g in [1,2]: u=by['Shem birth',g];v=by['Shem death',g+1];up=by['Shem birth',g+1];down=by['Shem death',g] gap=u['center']-v['center'];check('adjacent and repairs '+str(k)+' G'+str(g),gap==598 and Q(gap)*Q(300,299)==600 and up['center']==u['center']+2 and down['center']==v['center']-2 and up['center']-v['center']==u['center']-down['center']==600) rows.append({'birth':u,'death':v,'span':gap,'hold_death_birth_plus2':up,'hold_birth_death_minus2':down,'output_span':600,'input_is_matched_biography':False}) focus=[] for field in load('C349_DATA.json')['fields']: z=field['records'];N=z['N']['center'] for label in ['H','S']: u=z[label];hit=[r for r in rows if r['birth']==u];check('retained birth belongs to598 comparison '+str(field['i'])+label,len(hit)==1) r=hit[0];v=r['death'];eu=Q(N)+Q(25,23)*(u['center']-N);ev=Q(N)+Q(25,23)*(v['center']-N) mu=[p for p in reg if p['center']==eu];mv=[p for p in reg if p['center']==ev] check('E expands598 to650 '+str(field['i'])+label,eu-ev==650) check('death image outside frozen register '+str(field['i'])+label,not mv) focus.append({'i':field['i'],'label':label,'fixed_SP_Noah':z['N'],'input':r,'E_birth':str(eu),'E_death':str(ev),'birth_matches':mu,'death_matches':mv,'both_endpoints_source_qualified':bool(mu and mv)}) check('64 adjacent comparisons 96 biographies',len(rows)==64 and len(same)==96) return {'step':'C354','same_Gear_biographies':same,'adjacent_comparisons':rows,'counts':{'context_rail_families':32,'matched600':96,'adjacent598':64,'repairs':128,'SP_companion598':sum(r['birth'].get('rail')=='companion' for r in rows)},'focus_E_connections':focus,'interpretation':'All598 inputs are cross-Gear endpoint comparisons. Each600 output is an existing matched biography. Repeated contexts are not independent witnesses. Existing E_N does not map either focused lifespan interval to a complete source pair.','new_source_nodes':False,'global_operator_adopted':False}