from pathlib import Path from fractions import Fraction as Q from itertools import product import re,hashlib ROOT=Path(__file__).resolve().parent.parent def run(load,check): spec=[('MT_PERSONS','File_02.md',659,716),('PERSON_BASES','File_18.md',1253,1282),('SP_FIELD','File_18.md',1571,1596),('FLOOD','File_18.md',1540,1552),('VARIANTS','File_18.md',620,627),('LXX_REMOVAL','File_18.md',1140,1147),('SP_LOCALITY','File_18.md',433,435),('DUAL100','File_18.md',755,771),('E_P','File_46.md',97,133),('E_SQUARED','File_46.md',363,365),('J_GAP','File_02.md',718,731),('MIRROR_COMPONENTS','File_09.md',2028,2065)];cards=[] for key,name,a,z in spec: lines=(ROOT/'sources'/name).read_text().splitlines();text='\n'.join(lines[a-1:z]);check('current excerpt '+key,bool(text) and len(lines)>=z);cards.append({'id':key,'source':name,'line_start':a,'line_end':z,'text':text,'excerpt_sha256':hashlib.sha256(text.encode()).hexdigest()}) at={r['id']:r['text'] for r in cards};bases={} for person in ['Noah','Shem']: mt=re.search(r'\| '+person+r' \| (\d+)/(\d+) BC \| (\d+)/(\d+) BC',at['MT_PERSONS']);assert mt;bases['MT',person+' birth',None]=int(mt.group(2));bases['MT',person+' death',None]=int(mt.group(4)) lx=re.search(r'\| LXX \| '+person+r' \| (\d+)–(\d+) BC \| (\d+)–(\d+) BC',at['PERSON_BASES']);assert lx;a,z=(3,4) if person=='Noah' else (1,2);bases['LXX',person+' birth',None]=int(lx.group(a));bases['LXX',person+' death',None]=int(lx.group(z)) row=next(l for l in at['SP_FIELD'].splitlines() if l.startswith('| G1 |')).split('|')[2:6] for role,cell in zip(['Noah birth','Noah death','Shem birth','Shem death'],row): for rail,v in zip(['primary','companion'],map(int,cell.strip().split('/'))):bases['SP',role,rail]=v floods={} for tr,label in [('MT','MT'),('SP','SP'),('LXX','LXX — native Cainan ON')]: line=next(l for l in at['FLOOD'].splitlines() if l.startswith('| '+label+' |'));floods[tr]=int(re.findall(r'(\d+)→(\d+)',line)[2][0]) reg=load('C286_DATA.json')['target_register'];ids=set() for p in load('C416_DATA.json')['profiles']:ids.update(x['record_index'] for x in p['stations'].values()) for row in load('C418_DATA.json')['all_event_Gear_trials']:ids.update([row['upper_record_index'],row['lower_record_index']]) for row in load('C420_DATA.json')['sourced_endpoint_hits']:ids.update(row['source_record_indices']) for control in load('C417_DATA.json')['rail_controls']: c=control['upper_context'];ids.update(i for i,r in enumerate(reg) if r['role']=='Noah birth' and all(r.get(k)==v for k,v in c.items())) rebuilt=[] for i in sorted(ids): r=reg[i];tr=r['tradition'];native=int(tr=='LXX');shift=130*(r['Cainan']-native)+60*r['Terah60']+2*(r['gear']-1) if r['role'].startswith('Flood'):v=floods[tr]+shift+215*(r['full430']-1)-int(r['role']=='Flood close') else:v=bases[tr,r['role'],r.get('rail')]+shift+215*r['full430'] check('direct source reconstruction '+str(i),v==r['center']);rebuilt.append({'record_index':i,'record':r,'reconstructed_coordinate':v}) check('SP person and event guards',all(x in at['SP_FIELD'] for x in ['950','600','500','502','inclusive/harmonic','not six independently attested','not type the Flood close as a companion']) and 'do not transfer it to MT/LXX' in at['SP_LOCALITY']) check('J source gap guard','converts a gap, not a date' in at['J_GAP']) check('Jan1 axis and quarter source convention','start of Jan 1, AD 1' in at['MIRROR_COMPONENTS'] and '1/4' in at['MIRROR_COMPONENTS']) eps=[-Q(1,4),Q(1,4)];translations=[] for p,eu,el in product(load('C419_DATA.json')['station_pairs'],eps,eps): error=Q(p['upper'])+eu-1058-(Q(p['lower'])+el);ok=error==0;check('translation phase criterion '+str((p['station'],eu,el)),ok==(eu==el));translations.append({'station':p['station'],'upper_offset':str(eu),'lower_offset':str(el),'error':str(error),'preserved':ok}) hit=load('C420_DATA.json')['sourced_endpoint_hits'][0];h,x=hit['held_upper'],hit['input_lower'];y=Q(hit['output']['numerator'],hit['output']['denominator']);m=Q(625,529);fixed=[];shifted=[] for ei,eo in product(eps,eps): error=Q(h)+m*(Q(x)+ei-h)-(y+eo);fixed.append({'input_offset':str(ei),'target_offset':str(eo),'error':str(error),'preserved':error==0});check('fixed E2 component fails '+str((ei,eo)),error!=0) for e in eps: result=Q(h)+e+m*(Q(x)+e-(Q(h)+e));check('joint shifted comparison '+str(e),result==y+e);shifted.append({'common_offset':str(e),'pivot':str(h+e),'input':str(x+e),'output':str(result),'same_fixed_pivot_action':False}) claims=[{'claim':'Four same-role person stations and their950/600 lifespans','status':'Directly reconstructed source endpoints; the1058 context pairing is derived.'},{'claim':'Five-station profile and Flood boundary labels','status':'Exact derived comparison; upperclose/lowerstart remains explicit and full Flood-year translation fails.'},{'claim':'Finite uniqueness and harmonic endpoint','status':'Census/affine consequences of source menu, not a prescribed combined selection in the reviewed passages.'},{'claim':'Inherited quarter-offset translation','status':'Two matched components perstation are preserved by slope1; no new calendar phase is inferred.'},{'claim':'Squared-E seasonal interpretation','status':'Fixedpivotfailsallfourcomponentassignments; movingbothpivotandinputpreservescommonoffset as a different comparison, not onefixedaction.'}] return {'step':'C422','source_excerpt_cards':cards,'reconstructed_records':rebuilt,'translation_component_trials':translations,'fixed_E2_component_trials':fixed,'joint_shifted_E2_comparisons':shifted,'claim_status_matrix':claims,'counts':{'source_excerpt_cards':len(cards),'direct_source_records_reconstructed':len(rebuilt),'translation_component_assignments':len(translations),'preserved_translation_components':sum(x['preserved'] for x in translations),'fixed_E2_component_assignments':len(fixed),'preserved_fixed_E2_components':sum(x['preserved'] for x in fixed),'joint_shifted_E2_comparisons':len(shifted),'new_source_points':0,'new_protocol_prescriptions_established':0},'interpretation':'The existing signed-coordinate quarter offsets are inherited component diagnostics, not invented BC/AD civil dates. All source roles, rails, variants and Gear labels remain explicit. Matching a translation or jointly shifted comparison does not create a single physical-time E² action, a new phase, a global Mirror axis or an independent historical witness.'}