broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    ordinary=0; refresh=0; generation=0; waiting=False; terminal=True; out=[]
    for e in events:
        if e[0]=='begin': ordinary=e[1]; refresh=e[2]; generation=0; waiting=False; terminal=False
        elif e[0]=='success': terminal=False; waiting=False
        elif e[0]=='network':
            if terminal: out.append('terminal'); continue
            if waiting: out.append('waiting'); continue
            if ordinary==0: out.append('exhausted'); continue
            ordinary-=1; out.append('retry')
        elif e[0]=='challenge':
            if terminal: out.append('terminal'); continue
            if waiting: out.append('coalesced'); continue
            if refresh==0: out.append('auth-exhausted'); continue
            refresh-=1; generation+=1; waiting=True
            out.append(['refresh',generation])
        elif e[0]=='refreshed':
            if terminal or not waiting or e[1]!=generation: out.append('stale'); continue
            waiting=False; out.append('auth-replay')
    return [out,ordinary,refresh]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,0])
check('1', solve([('begin',2,1),('network',),('challenge',),('network',),('challenge',),('refreshed',1),('refreshed',1),('network',),('network',),('challenge',)]), [['retry',['refresh',1],'waiting','coalesced','auth-replay','stale','retry','exhausted','auth-exhausted'],0,0])
check('2', solve([('begin',0,2),('challenge',),('refreshed',1),('challenge',),('refreshed',1),('refreshed',3),('refreshed',2)]), [[['refresh',1],'auth-replay',['refresh',2],'stale','stale','auth-replay'],0,0])
check('3', solve([('begin',N,1),('challenge',),('success',),('refreshed',1),('network',),('challenge',)]), [[['refresh',1],'stale','terminal','terminal'],N,0])
check('4', solve([('begin',0,0),('network',),('challenge',)]), [['exhausted','auth-exhausted'],0,0])
check('5', solve([('begin',1,1),('challenge',),('begin',0,1),('challenge',),('refreshed',1)]), [[['refresh',1],['refresh',1],'auth-replay'],0,0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    ordinary=0; refresh=0; generation=0; waiting=False; terminal=True; out=[]
    for e in events:
        if e[0]=='begin': ordinary=e[1]; refresh=e[2]; generation=0; waiting=False; terminal=False
        elif e[0]=='success': terminal=ordinary==0; waiting=False
        elif e[0]=='network':
            if terminal: out.append('terminal'); continue
            if waiting: out.append('waiting'); continue
            if ordinary==0: out.append('exhausted'); continue
            ordinary-=1; out.append('retry')
        elif e[0]=='challenge':
            if terminal: out.append('terminal'); continue
            if waiting: out.append('coalesced'); continue
            if refresh==0: out.append('auth-exhausted'); continue
            refresh-=1; generation+=1; waiting=True
            out.append(['refresh',generation])
        elif e[0]=='refreshed':
            if terminal or not waiting or e[1]!=generation: out.append('stale'); continue
            waiting=False; out.append('auth-replay')
    return [out,ordinary,refresh]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,0])
