from pathlib import Path import hashlib ROOT=Path(__file__).resolve().parent.parent def run(load,check): summaries=[];main=auth=0 for n in range(354,363): c=load(f'C{n}_CERTIFICATE.json');d=load(f'C{n}_DATA.json');r=load(f'C{n}_RESULTS.json');nxt=load(f'C{n}_NEXT_STEP.json') check(f'C{n} completed',c['step']==d['step']==f'C{n}' and c['status']=='completed' and r['status']=='passed') for key,name in [('data_sha256',f'C{n}_DATA.json'),('results_sha256',f'C{n}_RESULTS.json'),('next_step_decision_sha256',f'C{n}_NEXT_STEP.json')]:check(f'C{n} '+key,hashlib.sha256((ROOT/'sources'/name).read_bytes()).hexdigest()==c[key]) check(f'C{n} next decision',nxt['next_proposed_step']==f'C{n+1}' and not nxt['executed'] and bool(nxt['reason_selected_after_current_result'])) prev='C353_CERTIFICATE.json' if n==354 else f'C{n-1}_CERTIFICATE.json' check(f'C{n} predecessor certificate',c['previous_certificate_sha256']==hashlib.sha256((ROOT/'sources'/prev).read_bytes()).hexdigest()) main+=r['assertions_passed'];auth+=r['source_checks_passed'];summaries.append({'step':f'C{n}','title':c['title'],'main_result':c['main_result'],'checks':r['assertions_passed'],'source_checks':r['source_checks_passed']}) check('C353 baseline binding',hashlib.sha256((ROOT/'sources/C353_DATA.json').read_bytes()).hexdigest()==load('C353_CERTIFICATE.json')['data_sha256']) audit=load('PRE_C363_ARCHIVE_AUDIT.json');check('nine sealed predecessor packets',audit['status']=='passed' and audit['totals']['packets']==9 and audit['totals']['main_output_comparisons']==18 and audit['totals']['successful_publications']==27) check('Shem census',load('C354_DATA.json')['counts']=={'context_rail_families':32,'matched600':96,'adjacent598':64,'repairs':128,'SP_companion598':16}) check('600 translation census',load('C355_DATA.json')['counts']=={'tested':8,'complete_with_fixed':4,'complete_nontrivial':2}) check('five pivot census',load('C356_DATA.json')['counts']=={'pivot_choices':10,'trials':40,'complete_nontrivial':10,'additional_nontrivial_beyond_untranslated':4}) check('context census',load('C357_DATA.json')['counts']=={'controls':384,'hits':6,'companion_hits':0}) check('local structure leaves nine controls',load('C358_DATA.json')['counts']['local_three_row']==9 and load('C358_DATA.json')['counts']['local_and_sameGear_R']==5 and load('C358_DATA.json')['counts']['local_and_regular2K']==4) for r in load('C359_DATA.json')['rows']:check('joined source image '+str(r['i']),r['input_gaps']==[460,598] and r['output_gaps']==[500,600] and r['total_output']==1100 and r['total_ratio_diagnostic']=='550/529') for r in load('C359_DATA.json')['rows']: old=next(x for x in load('C287_DATA.json')['rows'] if x['i']==r['i']);T=r['output_records'][2]['center'] check('joined comparison changes one17K span '+str(r['i']),old['R']-T==42 and old['R']-old['S']==17*529 and T-old['S']==17*529-42) select=['02:i3','02:i5','22:i3','22:i5'];check('joined selector',load('C360_DATA.json')['survivors']==select) for r in load('C361_DATA.json')['rows']:check('Shem squared E source and gap '+str(r['i']),r['ordered_gaps']==[600,50,600] and r['outer_span']==1250 and r['squared_E']['input_gap']==1058 and not r['squared_E']['intermediate_matches'] and not r['squared_E']['two_source_edges']) p=load('C362_DATA.json');check('squared selector and phases',p['source_survivors']==select and p['counts']=={'source_controls':20,'admitted_exact':4,'squared_phase_trials':16,'squared_phase_passes':4,'joined_phase_trials':64,'joined_phase_passes':4}) secondary=load('ROOT_SECOND_METHOD_RESULTS.json');check('root alternate method passes',secondary['status']=='passed' and secondary['check_count']==475 and not secondary['new_independent_agent_review'] and secondary['joined_selector_survivors']==select and secondary['squared_selector_survivors']==select) for name,want in [('File_18.md','68301ab760bfbe2e874aedc5c8d943ced7a6219d34bc2859332a70713f9630d5'),('File_09.md','45851004c5864229ebf6a896f9099819a08d8926715d3e97e4bc3985c4a3876e'),('C265_CERTIFICATE.json','112bdcdd23e7580512f6b6a1c4222f746e6552f71b92755932397dbd25dce2de')]:check('source bytes '+name,hashlib.sha256((ROOT/'sources'/name).read_bytes()).hexdigest()==want) check('File02 unchanged',hashlib.sha256((ROOT/'sources/File_02.md').read_bytes()).hexdigest()==load('C354_SOURCE_MANIFEST.json')['File_02.md']['sha256']) check('C265 checkpoint readable','C265' in (ROOT/'sources/C265_CHECKPOINT.md').read_text()) check('authorization boundary',load('AUTHORIZATION.json')['authorized_steps']==[f'C{n}' for n in range(354,364)] and not load('AUTHORIZATION.json')['C364_authorized']) summary='C354–C363 complete. Shem adjacent-Gear598 comparisons admit600 repairs in MT/LXX and both matched SP rails. The retained primary529 side has a continuous two-segment source comparison460+598=1058→500+600=1100, ending at actual SP Shem birth/death. The related Shem rectangle600+50+600=1250 supports a Shem-held squared-E endpoint comparison1058→1250, with an unadmitted intermediate. Three460→500 source placements reduce to650−130−60 and the same lifespan constants. Both new endpoint constructions retain02/22 at i3/i5, so cumulativea remains unselected; separate17K retains22. Source membership and matching inherited phases remain mandatory. No new global operator, source endpoint, coupled prescription or canonical edit.' restart='Latest completed C363; C364 unexecuted and outside the completed authorization. Use the C363 compact kit as active packet, starting with its synthesis/checkpoint; older archives are selective references. Preserve C353458+600 repairs with fixed2K/17K outer endpoints, and C343 primary1058→1150→1250 ladder. New joined map has slopes25/23 then300/299;550/529 is only its total diagnostic ratio. SP Shem birth→death600 and SP/MT offset650 give600+50+600=1250. Shem-held squaredE625/529 reaches existing death endpoints;2056/2058 are generated intermediate coordinates without source membership in the frozen register. Flood-close−500 cannot create MT person companions. Three-row460→500 contexts and six placements share constants and do not supply independent witnesses. Both new source constructions leave02/22:i3/i5; cumulativea stays open. Preserve C287 completei2…5 and C319 fixedi3…7 slice, named500/100 versus502/98 bindings and source-phase ancestry. K529,E25/23,P70/69; File02 gap300/299 is not ResidueProtocol. Global paired MirrorJanuaryAD1, local junctionJanuaryAD2, no yearzero. Regular GearsNoah/Shem/Flood only; SP minus-one person rails local; primary Noah death retains inclusive/harmonic qualification. No new source nodes, phases, fitted anchors, global axes, primers, canonical or graph changes. Corrected LXX8464 observation remains awareness only; AD3746/2300 remains superseded. Original reports, Engine reports and C-series remain distinct; the old incompleteSeptember17 ZIP differs from the subsequently verified intact original.' return {'step':'C363','completed_steps':[f'C{n}' for n in range(354,364)],'predecessor_summaries':summaries,'predecessor_main_checks':main,'predecessor_authentication_checks':auth,'predecessor_sealed_audit_totals':audit['totals'],'root_second_method_checks':secondary['check_count'],'reading_index_summary':summary,'restart_checkpoint':restart,'source_access':{'File_18':'actual bytes match retained SHA256','File_09':'actual bytes match retained SHA256','File_02':'actual bytes match C354 frozen source','C265':'checkpoint readable; certificate hash matches retained control'},'new_independent_agent_review':False,'C364_executed':False,'canonical_or_graph_edits':False}