from fractions import Fraction as Q def rat(x):return {'numerator':x.numerator,'denominator':x.denominator} def run(load,check): reg=load('C286_DATA.json')['target_register'];pairs=load('PREVIOUS_DATA.json')['station_pairs'];by={} for i,r in enumerate(reg):by.setdefault(r['center'],[]).append(i) ops={'E':Q(25,23),'E2':Q(625,529),'P':Q(70,69),'J':Q(300,299)};rows=[] for p in pairs: h,x=p['upper'],p['lower'];mid=Q(h)-ops['E']*(h-x) for name,m in ops.items(): y=Q(h)-m*(h-x);ids=by.get(y,[]);row={'station':p['station'],'held_upper':h,'input_lower':x,'operator':name,'multiplier':rat(m),'expanded_gap':rat(m*(h-x)),'output':rat(y),'source_record_indices':ids,'source_records':[reg[i] for i in ids]} if name=='E2':row.update({'E_intermediate':rat(mid),'intermediate_source_record_indices':by.get(mid,[]),'both_E_steps_source_admitted':bool(ids and by.get(mid,[]))});check('E2 exact composition '+p['station'],y==Q(h)-ops['E']*(h-mid)) check('fixed source gap '+str((p['station'],name)),h-x==1058) if name in ['P','J']:check('nonintegral fixed2K output '+str((p['station'],name)),y.denominator>1) rows.append(row) return {'step':'C420','harmonic_trials':rows,'sourced_endpoint_hits':[r for r in rows if r['source_record_indices']],'counts':{'station_pairs':len(pairs),'operator_trials':len(rows),'sourced_output_trials':sum(bool(r['source_record_indices']) for r in rows),'E_sourced_outputs':sum(r['operator']=='E' and bool(r['source_record_indices']) for r in rows),'E2_sourced_outputs':sum(r['operator']=='E2' and bool(r['source_record_indices']) for r in rows),'complete_E2_ladders':sum(r.get('both_E_steps_source_admitted',False) for r in rows)},'interpretation':'These are specified gap-scaling diagnostics about already fixed upper coordinates, not permission to use J as a calendar date operator. E2 endpoint membership is separated from the two sourced E steps. Source roles and contexts remain on every output record; no inferred intermediate becomes a source.'}