check('1', solve([('begin',2,1),('network',),('challenge',),('network',),('challenge',),('refreshed',1),('refreshed',1),('network',),('network',),('challenge',)]), [['retry',['refresh',1],'waiting','coalesced','auth-replay','stale','retry','exhausted','auth-exhausted'],0,0])
check('2', solve([('begin',0,2),('challenge',),('refreshed',1),('challenge',),('refreshed',1),('refreshed',3),('refreshed',2)]), [[['refresh',1],'auth-replay',['refresh',2],'stale','stale','auth-replay'],0,0])
check('3', solve([('begin',N,1),('challenge',),('success',),('refreshed',1),('network',),('challenge',)]), [[['refresh',1],'stale','terminal','terminal'],N,0])
check('4', solve([('begin',0,0),('network',),('challenge',)]), [['exhausted','auth-exhausted'],0,0])
check('5', solve([('begin',1,1),('challenge',),('begin',0,1),('challenge',),('refreshed',1)]), [[['refresh',1],['refresh',1],'auth-replay'],0,0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Success terminal violates retry transition semantics

begin(ordinary retries,refresh allowance) starts a request. network_failure spends ordinary allowance, challenge spends refresh allowance only if no refresh in flight, refreshed(generation) completes only current refresh generation and records auth replay. While refreshing network failures wait. success terminates both budgets; late refresh is ignored. No credentials are represented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]+1; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Deadline anchor violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=e[1]
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=min(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Clock monotonic violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=0; state='queued'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='running'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
New due reset violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='ready'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='failed'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cancel terminal violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed','done'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed','cancelled'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Queue state violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if False: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Queue expiry violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=deadline+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Delay origin violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='ready'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='failed'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Queue single violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('early'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('started'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Wake state violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if False: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Wake expiry violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<=due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if False: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Wake due violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='ready'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='failed'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Running state violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='ready'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Failure state violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>deadline: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if False: state='expired'; out.append('expired'); continue
            state='done'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complete expiry violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='ready'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events):
    now=0; deadline=0; due=None; state='idle'; out=[]
    for e in events:
        if e[0]=='begin':
            now=e[1]; deadline=now+e[2]; due=None; state='ready'
        elif e[0]=='advance': now=max(now,e[1])
        elif e[0]=='cancel': state='cancelled'; due=None
        elif e[0]=='queue':
            if state not in ('ready','failed'): out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            due=now+e[1]; state='queued'; out.append(['queued',due])
        elif e[0]=='wake':
            if state!='queued': out.append('blocked'); continue
            if now>=deadline: state='expired'; due=None; out.append('expired'); continue
            if now<due: out.append('early'); continue
            state='running'; due=None; out.append('started')
        elif e[0]=='fail':
            if state=='running': state='failed'
        elif e[0]=='complete':
            if state!='running': out.append('blocked'); continue
            if now>=deadline: state='expired'; out.append('expired'); continue
            state='running'; out.append('success')
    return [out,deadline,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,'idle'])
check('1', solve([('begin',N,5),('queue',2),('wake',),('advance',N+2),('wake',),('complete',),('queue',0)]), [[['queued',N+2],'early','started','success','blocked'],N+5,'done'])
check('2', solve([('begin',N,2),('queue',2),('advance',N+2),('wake',)]), [[['queued',N+2],'expired'],N+2,'expired'])
check('3', solve([('begin',N,2),('advance',N+2),('queue',0)]), [['expired'],N+2,'expired'])
check('4', solve([('begin',N,2),('queue',0),('wake',),('advance',N+2),('complete',)]), [[['queued',N],'started','expired'],N+2,'expired'])
check('5', solve([('begin',N,5),('queue',0),('wake',),('fail',),('queue',1),('advance',N+1),('wake',),('cancel',),('queue',0)]), [[['queued',N],'started',['queued',N+1],'started','blocked'],N+5,'cancelled'])
check('6', solve([('begin',N,2),('advance',N+3),('advance',N),('queue',0)]), [['expired'],N+2,'expired'])
check('7', solve([('begin',N,3),('cancel',),('fail',),('queue',0)]), [['blocked'],N+3,'cancelled'])
check('8', solve([('begin',N,5),('queue',0),('wake',),('fail',)]), [[['queued',N],'started'],N+5,'failed'])
check('9', solve([('begin',N,5),('cancel',),('wake',)]), [['blocked'],N+5,'cancelled'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Complete terminal violates retry transition semantics

begin(now,budget) pins a logical deadline. advance(time) uses monotonic logical time. queue(delay) schedules retry only for live request, wake starts only after due and strictly before deadline, complete succeeds only for running attempt before deadline. finish/cancel are terminal. Admission at expired time reports expired and closes request; queue never extends deadline. Return scheduling/attempt dispositions.

split: open-access