from pathlib import Path import argparse,json,itertools p=argparse.ArgumentParser();p.add_argument('--sources',type=Path,required=True);p.add_argument('--out',type=Path,required=True);a=p.parse_args() def load(n):return json.loads((a.sources/n).read_text()) checks=[] def check(name,value): assert value,name checks.append(name) reg=load('C286_DATA.json')['target_register'];pairs=load('C286_DATA.json')['source_pairs'] ns=[x for x in reg if x['tradition']=='SP' and x['role']=='Noah birth' and x['Cainan']==x['Terah60']==0 and x['full430']==1] rs=[x for x in reg if x['tradition']=='MT' and x['role'] in ['Flood start','Flood close'] and x['full430']==1] right=[(n,r) for n in ns for r in rs if n['center']-r['center']==1058] left=[x for x in pairs if x['F']-x['S']==1058] check('raw source membership6by4',(len(left),len(right))==(6,4)) join=[(l,n,r) for l in left for n,r in right if r['center']-l['S']==8993 and n['center']-l['F']==8993] check('four actual17K matches',len(join)==4) full=[] for n,r in right: hs=[h for h in reg if h['tradition']=='MT' and h['role']=='Shem birth' and h['gear']==n['gear'] and h['Cainan']==h['Terah60']==0 and h['full430']==1] fs=[f for f in reg if f['tradition']=='MT' and f['role']==r['role'] and f['gear']==n['gear'] and f['Cainan']==f['Terah60']==0 and f['full430']==1] check(str(n['center'])+' H/F membership',len(hs)==len(fs)==1) h,f=hs[0],fs[0];dn=n['center']-r['center'];dh=n['center']-h['center'];df=n['center']-f['center'] check(str(n['center'])+' double expansion integer identity',625*dn==529*df) if 25*dn==23*dh and 25*dh==23*df:full.append(n['center']) check('two full primary ladders from integer equations',sorted(full)==[3706,3708]) phase_full=0;phase_double=0;phase_count=0 for x in load('C340_DATA.json')['rows']: v=x['records'];pts=[4*v[k]['center'] for k in ['N','R','H','F']] for eps in itertools.product([-1,1],repeat=4): n,r,h,f=[x+y for x,y in zip(pts,eps)];phase_count+=1 phase_full+=int(25*(n-r)==23*(n-h) and 25*(n-h)==23*(n-f)) phase_double+=int(625*(n-r)==529*(n-f)) check('integer scaled phase count',(phase_count,phase_full,phase_double)==(80,4,20)) reported=load('C341_DATA.json')['counts'];check('agreement with Fraction implementation',[reported[k] for k in ['phase_assignments','complete_ladders','doubleE_with_unconstrained_H_phase']]==[phase_count,phase_full,phase_double]) for x in load('C340_DATA.json')['rows']: c=x['records'];seq=[c[k]['center'] for k in ['N','M','D','R','H','F']];check(str(x['i'])+x['binding']+' direct source chain',[u-v for u,v in zip(seq,seq[1:])]==x['legs'] and seq[0]-seq[2]==950 and seq[2]-seq[5]==300) # Check selector agreement by matching regular records, without using the a/b formula. selector=[] for x in load('C319_DATA.json')['rows']: n=[n for n,r in right if n['center']==x['n'] and r['center']==x['R']] if x['joint_admitted'] and n and x['n'] in full:selector.append({k:x[k] for k in ['a','b','i']}) check('selector from endpoint join matches synthesis',selector==load('C342_DATA.json')['survivors']) check('both cumulative choices retained',{x['a'] for x in selector}=={0,2}) result={'status':'passed','author':'root agent, separately written integer cross-multiplication and direct record-join method','new_independent_agent_review':False,'checks':checks,'check_count':len(checks),'left2K':len(left),'right2K':len(right),'joined17K':len(join),'full_primary_Noah_centers':sorted(full),'phase_counts':[phase_count,phase_full,phase_double],'selector':selector} a.out.mkdir(parents=True,exist_ok=True);(a.out/'ROOT_SECOND_METHOD_RESULTS.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps({'status':'passed','checks':len(checks)}))