from itertools import product def run(load,check): reg=load('C286_DATA.json')['target_register'];cum=load('C365_DATA.json')['cumulative_register'];pairs=load('C414_DATA.json')['source_pairs'];cc=[(i,j) for i,s in enumerate(cum) for j,f in enumerate(cum) if s['role']=='Shem' and f['role']=='Flood' and f['coordinate']-s['coordinate']==1058];old=load('C287_DATA.json')['rows'];trials=[];hits=[];templates=load('C426_DATA.json')['context_templates'] for p,(i,j) in product(pairs,cc): u,l,s,f=p['upper'],p['lower'],cum[i]['coordinate'],cum[j]['coordinate'];spans=[l-s,u-f];check('paired cross-span equality '+str((u,i,j)),spans[0]==spans[1]);row={'regular_pair':[u,l],'cumulative_record_indices':[i,j],'cumulative_coordinates':[s,f],'cross_spans':spans,'two_17K':spans==[8993,8993]};trials.append(row) if row['two_17K']: prior=[r['i'] for r in old if (r['Noah_required'],r['R'],r['S'],r['F'])==(u,l,s,f)];labels=[{'upper_record_index':a,'lower_record_index':z,'upper':reg[a],'lower':reg[z]} for a,z in product(p['levels'][0]['upper_record_indices'],p['levels'][0]['lower_record_indices'])];hits.append({**row,'C287_indices':prior,'source_labelled_regular_pairs':labels,'templates':[t['template'] for t in templates if [u,l] in t['coordinate_pairs']]}) check('existing C287 geometry '+str(u),len(prior)==1) return {'step':'C428','cumulative_2K_pairs':[{'record_indices':[i,j],'Shem':cum[i],'Flood':cum[j]} for i,j in cc],'join_trials':trials,'hits':hits,'counts':{'regular_2K_coordinate_pairs':len(pairs),'cumulative_2K_Shem_Flood_pairs':len(cc),'join_trials':len(trials),'two_17K_coordinate_joins':len(hits),'labelled_regular_join_realizations':sum(len(x['source_labelled_regular_pairs']) for x in hits),'new_geometry_outside_C287':sum(not x['C287_indices'] for x in hits)},'interpretation':'This is the complete frozen2K-side/fixed17K rectangle census, not a new Mirror-axis fit. C287 companion branches are retained as source rectangles; the earlier narrower primary i3/i5 P/J and other operator tests keep their separate conditions. A rectangle hit does not remove those qualifications.'}