import json,itertools from fractions import Fraction SLUG='authorization-revocation-time';KIND='Constructed analytical model; not a measured benchmark' def mean_window(d,t):return d+t/2 def tail(d,t,b):return float(d>b) if t==0 else max(0,min(1,(d+t-b)/t)) def permission(revision):return revision<2 def run(): checks=[];cases=0 for d in (0,1,3): for t in (0,1,2,4,8,16): points=[Fraction(d)+Fraction(2*j+1,2000)*t for j in range(1000)] assert sum(points)/1000==Fraction(d)+Fraction(t,2) for b in (0,1,3,5,10,25): observed=sum(x>b for x in points)/1000 assert abs(observed-tail(d,t,b))<=0.001 cases+=1 checks.append(dict(name='Exact midpoint expectation and tail enumeration',passed=True,cases=cases,detail='Uniform residual phase, six budgets, three propagation delays, six objectives; tail discretization tolerance 0.001.')) stale_allow=permission(1);new_content_revision=3 assert stale_allow and not permission(new_content_revision) checks.append(dict(name='New-content fence counterexample',passed=True,cases=2,detail='Revision-one allow exposes revision-three content; check at its revision-three fence denies after revision-two revoke.')) allow_at_check=permission(1);allow_at_use=permission(2) assert allow_at_check and not allow_at_use checks.append(dict(name='Check-use race survives fresh initial check',passed=True,cases=1,detail='A revision-one check is fresh when made, but a revision-two revocation precedes use.')) periods=[0,1,2,4,8,16] figures=[dict(id='mean-exposure',title='Sequential propagation and refresh delay',x_label='Cache refresh period T (seconds)',y_label='Mean exposure (seconds)',series=[dict(name='Propagation 0 seconds',x=periods,y=[mean_window(0,t) for t in periods]),dict(name='Propagation 1 second',x=periods,y=[mean_window(1,t) for t in periods])],caption='Constructed W=d+U with uniform U between zero and T; this is not a universal cache model.',assumptions=['Propagation then a residual refresh timer','Uniform phase','No extra replica delay'],kind=KIND),dict(id='exposure-tail',title='Timer phases missing a five-second objective',x_label='Cache refresh period T (seconds)',y_label='Fraction with exposure above 5 seconds',series=[dict(name='Propagation 1 second',x=periods,y=[tail(1,t,5) for t in periods])],caption='Exact tail for the declared sequential mechanism, not a measured unauthorized-request rate.',assumptions=['One-second fixed propagation','Uniform phase','Objective five seconds'],kind=KIND)] return dict(slug=SLUG,checks=checks,figures=figures,result_summary=dict(mean_T8_d1=5,tail_T8_d1_over5=0.5,mean_T16_d1=9,tail_T16_d1_over5=0.75,zero_cache_exposure_d1=1)) if __name__=='__main__':print(json.dumps(run(),indent=2))