from fractions import Fraction from collections import defaultdict import hashlib def run(load,read,check): def digest(name):return hashlib.sha256(read(name).encode()).hexdigest() check('C469_source_manifest_certificate',digest('C469_SOURCE_MANIFEST.json')==load('C469_CERTIFICATE.json')['source_manifest_sha256']) for name in ['C365_DATA.json','C287_DATA.json']:check(name+'_inherited_hash',digest(name)==load('C469_SOURCE_MANIFEST.json')[name]['sha256']) check('C461_data_certificate',digest('C461_DATA.json')==load('C461_CERTIFICATE.json')['data_sha256']) cum=load('C365_DATA.json')['cumulative_register'];ix=defaultdict(list) for i,z in enumerate(cum):ix[z['coordinate']].append(i) check('fixed48_cumulative_domain',len(cum)==48 and len(ix)==48) cases=[z for z in load('PREVIOUS_DATA.json')['rows'] if z['endpoint_pair_complete']] check('nine_source_endpoint_cases',len(cases)==9) def E(h,x):return Fraction(25*x-2*h,23) trials=[] for z in cases: h=z['upper'];x,m,y=z['lower_path'] for A in [-2639,-2635]: pivot=A-h;stations=[A-v for v in [x,m,y]] label=str(h)+'_'+str(A) for j,v in enumerate([x,m]):check(label+'_conjugacy_'+str(j),A-E(h,v)==E(pivot,A-v)) check(label+'_reflected_gaps',stations[0]-pivot==1058 and stations[1]-pivot==1150 and stations[2]-pivot==1250) pair_ok=bool(ix.get(pivot)) and bool(ix.get(stations[0]));cross=h-stations[0] phase=[row['i'] for row in load('C287_DATA.json')['rows'] if row['complete'] and row['R']==x and row['Noah_required']==h and row['S']==pivot and row['F']==stations[0]] trials.append({'regular_upper':h,'regular_lower_path':[x,m,y],'rail':z['rail'],'regular_full_path':z['two_sourced_E_steps'],'extra_input_alias':z['extra_input_alias'],'exchange_constant':A,'cumulative_pivot':pivot,'cumulative_lower_path':stations,'cumulative_record_indices':{'pivot':ix.get(pivot,[]),'input':ix.get(stations[0],[]),'middle':ix.get(stations[1],[]),'final':ix.get(stations[2],[])},'complete_input_image':pair_ok,'complete_cumulative_path':all(ix.get(v) for v in [pivot]+stations),'cross_span':cross,'cross_span_is17K':cross==17*529,'inherited_phase_rows':phase}) complete=[z for z in trials if z['complete_input_image']] old=load('C461_DATA.json')['complete_images'] check('input_images_exactly_inherited_C461',sorted((z['exchange_constant'],tuple([z['regular_lower_path'][0],z['regular_upper']])) for z in complete)==sorted((z['exchange_constant'],tuple(z['regular_pair'])) for z in old)) check('two_inherited17K_images',len([z for z in complete if z['cross_span_is17K'] and z['inherited_phase_rows']])==2) check('no_sourced_cumulative_middle',not any(z['cumulative_record_indices']['middle'] for z in trials)) check('no_expanded_final_on_complete_input_images',not any(z['cumulative_record_indices']['final'] for z in complete)) return {'step':'C477','trials':trials,'complete_input_images':complete,'cumulative_register':cum,'counts':{'trials':len(trials),'complete_input_images':len(complete),'primary_complete_input_images':sum(z['rail']=='primary' for z in complete),'companion_complete_input_images':sum(z['rail']=='companion' for z in complete),'inherited17K_images':sum(bool(z['inherited_phase_rows']) for z in complete),'sourced_cumulative_middles':sum(bool(z['cumulative_record_indices']['middle']) for z in trials),'sourced_cumulative_finals':sum(bool(z['cumulative_record_indices']['final']) for z in trials),'complete_cumulative_paths':sum(z['complete_cumulative_path'] for z in trials),'fully_sourced_regular_and_cumulative_paths':sum(z['regular_full_path'] and z['complete_cumulative_path'] for z in trials)},'limits':'Formal conjugacy only; held-pivot diagnostics remain outside the active eight-pivot menu. Exactly48 cumulative records and two inherited exchange constants; no annual phase reassignment is promoted to a new17K corner.'}