"""Finite C269 source-path audit; exact arithmetic, no search or graph mutation.""" from pathlib import Path from fractions import Fraction as F import argparse, hashlib, json, csv ROOT=Path(__file__).resolve().parents[1] p=argparse.ArgumentParser();p.add_argument('--output',type=Path,default=ROOT/'evidence') OUT=p.parse_args().output;OUT.mkdir(parents=True,exist_ok=True) checks=[] def check(name,condition): if not condition:raise AssertionError(name) checks.append(name) def sha(path):return hashlib.sha256(path.read_bytes()).hexdigest() def load(name):return json.loads((ROOT/'sources'/name).read_text()) def dump(name,obj):(OUT/name).write_text(json.dumps(obj,indent=2,ensure_ascii=False,default=str)+'\n') def pair(x):return [F(x)-F(1,4),F(x)+F(1,4)] def spans(a,b):return [q-p for p,q in zip(pair(a),pair(b))] for name,row in json.loads((ROOT/'SOURCE_MANIFEST.json').read_text()).items(): src=ROOT/'sources'/name check('frozen '+name,sha(src)==row['sha256'] and src.stat().st_size==row['bytes']) prev=load('C268_CERTIFICATE.json') for name,key in [('C268_REPORT.md','report_sha256'),('C268_CHECKPOINT.md','checkpoint_sha256'),('C268_RESULTS.json','results_sha256')]: check('C268 certificate '+name,sha(ROOT/'sources'/name)==prev[key]) expected={'FILE_18.md':'68301ab760bfbe2e874aedc5c8d943ced7a6219d34bc2859332a70713f9630d5','FILE_09.md':'45851004c5864229ebf6a896f9099819a08d8926715d3e97e4bc3985c4a3876e','C127_GRAPH.json':'d7be8886117c8c550e39f8846862ec613f621c0ed560d4c9d8c89446fae53503','C18_REPORT.md':'b11fefdbcfe2f5c95532d851cca1b6eede99bbd9e4e166d214c087f11fc3b753'} for name,digest in expected.items():check('controlling hash '+name,sha(ROOT/'sources'/name)==digest) G=load('C127_GRAPH.json')['graph'];nodes={n['id']:n for n in G['nodes']};edges={e['id']:e for e in G['duration_edges']} check('frozen graph sizes',len(nodes)==208 and len(edges)==382) old=load('C01_RESULTS.json');events=old['events'];chains=old['complete_three_stage_chains'] check('fixed source domain',len(events)==48 and len(chains)==2) records=load('C266_ENDPOINTS.json') flood=sorted([r for r in records if r['profile']=='LXX_OFF' and r['source_role']=='Flood'],key=lambda r:r['source_index']) check('retained LXX full Flood field',len(flood)==8 and [r['source_BC_base'] for r in flood]==list(range(5290,5282,-1))) fc=flood[-1] sc=[r for r in records if r['profile']=='LXX_OFF' and r['source_role']=='Shem' and r['source_index']==7 and r['reflection_after_translation']][0] l=-fc['source_BC_base'];s=-sc['source_BC_base'] check('closing source identities',(l,s)==(-5283,-5883)) check('closing local transforms',l+fc['translation']==7 and -(s+sc['translation'])==-5) check('no cumulative Gear',fc['regular_Gear'] is None and sc['regular_Gear'] is None) check('Flood closing not stored in C127',not any(n['signed_center']==l for n in nodes.values())) check('Shem closing stored identity',nodes['N04_cm']['signed_center']==s and nodes['N04_cm']['role']=='cum_LXX_OFF_Shem') selected_edges=[] def edge(identifier,source,target,width): e=edges[identifier] check('stored edge '+identifier,(e['from'],e['to'],e['width'])==(source,target,width)) check('edge coordinate width '+identifier,nodes[target]['signed_center']-nodes[source]['signed_center']==width) selected_edges.append(e);return e paths=[];operator=[] for label,chain,j in zip(['N02','N04'],chains,[3,5]): c=nodes[label+'_c']['signed_center'];a=-chain['Creation_BC_Nisan'] f=chain['Flood']['BC_Nisan'];m=chain['midpoint']['BC_Nisan'];n=chain['MT_Noah']['BC_Nisan'];v=chain['SP_Noah']['BC_Nisan'] check(label+' cumulative source member',flood[j]['source_BC_base']==-c and flood[j]['pair_center']==j) for suffix,value in [('_b',a),('_f',f),('_spDeath',m),('_mtN',n),('_s',v)]: check(label+' graph source '+suffix,nodes[label+suffix]['signed_center']==value and nodes[label+suffix]['source_membership_verified']) route=[('_868','_c','_b',868),('_13','_b','_f',6877),('_299a','_f','_spDeath',299),('_299b','_spDeath','_mtN',299),('_650','_mtN','_s',650)] for eid,u,w,d in route:edge(label+eid,label+u,label+w,d) edge(label+'_17',label+'_c',label+'_s',8993) edge(label+'_opening_member_offset','opening_OFF_BC',label+'_c',j) # Subdivide the stored attachment with the existing source closing boundary. gap=l-c;tail=a-l;points=[c,l,a,f,m,n,v];widths=[q-p for p,q in zip(points,points[1:])] check(label+' closing insertion ordered',cq+868 for retained selected members','C09_source_to_MT_Flood':'q->q+7745 on admitted selected members; closing2462 unsourced','source_rectangle':'q->q+8993 on three listed source members','limit':'Connected source paths do not identify the C268 source anchor or implement its seasonal-component-to-pair-center rescaling'}) dump('RESULTS.json',{'step':'C269','status':'passed','check_count':len(checks),'checks':checks,'main_result':'The exact closing sources join retained17K paths and a600-by8993 source rectangle; C254 closing support is retained; C268 affine charts remain distinct operators','canonical_sources_modified':False,'prior_graph_modified':False}) with (OUT/'SOURCE_PATHS.csv').open('w',newline='') as f: w=csv.writer(f);w.writerow(['path','from_center','to_center','width','evidence_status']) for row in paths: for k,(a,b,d) in enumerate(zip(row['centers'],row['centers'][1:],row['widths'])):w.writerow([row['chain'],a,b,d,'new source-supported subdivision' if k<2 else 'existing directed source comparison']) for a,b,d in zip(closing_route,closing_route[1:],closing_widths):w.writerow(['C254 selector7',a,b,d,'inherited completed source path']) print(json.dumps({'step':'C269','status':'passed','checks':len(checks),'output_files':6}))