from pathlib import Path import json,hashlib,zipfile,runpy,shutil BASE=Path('/workspace/scratch/2cd312e78692');W=BASE/'handoff_C479_work';D=BASE/'deliverables';DATE='20260925' def get(p):return json.loads(p.read_text()) def dump(p,x):p.parent.mkdir(parents=True,exist_ok=True);p.write_text(json.dumps(x,ensure_ascii=False,indent=2)+'\n') def sha(p): h=hashlib.sha256() with p.open('rb') as f: while chunk:=f.read(1024*1024):h.update(chunk) return h.hexdigest() docs=get(W/'DOCUMENTS.json');loc=get(D/f'490d_C01_C479_Report_Evidence_Locator_{DATE}.json');coverage=get(W/'coverage/C266_C479_COVERAGE.json') assert len(loc['records'])==479 and not loc['C480_executed'] and not (BASE/'axis_ledger_work/C480').exists() assert not coverage['summary']['failed_packets'] common={} def add(mapping,name,path): path=Path(path);assert path.is_file(),path if name in mapping:assert sha(path)==sha(mapping[name]),name mapping[name]=path for x in docs: p=Path(x['path']);assert sha(p)==x['sha256'];add(common,p.name,p) add(common,'verify_handoff_package.py',D/f'490d_C479_Verify_Handoff_Package_{DATE}.py') for name,path in { 'controls/FILE_18.md':'project_sources/40-File_18.Chronological_Data_Tables-20260919-141048-.md', 'controls/FILE_09.md':'project_sources/32-File_09.Cumulative_Architecture-9-.md', 'controls/FILE_02.md':'project_sources/18-File_02.Flood_Sumerian_Integration-2-.md', 'controls/FILE_46.md':'project_sources/21-File_46.Harmonic_Expansion_Protocols-1-.md', 'controls/FILE_11.md':'project_sources/25-File_11.Three_Gear_Protocol_Harmonic_Engine-1-.md', 'controls/C265_CERTIFICATE.json':'axis_ledger_work/C479/sources/C265_CERTIFICATE.json', 'controls/C265_CHECKPOINT.md':'axis_ledger_work/C479/sources/C265_CHECKPOINT.md', 'controls/C127_GRAPH.json':'active_c265/active/graph/C127_GRAPH.json', 'reference/490d_Fifth_Handoff_C265_20260923.md':'active_c265/490d_Fifth_Handoff_C265_20260923.md', 'reference/490d_C265_User_Direction_Ledger_20260923.md':'active_c265/490d_C265_User_Direction_Ledger_20260923.md', 'reference/490d_C01_C265_Report_Locator_20260923.json':'active_c265/490d_C01_C265_Report_Locator_20260923.json', 'reference/490d_C265_Compact_Restart_Kit_20260923.zip':'upload/490d_C265_Compact_Restart_Kit_20260923(1).zip', 'incoming/490d_Comprehensive_4232_8464_12696_Mirror_Axis_Report_20260924.md':'upload/490d_Comprehensive_4232_8464_12696_Mirror_Axis_Report_20260924.md', 'incoming/490d_Mirror_Axis_4232_8464_12696_20260924.svg':'doublecheck_C479/recovered_figure/490d_Mirror_Axis_4232_8464_12696_20260924.svg', 'incoming/490d_SKL_529_Appendix_for_Astra_20260925.md':'upload/490d_SKL_529_Appendix_for_Astra_20260925.md', 'incoming/490d_Supplement_LXX_8464_Creation_Jared_Correction_20260924.md':'axis_ledger_work/C275/490d_Supplement_LXX_8464_Creation_Jared_Correction_20260924.md', 'incoming/SUPPLEMENTAL_STUDIES_INTAKE_AFTER_C311.md':'handoff_C479_work/coverage/packets/C312/sources/SUPPLEMENT_INTAKE.md', 'audit/ACCESS_ARCHIVE_VERIFICATION.json':'handoff_C479_work/integrity/ACCESS_ARCHIVE_VERIFICATION.json', 'audit/C266_C479_COVERAGE.json':'handoff_C479_work/coverage/C266_C479_COVERAGE.json', 'audit/C266_C479_REPORT_LOCATOR.json':'handoff_C479_work/coverage/C266_C479_REPORT_LOCATOR.json', 'audit/PUBLISHED_EVIDENCE_INDEX.json':'handoff_C479_work/coverage/PUBLISHED_EVIDENCE_INDEX.json', 'audit/BATCH_RECORDS_INDEX.json':'handoff_C479_work/coverage/BATCH_RECORDS_INDEX.json', 'audit/SUPPLEMENTAL_BUNDLE_VERIFICATION.json':'handoff_C479_work/SUPPLEMENTAL_BUNDLE_VERIFICATION.json', 'audit/CONTINUITY_REVIEW.md':'handoff_C479_work/continuity/CONTINUITY_REVIEW.md', 'audit/verify_access_archives.py':'handoff_C479_work/integrity/verify_access_archives.py', 'audit/audit_coverage.py':'handoff_C479_work/coverage/audit_coverage.py', 'audit/collect_published.py':'handoff_C479_work/coverage/collect_published.py', 'audit/prepare_handoff.py':'handoff_C479_work/prepare_handoff.py', 'audit/build_handoff.py':'handoff_C479_work/build_handoff.py', }.items():add(common,name,BASE/path) supp=get(W/'SUPPLEMENTAL_BUNDLE_VERIFICATION.json') add(common,'incoming/490d_Supplemental_Studies_Bundle_20260924.zip',Path(supp['current_path'])) for p in sorted((BASE/'project_sources').glob('*.md')):add(common,'project_sources/'+p.name,p) assert sum(n.startswith('project_sources/') for n in common)==40 for p in sorted((BASE/'axis_ledger_work/provenance').glob('*.md')):add(common,'incoming/earlier_branch_context/'+p.name,p) for p in sorted((W/'coverage/batch_records').iterdir()):add(common,'reference/batch_records/'+p.name,p) # Carry final recent recovery metadata (already verified/published) without private transfer logs. for name in ['490d_C470_C479_Reading_Index_20260925.md','490d_C470_C479_Completion_and_Integrity_20260925.json','490d_C445_C469_Completion_and_Integrity_20260925.json']: add(common,'reference/recent_recovery/'+name,D/name) compact=dict(common);full=dict(common) selected=[266,273,275,276,286,287,310,429,434,466,469] milestones=[273,275,276,287,310,313,323,333,343,353,363,373,383,393,403,413,423,433,434,444,469] for r in loc['records'][265:]: n=int(r['step'][1:]);root=W/'coverage/packets'/r['step'] for p in sorted(root.rglob('*')): if p.is_file(): rel=p.relative_to(root).as_posix();add(full,f'packets/C{n}/{rel}',p) if n>=470:add(compact,f'active/C{n}/{rel}',p) elif n in selected:add(compact,f'reference/packets/C{n}/{rel}',p) rp=root/Path(r['full_archive_report']).name if n<470:add(compact,'recent_reports/'+rp.name,rp) if n in milestones: cp=root/Path(r['full_archive_checkpoint']).name;add(compact,'milestone_checkpoints/'+cp.name,cp) evidence=get(W/'coverage/PUBLISHED_EVIDENCE_INDEX.json') assert evidence['summary']['original_published_evidence_zips']==214 and not evidence['summary']['missing_original_zips'] for r in evidence['records']: p=BASE/r['local_path'];assert sha(p)==r['sha256'];add(full,'published_evidence/'+r['canonical_basename'],p) add(full,'reference/490d_C01_C265_Complete_Window_Archive_20260923.zip',BASE/'upload/490d_C01_C265_Complete_Window_Archive_20260923(1).zip') add(full,'reference/490d_Complete_Study_Handoff_20260917.zip',BASE/'upload/490d_Complete_Study_Handoff_20260917(3).zip') mapfile=W/'COMPACT_FILE_MAP.json' dump(mapfile,{'purpose':'Exact compact selection and its source paths; absolute paths are historical provenance only.','latest_completed':'C479','C480_executed':False,'files':[{'compact_path':n,'source_path':str(p.relative_to(BASE)),'bytes':p.stat().st_size,'sha256':sha(p)} for n,p in sorted(compact.items())]}) add(compact,'COMPACT_FILE_MAP.json',mapfile);add(full,'COMPACT_FILE_MAP.json',mapfile) readfirst=W/'READ_FIRST.md' readfirst.write_text('''# Sixth handoff — continue from C479 Read 490d_Sixth_Handoff_C479_20260925.md first, then the reading guide, archive verification, correction ledger and report/evidence locator. C479 is complete. C480 has not been executed. This handoff performs no new research. The compact kit is the active packet. Its complete latest packets are under active/C470 through active/C479; immediate C480 inputs are already frozen in C470. The full archive is a selective reference library: packets/C266 through packets/C479, plus intact C01–C265 and September17 archives under reference/. Use the locator to distinguish outer containers from inner member paths. All479 reports/results are located. Original unprefixed reports and Engine reports remain separate. Verify actual access to File_18, File_09 and the C479 checkpoint; return a brief access/status summary and small restart checkpoint, then wait for Dean's instruction unless he has already authorized research. The next bounded question is the existing1150 source grammar, not the superseded original C266 AD1905–1911 proposal. Keep Mirror/529 focus and regular Gears Noah/Shem/Flood only. Current scope and corrections override all historical next-step paragraphs. The September17 original is intact. No civil yearzero, imported person companions, new dates/pivots/phases/global axes, cumulative Gears or primer reopening follows from this packet. Run python3 verify_handoff_package.py ARCHIVE.zip for artifact verification only. Use a selected packet README for any separately authorized research replay. Do not run old upload/orchestration scripts. ''') add(compact,'READ_FIRST.md',readfirst);add(full,'READ_FIRST.md',readfirst) def package(path,items,kind): rows=[{'path':n,'bytes':p.stat().st_size,'sha256':sha(p)} for n,p in sorted(items.items())] manifest={'title':'490d sixth handoff after C479','kind':kind,'date_UTC':'2026-09-25','latest_completed':'C479','C480_executed':False,'files':rows,'research_reexecuted':False} temporary=W/(path.name+'.building') with zipfile.ZipFile(temporary,'w',compression=zipfile.ZIP_DEFLATED,compresslevel=9,allowZip64=True) as z: for n,p in sorted(items.items()):z.write(p,n,compress_type=zipfile.ZIP_STORED if p.suffix.lower()=='.zip' else zipfile.ZIP_DEFLATED) z.writestr('PACKAGE_MANIFEST.json',json.dumps(manifest,ensure_ascii=False,indent=2)+'\n') temporary.replace(path) verifier=runpy.run_path(str(D/f'490d_C479_Verify_Handoff_Package_{DATE}.py'))['verify'] result=verifier(path);result['kind']=kind print(json.dumps({'built':path.name,'bytes':result['bytes'],'payloads_verified':result['payloads_verified']}),flush=True) return result compact_path=D/f'490d_C479_Sixth_Handoff_Compact_Restart_Kit_{DATE}.zip' full_path=D/f'490d_C01_C479_Complete_Window_Archive_{DATE}.zip' cm=package(compact_path,compact,'active working packet') fm=package(full_path,full,'complete C01–C479 reference with intact older libraries') # Resolve every locator report/result route from the final artifact layout. with zipfile.ZipFile(full_path) as z,zipfile.ZipFile(BASE/'upload/490d_C01_C265_Complete_Window_Archive_20260923(1).zip') as historic: for r in loc['records']: source=historic if r['archive_container_chain'] else z for field,digest in [('full_archive_report','report_sha256'),('full_archive_results','results_sha256')]:assert hashlib.sha256(source.read(r[field])).hexdigest()==r[digest],r['step'] with zipfile.ZipFile(compact_path) as z: for r in loc['records'][265:]:assert hashlib.sha256(z.read(r['compact_report'])).hexdigest()==r['report_sha256'] assert not (BASE/'axis_ledger_work/C480').exists() receipts=D/f'490d_C479_Handoff_Package_Receipts_{DATE}.json' record={'handoff_number':6,'latest_completed':'C479','C480_executed':False,'date_UTC':'2026-09-25','artifacts_verified_not_research_rerun':True,'numbered_reports':479,'numbered_results':479,'new_packets':214,'original_published_evidence_zips':214,'no_missing_numbered_reports':True,'archives':[cm,fm],'documents':docs,'verifier':{'path':str(D/f'490d_C479_Verify_Handoff_Package_{DATE}.py'),'sha256':sha(D/f'490d_C479_Verify_Handoff_Package_{DATE}.py')},'intact_September17_sha256':'a24741428ab6b1f88577b4571597b442dd35d069664e56dd1e29c3c354157a19','C479_certificate_sha256':sha(BASE/'axis_ledger_work/C479/CERTIFICATE.json'),'all_locator_report_and_result_paths_verified':True,'all_compact_recent_reports_verified':True,'file_receipt_does_not_hash_itself':True} record['double_check_correction']={'description':'Restored the original schematic SVG linked by the incoming 529-axis report, adjacent to the unchanged Markdown report in both packages. No research text, source file, numbered packet, locator, checkpoint, or next-step decision changed.','figure_path':'incoming/490d_Mirror_Axis_4232_8464_12696_20260924.svg','figure_bytes':21261,'figure_sha256':'94ad0018d60a8fecec7601f161201abf4d6140a698fe5202da97a841c2f2ddaf','original_figure_library_file_id':'libfile_7db95f5fc56c8191ab4291102f6caff1'} dump(receipts,record) paths=[Path(x['path']) for x in docs]+[D/f'490d_C479_Verify_Handoff_Package_{DATE}.py',compact_path,full_path,receipts] dump(W/'HANDOFF_BUILD_RESULT.json',{'artifacts':[{'path':str(p),'name':p.name,'bytes':p.stat().st_size,'sha256':sha(p)} for p in paths],'archives':[cm,fm],'C480_executed':False}) dump(W/'PRIVATE_UPLOAD_REQUEST.json',{'uploads':[{'local_path':str(p),'purpose':'create_library_file'} for p in paths]}) print(json.dumps({'handoff_artifacts':len(paths),'all479_report_result_routes_verified':True,'all214_compact_reports_verified':True,'C480_executed':False}),flush=True)