from research import *
s=begin(820,'Audit the main synthesis table and primary continuation','Do the reader-facing numbers reconstruct from the frozen models?',{},['draft C819; model native fields; latest File52c'])
doc=(ROOT/'drafts/Integrated_Synthesis_C819.md').read_text()
native=json.loads((ROOT/'model/native_mode_fields.json').read_text());birth=json.loads((ROOT/'model/finite_birth_configurations.json').read_text());l={x['name']:x for x in native['LXX']};sp={x['name']:x for x in native['SP']};names=['Noah','Shem','Arphaxad','Cainan2','Shelah','Eber','Peleg','Reu','Serug','Nahor','Terah','Abraham']
checked=[]
for n in names:
    display='Cainan' if n=='Cainan2' else ('Abraham, shared terminal' if n=='Abraham' else n)
    line=next(z for z in doc.splitlines() if z.startswith('| '+display+' |') and (' / ' in z))
    cells=[z.strip() for z in line.strip('|').split('|')]
    sc=sp['Shelah']['C_center']+460 if n=='Cainan2' else sp[n]['C_center']+(460 if names.index(n)<=2 else 0)
    lc=l[n]['C_center']
    checks=[int(cells[1])==birth['SP']['101'][n],cells[3]==f'{sc} / {lc}',int(cells[4])==lc-sc]
    checked.append({'name':n,'checks':checks})
continuation=6+inv(1650)+inv(1050)+inv(1400)
finish(s,{'table_rows_checked':len(checked),'continuation_endpoint':continuation,'backbone_shift':continuation-12026},'Every displayed shared birth and cumulative pair matches the frozen model. The added primary continuation gives14726 and the stated2700 shift with one reversal per admitted component.','Prepare the final synthesis with independent review qualifications.',{'all_displayed':all(all(x['checks']) for x in checked),'continuation':continuation==14726})
