#!/usr/bin/env python3 """C323 independent scientific synthesis audit of completed C314–C322 data. --sources DIR contains C314_DATA.json through C322_DATA.json. No endpoint search, new source state, or C324 computation is performed. """ import argparse from fractions import Fraction as F from pathlib import Path import hashlib,json def rank(a): a=[[F(x) for x in r] for r in a];r=0 for c in range(len(a[0])): z=next((k for k in range(r,len(a)) if a[k][c]),None) if z is None:continue a[r],a[z]=a[z],a[r];v=a[r][c];a[r]=[x/v for x in a[r]] for k in range(len(a)): if k!=r: v=a[k][c];a[k]=[x-v*y for x,y in zip(a[k],a[r])] r+=1 return r def main(): ap=argparse.ArgumentParser();ap.add_argument('--sources',type=Path);ap.add_argument('--out',type=Path,default=Path(__file__).parent);a=ap.parse_args();root=Path(__file__).resolve().parents[1];d={};hashes={};checks=[] for k in range(314,323): p=a.sources/f'C{k}_DATA.json' if a.sources else root/f'C{k}/evidence/DATA.json';raw=p.read_bytes();d[k]=json.loads(raw);hashes[f'C{k}_DATA.json']=hashlib.sha256(raw).hexdigest();assert d[k]['step']==f'C{k}' def check(name,condition): assert condition,name;checks.append(name) r314=d[314]['rows'];check('C314five index reversals',len(r314)==5 and all(r['i']+r['j']==10 for r in r314)) check('C314ten reversed phase biographies',sum(len(r['components']) for r in r314)==10 and all(F(c['Noah_ancestry_phase'])==-F(c['Shem_ancestry_phase']) and F(c['Noah'])-F(c['Shem_birth'])==500 and F(c['Shem_birth'])-F(c['Shem_death'])==600 for r in r314 for c in r['components'])) check('C314no component fixedpoints',d[314]['counts']['phase_fixed_points']==0) check('C315biography chains',all([r['biography_BC'][k]-r['biography_BC'][k+1] for k in range(4)]==[500,100,350,150] for r in d[315]['rows'])) check('C315sameancestry residual2',all(r['residual']==2 and r['fixed8395_candidate']-r['biography_BC'][2]==2 for r in d[315]['rows'])) check('C315aliases3 absent2',d[315]['counts']['wrongGear_aliases']==3 and d[315]['counts']['unadmitted_fixed_candidates']==2) check('C316typed ancestry separation',all(r['h']==r['i']-2 and r['h']+r['j']==8 and r['inherited_ancestry_role']=='Shem' and r['derived_ancestry_role']=='Flood' for r in d[316]['rows'])) check('C316factorization phasewise',all(F(c['derived_selectedFlood_Flood_ancestor'])-F(c['original_selectedFlood_Shem_ancestor'])==598 and F(c['derived_selectedFlood_Flood_ancestor'])+8395==F(c['original_selectedFlood_Shem_ancestor'])+8993==F(c['selected_Flood']) for r in d[316]['rows'] for c in r['components'])) check('C316same ancestor not repaired',d[316]['common_ancestor_repaired'] is False and d[316]['cumulative_Gear_applied'] is False) check('C317rectangles',all(r['q']-r['p']==r['n']-r['f']==600 and r['f']-r['p']==r['n']-r['q']==8993 and r['cross_widths']==[[8993,9593],[8393,8993]] for r in d[317]['rows'])) bridges=[[-1,0,1,0],[0,-1,0,1]];side=[-1,1,0,0];all_edges=[] for u in range(4): for v in range(u+1,4): r=[0]*4;r[u]=-1;r[v]=1;all_edges.append(r) check('rank two bridges2 fullrectangle3',rank(bridges)==2 and rank(bridges+[side])==rank(all_edges)==3) check('C318typed shifts',d[318]['cumulative_operations']==[-460,2] and d[318]['regular_operations']==[-650,130,60,2] and sum(d[318]['cumulative_operations'])==sum(d[318]['regular_operations'])==-458) check('C318finite terminal admission',sorted(r['i'] for r in d[318]['rows'] if r['paired_admitted'])==[3,4,5]) check('C3182K identity',600+460-2==2*529 and 650-130-60==460) r319=d[319]['rows'];check('C319configuration counts',len(r319)==20 and sum(len(r['components']) for r in r319)==40 and sum(r['joint_admitted'] for r in r319)==14) check('C319conditional selector',all(r['two17K']==(r['a']==r['b']) and r['allK']==(r['a']==r['b']==2) for r in r319)) check('C31900counterexample',sum(r['joint_admitted'] and r['a']==r['b']==0 and r['two17K'] and not r['allK'] for r in r319)==5) check('C319allKthree admitted',sum(r['joint_admitted'] and r['allK'] for r in r319)==3) pairs320=[(r['i'],m) for r in d[320]['rows'] for m in r['matched_context_rectangles']] check('C320labels andcoordinates',len(pairs320)==9 and len({(m['Noah']['center'],m['Flood']['center']) for i,m in pairs320})==6) sp_indices=sorted(i for i,m in pairs320 if m['Noah']['tradition']=='SP');lxx_indices=sorted(i for i,m in pairs320 if m['Noah']['tradition']=='LXX') check('C320source families',sp_indices==[2,3,4,5,6,7] and lxx_indices==[3,5,7]) check('C320point counts',sum(len(r['Noah_point_records']) for r in d[320]['rows'])==9 and sum(len(r['Flood_point_records']) for r in d[320]['rows'])==12) pairs321=[(r['i'],m) for r in d[321]['rows'] for m in r['matched_context_rectangles']] on_indices=sorted(i for i,m in pairs321) check('C321nativeONsource families',on_indices==[3,5,7] and all(m['Noah']['tradition']=='MT' and m['Noah']['Cainan']==m['Noah']['Terah60']==m['Noah']['full430']==1 for i,m in pairs321)) check('C321uniform rectangle460',all(m['SP_OFF_antecedent']['Noah']['center']-m['Noah']['center']==m['SP_OFF_antecedent']['Flood']['center']-m['Flood']['center']==460 for i,m in pairs321)) bios=d[322]['biographies'];check('C322full biography460',len(bios)==3 and all(s-m==460 for r in bios for s,m in zip(r['SP_chain_BC'],r['MT_chain_BC']))) check('C322thirty exactcomponents',sum(len(c['SP']) for r in bios for c in r['components'])==30 and all(F(s)-F(m)==460 for r in bios for c in r['components'] for s,m in zip(c['SP'],c['MT']))) check('C322sameGear500',all(r['MT_chain_BC'][0]-r['MT_chain_BC'][1]==500 for r in bios)) bc=d[322]['MT_binding_control'];check('C322distinctcrossGear502',bc['Noah_G2']-bc['Shem_G1']==502==bc['Noah_G2_to_Shem_G1']) support=d[322]['joint_support'];sets={key:[r['i'] for r in support if r[key]] for key in ['OFF600','ON600','reversed_SP500','C287_at_i','C287_at_reversed_j','OFF_ON_reversed_and_C287_i','with_partner_C287']} check('C322jointdomains',sets=={'OFF600':[2,3,4,5,6,7],'ON600':[3,5,7],'reversed_SP500':[3,4,5,6,7],'C287_at_i':[2,3,4,5],'C287_at_reversed_j':[5,6,7],'OFF_ON_reversed_and_C287_i':[3,5],'with_partner_C287':[5]}) check('coverage derives from predecessorrows',sets['OFF600']==sp_indices and sets['ON600']==on_indices and sets['reversed_SP500']==sorted(r['i'] for r in r314)) out={'step':'C323','status':'passed','scope':'Independent audit of completed C314–C322 scientific results only; no new endpoint search.','input_sha256':hashes,'checks_passed':len(checks),'checks':checks,'consolidated_claims':{'OFF_coordinate_rectangles':6,'OFF_source_pair_labels':9,'OFF_SP_pairs':6,'OFF_LXX_coordinate_aliases':3,'nativeON_MT_pairs':3,'uniform460_biography_pairs':3,'uniform460_endpoint_checks':15,'uniform460_phase_endpoint_checks':30,'coupled22_allK_admitted':3,'equal17K_00_control_admitted':5},'joint_domains':sets,'dependency_summary':{'two_parallel17K_equations_rank':2,'including_one600side_rank':3,'all_six_four_node_durations_rank':3,'common_translation_freedom':1,'alternative8395route':'598+8395=8993, different cumulative source roles retained','paired458':'cumulative−460+2; regular−650+130+60+2','allK_condition':'a=b=2 in the fixed0/2menu, not forced by two17K','source_selector_established':False},'binding_correction':'SameGearharmonic500 and crossGearArphaxad/text-bound502 are separately valid labels. The initial sameGear502 expectation was corrected, not used to alter source rows.','scientific_verdict':'The batch strengthens finite source coherence and maps its boundaries. The equations share dependencies; coordinate aliases, phase components and selected intersections are not independent historical witnesses or source-prescribed rules.','new_research_performed':False,'C324_executed':False} a.out.mkdir(parents=True,exist_ok=True);(a.out/'C323_Independent_Synthesis_Results.json').write_text(json.dumps(out,indent=2)+'\n');print(json.dumps({'status':'passed','completed_step_data_audited':9,'scientific_claim_checks':len(checks),'all_five_joint_i':sets['with_partner_C287']})) if __name__=='__main__':main()