from simulate import simulate import json from pathlib import Path # Exact no-surprise budget: initial100 + renewals at7/14/21, no reset at horizon28. a=simulate([], 'reserve',10,30,7,'fixed',0) assert abs(a['total_done']-400)<1e-6 and abs(a['essential_done']-280)<1e-6 assert abs(a['optional_done']-120)<1e-6 # No-demand workload does not manufacture consumption. a=simulate([1.25,2.5], 'reserve',0,0,7,'restart',0) assert a['total_done']==0 and a['terminal_balance']==100 # Replenishment replaces, rather than adds to, residual capacity. a=simulate([1], 'greedy',0,10,7,'fixed',0) assert abs(a['auto_unused']-90)<1e-6 # Expired tickets do not remain as stock or count as redeemed. a=simulate([], 'reserve',0,0,7,'fixed',2) assert a['tickets_expired']==2 and a['tickets_used']==0 and a['tickets_unspent']==0 # Finite tickets can support optional frontloading without sacrificing essential work. a=simulate([], 'reserve_bank',10,30,7,'restart',2) assert a['essential_missed']<1e-6 and a['tickets_used']==2 and a['optional_done']>120 # All published scenarios agree with stated zero misses; output has full conservation assertions. d=json.loads((Path(__file__).parent/'simulation_results.json').read_text()) assert len(d['replays'])==144 and sum(r['n'] for r in d['replays'])==9072 assert all(r['any_essential_miss']==0 for r in d['replays'] if r['policy'] in ('reserve','reserve_bank')) assert all(r['initial_tickets']==0 for r in d['replays'] if r['provider']=='claude') e=json.loads((Path(__file__).parent/'events_public.json').read_text()) assert sum(x['count_main'] for x in e)==28 assert all(x['original_checked'] for x in e if x['count_main']) print('PASS: budget conservation, demand balance, expiry, reset replacement, finite-credit stress, scenario totals, public evidence')