from pathlib import Path ROOT=Path(__file__).resolve().parent.parent def run(load,check): reg=load('C286_DATA.json')['target_register'];pairs=load('C286_DATA.json')['source_pairs'];old={(x['a'],x['b'],x['i']):x for x in load('C332_DATA.json')['rows']};rows=[] for x in load('C319_DATA.json')['rows']: a,b,i=x['a'],x['b'],x['i'];prior=old[a,b,i];e=int(prior['rail']=='companion');P=x['S']+460;M=prior['M']['center'];left=x['q']-P;right=M-x['R'];both=left==right==598;primary=e==0;tag=f'{a}{b}/i{i}' check(tag+' source gap formulas',left==600-a and right==600+e-b) check(tag+' paired input predicate',both==(a==b==2 and primary)) check(tag+' restated2K criteria',both==(x['sides']==[1058,1058] and primary)) repaired=None if x['joint_admitted'] and primary: pv=x['q']-600;mv=x['R']+600;sp=[z for z in pairs if z['Shem_Cainan']==0 and z['Shem_index']==i and z['S']==pv];mt=[z for z in reg if z['tradition']=='MT' and z['role']=='Noah birth' and z['gear']==prior['SP_gear']+b//2 and z['Cainan']==z['Terah60']==z['full430']==1 and z['center']==mv] check(tag+'600 source outputs',bool(sp) and len(mt)==1) check(tag+' output interiors',pv-x['S']==460-a and x['n']-mv==460-b) repaired={'cumulative_P':pv,'regular_M':mv,'gaps':[x['q']-pv,mv-x['R']],'moves':[pv-P,mv-M],'already600_sides':[left==600,right==600]} rows.append({'a':a,'b':b,'i':i,'primary':primary,'joint_admitted':x['joint_admitted'],'cumulative_input_gap':left,'regular_input_gap':right,'both_inputs598':both,'existing600_outputs':repaired}) selected=[{k:x[k] for k in ['a','b','i']} for x in rows if x['joint_admitted'] and x['both_inputs598']];outputs=[{k:x[k] for k in ['a','b','i']} for x in rows if x['existing600_outputs']] check('paired598 two retained cases',selected==load('C332_DATA.json')['both_plus_two17K_survivors']) check('600 outputs nine andallfourchoices',len(outputs)==9 and {(x['a'],x['b']) for x in outputs}=={(0,0),(0,2),(2,0),(2,2)}) text=(ROOT/'sources/File_02.md').read_text();check('source scope retained','converts a gap, not a date' in text and 'chain-wide propagated state' in text and 'not a Residue Protocol calculation' in text) return {'step':'C352','rows':rows,'paired598_survivors':selected,'both600_output_survivors':outputs,'source_rule_status':'Shared origin and regular gap conversion are explicit; cumulative counterpart is a numerical endpoint comparison. No reviewed prescription forces both sides to start at598 or couples their state choices.','source_coupling_established':False,'prior_source_audit':load('C334_DATA.json')['exact_endpoint_binding'],'key_result':'Both inputs598 conditionally selects22 primary at i3/i5; allowing already600 source states leaves9 admitted primary controls spanning allfour choices.'}