"""Synthetic planning scenarios, not timings from an executed restore drill.""" import csv,json from pathlib import Path p=Path(__file__).parent phases=[('Detect',4),('Decide',6),('Provision',8),('Restore data',15),('Validate',12),('Cut over',6)] cases=[] for name,restore,gap in [('Baseline',15,8),('Faster restore',8,8),('Fresher point',15,3),('Both changes',8,3)]: elapsed=sum(v for k,v in phases if k!='Restore data')+restore cases.append(dict(scenario=name,restore_minutes=restore,elapsed_minutes=elapsed,recoverable_gap_minutes=gap,rto_target_minutes=45,rpo_target_minutes=5,time_target_met=elapsed<=45,point_target_met=gap<=5)) assert [(c['elapsed_minutes'],c['recoverable_gap_minutes']) for c in cases]==[(51,8),(44,8),(51,3),(44,3)] assert [c['time_target_met'] and c['point_target_met'] for c in cases]==[False,False,False,True] result=dict(kind='synthetic planning arithmetic',failure_time='12:00',baseline_recoverable_point='11:52',baseline_service_ready='12:51',phases=[dict(name=k,minutes=v) for k,v in phases],cases=cases) (p/'drill-calculations.json').write_text(json.dumps(result,indent=2)+'\n') with (p/'drill-cases.csv').open('w',newline='') as f: w=csv.DictWriter(f,fieldnames=cases[0]);w.writeheader();w.writerows(cases) print(json.dumps(cases,indent=2))