from fractions import Fraction as Q from collections import defaultdict def run(load,check): cum=load('C365_DATA.json')['cumulative_register'];reg=load('C286_DATA.json')['target_register'];d=load('C370_DATA.json');rows=[] menus={'cumulative':cum,'regular':reg};indices={} for field,records in menus.items(): at=defaultdict(list) for j,p in enumerate(records):at[p['coordinate'] if field=='cumulative' else p['center']].append(j) indices[field]=dict(at) check('frozen finite source menus',len(cum)==48 and len(reg)==528 and all(p['regular_Gear'] is None for p in cum) and all(p['role'] in ['Flood start','Flood close','Noah birth','Noah death','Shem birth','Shem death'] for p in reg)) for rr in d['regular_rows']: i=rr['i'];cc=next(r for r in d['cumulative_rows'] if r['i']==i) for field,A,B,inputc,target in [('cumulative',cc['J_pivot_OFF_Flood']['coordinate'],cc['P_pivot_ON_Flood']['coordinate'],cc['input_OFF_Shem']['coordinate'],cc['output_OFF_Shem']['coordinate']),('regular',rr['J_pivot_MT_Flood']['center'],rr['P_pivot_SP_Flood']['center'],rr['input_MT_Noah']['center'],rr['candidate_next_Gear_MT_Noah']['center'])]: at=indices[field];edges=[];fixed=[];trials=0 for name,ratio,pivot in [('J',Q(300,299),A),('P',Q(70,69),B)]: for x in sorted(at): y=pivot+ratio*(x-pivot);trials+=1 if y.denominator!=1 or int(y) not in at:continue y=int(y);row={'operator':name,'pivot':pivot,'from_coordinate':x,'to_coordinate':y,'signed_input_gap':x-pivot,'signed_output_gap':y-pivot,'source_record_indices':at[x],'target_record_indices':at[y]} if y==x:fixed.append(row) else:edges.append(row) grouped=defaultdict(list) for e in edges:grouped[e['from_coordinate'],e['to_coordinate']].append(e['operator']) common=[{'from_coordinate':x,'to_coordinate':y,'operators':sorted(ops)} for (x,y),ops in grouped.items() if len(set(ops))==2] outgoing=[e for e in edges if e['from_coordinate']==target];incoming=[e for e in edges if e['to_coordinate']==inputc] check('source edge exact replay '+str((field,i)),all(Q(e['signed_output_gap'],e['signed_input_gap'])=={'J':Q(300,299),'P':Q(70,69)}[e['operator']] for e in edges)) check('only unique meeting can have common image '+str((field,i)),all(Q(x['from_coordinate']-A)==Q(13,10)*(B-A) for x in common)) rows.append({'field':field,'i':i,'rail':rr['rail'],'J_pivot':A,'P_pivot':B,'source_records':len(menus[field]),'distinct_coordinates':len(at),'trials':trials,'edges':edges,'fixed_points':fixed,'common_edges':common,'known_input':inputc,'candidate_output':target,'nontrivial_forward_edges_from_candidate':outgoing,'nontrivial_forward_edges_into_input':incoming,'counts':{'nontrivial_operator_edges':len(edges),'distinct_directed_edges':len(grouped),'fixed_operator_points':len(fixed),'common_edges':len(common),'continuations_from_candidate':len(outgoing),'predecessors_into_input':len(incoming)}}) totals={k:sum(r['counts'][k] for r in rows) for k in rows[0]['counts']} check('exact eight pivot fields',len(rows)==8) return {'step':'C376','menus':menus,'rows':rows,'totals':totals,'edge_semantics':'Finite point comparisons at fixed inherited pivots. Coordinate edges retain every source-labelled record index; duplicate records and opposite fields are not independent witnesses. Inverse edges are the reversals of the listed exact forward edges, not extra source evidence. Fixed points are separated.','scope':'All existing regular records remain Noah/Shem/Flood only; cumulative48 members include the retained source-derived Noah records. No new endpoints or fitted pivots.'}