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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held=held
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held={"stale"}
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Configure clears violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if False: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('denied'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Held idempotency violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available<0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available<=1: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Zero denial violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available=0
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=2
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Reserve charge violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add("global")
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(str(e[1])+"suffix")
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Reservation identity violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('held')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('denied')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Reserve result violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.discard("global")
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.clear()
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Commit remove violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.discard("global")
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.clear()
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Abort remove violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+2)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Refund violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity,available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity+len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Refill held violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+1)
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Refill amount violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if True:
                held.discard(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] not in held:
                held.discard(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Unknown abort violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=available+e[1]
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=max(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Refill cap violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=e[1]+1; available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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):
    capacity=0; available=0; held=set(); out=[]
    for e in events:
        if e[0]=='configure':
            capacity=max(1,e[1]); available=capacity; held.clear()
        elif e[0]=='reserve':
            if e[1] in held: out.append('held'); continue
            if available==0: out.append('denied'); continue
            available-=1
            held.add(e[1])
            out.append('reserved')
        elif e[0]=='commit':
            if e[1] in held:
                held.remove(e[1])
        elif e[0]=='abort':
            if e[1] in held:
                held.remove(e[1])
                available=min(capacity,available+1)
        elif e[0]=='refill':
            available=min(capacity-len(held),available+e[1])
    return [out,available,sorted(held)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('configure',3),('reserve','a'),('reserve','b'),('abort','a')]), [['reserved','reserved'],2,['b']])
check('1', solve([('configure',3),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('reserve','a'),('commit','a'),('refill',2)]), [['reserved','reserved','reserved'],2,[]])
check('2', solve([]), [[],0,[]])
check('3', solve([('configure',0),('reserve','a')]), [['denied'],0,[]])
check('4', solve([('configure',2),('reserve','a'),('reserve','a'),('reserve','b'),('reserve','c')]), [['reserved','held','reserved','denied'],0,['a','b']])
check('5', solve([('configure',3),('reserve','a'),('reserve','b'),('commit','a'),('abort','a'),('abort','b'),('abort','b')]), [['reserved','reserved'],2,[]])
check('6', solve([('configure',N+3),('reserve','a'),('refill',N+10)]), [['reserved'],N+2,['a']])
check('7', solve([('configure',4),('reserve','a'),('commit','a'),('reserve','b'),('commit','b'),('refill',1)]), [['reserved','reserved'],3,[]])
check('8', solve([('configure',1),('reserve','a'),('configure',2),('reserve','a')]), [['reserved','reserved'],1,['a']])
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:
Configure capacity violates retry transition semantics

configure(capacity) resets a shared retry pool. reserve(request) consumes one token only for a new reservation; commit spends its token and removes the reservation, abort refunds exactly once, refill is capped. Repeated reserve is idempotent; unknown commit/abort does nothing. Return admissions and available token count.

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if False: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled and e[2]==0: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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:
Cancelled schedule violates retry transition semantics

schedule(id,due) replaces an existing queued retry for that ID. cancel(id) removes it and permanently cancels that logical request. poll(now) starts every due noncancelled retry ordered by due then ID and removes it before execution. finish records completion only for running retries. Cancelling running work removes running status; its late completion is ignored. Return start/finish events and pending/running IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if False: pass
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running and e[2]==0: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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 schedule violates retry transition semantics

schedule(id,due) replaces an existing queued retry for that ID. cancel(id) removes it and permanently cancels that logical request. poll(now) starts every due noncancelled retry ordered by due then ID and removes it before execution. finish records completion only for running retries. Cancelling running work removes running status; its late completion is ignored. Return start/finish events and pending/running IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued.setdefault(e[1],e[2])
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=min(queued.get(e[1],e[2]),e[2])
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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:
Reschedule time violates retry transition semantics

schedule(id,due) replaces an existing queued retry for that ID. cancel(id) removes it and permanently cancels that logical request. poll(now) starts every due noncancelled retry ordered by due then ID and removes it before execution. finish records completion only for running retries. Cancelling running work removes running status; its late completion is ignored. Return start/finish events and pending/running IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.discard(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add("all")
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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 sticky violates retry transition semantics

schedule(id,due) replaces an existing queued retry for that ID. cancel(id) removes it and permanently cancels that logical request. poll(now) starts every due noncancelled retry ordered by due then ID and removes it before execution. finish records completion only for running retries. Cancelling running work removes running status; its late completion is ignored. Return start/finish events and pending/running IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop("all",None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.clear()
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
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 queued violates retry transition semantics

schedule(id,due) replaces an existing queued retry for that ID. cancel(id) removes it and permanently cancels that logical request. poll(now) starts every due noncancelled retry ordered by due then ID and removes it before execution. finish records completion only for running retries. Cancelling running work removes running status; its late completion is ignored. Return start/finish events and pending/running IDs.

split: open-access