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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=sorted(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(reversed(e[1])); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Pool order violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=tried; pin=pin; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=pin; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Request reset violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=False; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=True; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Affinity capture violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.discard(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add("global")
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Health down violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.add(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.clear()
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Health up violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if False: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('exhausted'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Terminal pick violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if False: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('exhausted'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Active pick violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Pin health violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Candidate health violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[-1]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[len(options)//2]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Candidate first violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=None
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=pool[-1]
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Capture pin violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.discard(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(pool[-1])
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Failure tried violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=active
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=pin
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Failure release violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=False; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set()
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=False; active=active
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Success stop violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=down
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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):
    pool=[]; down=set(); tried=set(); pin=None; active=None; affinity=False; terminal=True; out=[]
    for e in events:
        if e[0]=='pool': pool=list(e[1]); down=set(e[1])
        elif e[0]=='begin': tried=set(); pin=None; active=None; affinity=e[2]; terminal=False
        elif e[0]=='down': down.add(e[1])
        elif e[0]=='up': down.discard(e[1])
        elif e[0]=='pick':
            if terminal: out.append('terminal'); continue
            if active is not None: out.append('active'); continue
            if affinity and pin is not None:
                options=[pin] if pin not in down and pin in pool else []
            else: options=[p for p in pool if p not in down and p not in tried]
            if not options: out.append('exhausted'); continue
            active=options[0]
            if pin is None: pin=active
            out.append(active)
        elif e[0]=='fail':
            if active is not None: tried.add(active)
            active=None
        elif e[0]=='success': terminal=True; active=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('pool',['b','a','c']),('begin','r',False),('pick',),('pick',),('fail',),('pick',),('fail',),('pick',),('fail',),('pick',)]), ['b','active','a','c','exhausted'])
check('2', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pick',),('fail',),('down','a'),('pick',)]), ['a','a','exhausted'])
check('3', solve([('pool',['a','b','c']),('down','a'),('down','b'),('up','a'),('begin','r',False),('pick',),('fail',),('pick',)]), ['a','c'])
check('4', solve([('pool',['a','b']),('begin','r',True),('pick',),('fail',),('pool',['b']),('pick',),('begin','s',True),('pick',)]), ['a','exhausted','b'])
check('5', solve([('pool',[N,N+1]),('begin','r',False),('pick',),('success',),('pick',),('begin','s',False),('pick',)]), [N,'terminal',N])
check('6', solve([('pool',['a']),('down','a'),('pool',['a']),('begin','r',False),('pick',)]), ['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:
Pool health reset violates retry transition semantics

pool(endpoint IDs) sets ordered available endpoints. begin(request,affinity bool) resets attempted endpoint set and pin. pick selects first healthy untried endpoint; an affinity request must reuse its first endpoint on subsequent retries while healthy. down/up alter health. fail marks current endpoint attempted and clears active route. success finalizes. No route changes are HTTP redirects. Return chosen endpoint or exhausted/terminal/active.

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[2]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=0; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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:
Threshold capture violates retry transition semantics

open(memory threshold,total limit) begins capturing byte-list chunks. append stores an entire chunk only if total limit permits; crossing memory threshold spills all prior memory and new chunk to modeled disk. fail_disk invalidates captured body. seal finalizes; replay returns captured bytes only when sealed and valid. Overflow is terminal until next open. Return replay decisions and storage mode.

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[1]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]+1; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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:
Total limit violates retry transition semantics

open(memory threshold,total limit) begins capturing byte-list chunks. append stores an entire chunk only if total limit permits; crossing memory threshold spills all prior memory and new chunk to modeled disk. fail_disk invalidates captured body. seal finalizes; replay returns captured bytes only when sealed and valid. Overflow is terminal until next open. Return replay decisions and storage mode.

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=memory; disk=disk; size=size; mode=mode; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode=mode; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
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:
Fresh spool violates retry transition semantics

open(memory threshold,total limit) begins capturing byte-list chunks. append stores an entire chunk only if total limit permits; crossing memory threshold spills all prior memory and new chunk to modeled disk. fail_disk invalidates captured body. seal finalizes; replay returns captured bytes only when sealed and valid. Overflow is terminal until next open. Return replay decisions and storage mode.

split: open-access