from collections import Counter def run(load,check): reg=load('C286_DATA.json')['target_register'];by={} for i,r in enumerate(reg):by.setdefault(r['center'],[]).append(i) coords=sorted(by);edges=[];links=[];trials=[] def same(a,b,keys):return all(a.get(k)==b.get(k) for k in keys) keys=['tradition','gear','Cainan','Terah60','full430'];context=['gear','Cainan','Terah60','full430'] for u in coords: v=u-500;ok=v in by;trials.append({'input':u,'output':v,'source_member':ok}) if not ok:continue pairids=[] for ia in by[u]: for ib in by[v]: a,z=reg[ia],reg[ib];kind='additional labelled coincidence' if a['role']=='Noah birth' and z['role']=='Shem birth' and same(a,z,keys+['rail']):kind='same-family Noah birth to Shem birth' elif a['role']=='Flood start' and z['role']=='Shem death' and same(a,z,keys) and z.get('rail')==('primary' if a['tradition']=='SP' else None):kind='same-family Flood start to primary/native Shem death' elif a['role']=='Flood close' and z['role']=='Shem death' and same(a,z,keys) and a['tradition']=='SP' and z.get('rail')=='companion':kind='SP Flood close to companion Shem death' elif a['role']=='Shem death' and z['role']=='Noah death' and a['tradition'] in ['SP','LXX'] and z['tradition']=='MT' and same(a,z,context) and a.get('rail') in [None,'primary']:kind='SP primary/LXX Shem death to MT Noah death' pairids.append(len(links));links.append({'input_record':ia,'output_record':ib,'classification':kind}) edges.append({'input':u,'output':v,'source_input_records':by[u],'source_output_records':by[v],'labelled_links':pairids}) edgeinputs={e['input'] for e in edges};edgeoutputs={e['output'] for e in edges};paths=[] for start in sorted(edgeinputs-edgeoutputs): path=[start] while path[-1] in edgeinputs:path.append(path[-1]-500) paths.append({'vertices':path,'edge_count':len(path)-1,'roles_at_vertices':[sorted({reg[i]['role'] for i in by[x]}) for x in path]}) covered={(p['vertices'][i],p['vertices'][i+1]) for p in paths for i in range(p['edge_count'])} check('finite chain coverage',covered=={(e['input'],e['output']) for e in edges} and len(covered)==len(edges)) check('strictly decreasing finite translation',all(e['input']-e['output']==500 for e in edges)) types=Counter(r['classification'] for r in links);lengths=Counter(p['edge_count'] for p in paths);rolepairs=Counter((reg[r['input_record']]['role'],reg[r['output_record']]['role']) for r in links) check('retained selected loop translation in census',all((s['center']+500,s['center']) in covered for h in load('C405_DATA.json')['loop_translations'] for s in list(h['Shem_records'].values())+h['P_Shem_death_records'])) return {'step':'C410','coordinate_trials':trials,'source_edges':edges,'labelled_links':links,'classification_counts':dict(sorted(types.items())),'role_pair_counts':[{'input_role':a,'output_role':b,'labelled_links':n} for (a,b),n in sorted(rolepairs.items())],'maximal_paths':paths,'path_length_distribution':{str(k):v for k,v in sorted(lengths.items())},'counts':{'source_records':len(reg),'distinct_coordinates':len(coords),'coordinate_trials':len(trials),'source_coordinate_arrows':len(edges),'source_labelled_arrows':len(links),'maximal_nontrivial_paths':len(paths),'maximum_path_edges':max(lengths),'isolated_source_coordinates':len(set(coords)-edgeinputs-edgeoutputs)},'interpretation':'This is the entire coordinate domain of one already motivated fixed translation. The ledger preserves all source labels and classifies same-family role transport separately from cross-tradition source relations and other alias pairings. A coordinate arrow alone does not prescribe a historical source pairing or make the whole register translation-invariant.'}