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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation and not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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:
A timed-out attempt can publish a late success

start allocates a strictly increasing generation. complete(generation,value) publishes only the current active generation and terminates it; duplicate/stale results are rejected. timeout(generation) deactivates only that generation. cancel terminates the logical request permanently. Return accepted/rejected results plus current generation and cancellation flag.

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=True
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=e[2]!=0
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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:
Duplicate completion of the winning attempt is published twice

start allocates a strictly increasing generation. complete(generation,value) publishes only the current active generation and terminates it; duplicate/stale results are rejected. timeout(generation) deactivates only that generation. cancel terminates the logical request permanently. Return accepted/rejected results plus current generation and cancellation flag.

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append(['accepted',e[2]]); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('stale'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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:
A response arriving after cancellation has the wrong terminal disposition

start allocates a strictly increasing generation. complete(generation,value) publishes only the current active generation and terminates it; duplicate/stale results are rejected. timeout(generation) deactivates only that generation. cancel terminates the logical request permanently. Return accepted/rejected results plus current generation and cancellation flag.

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[1]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',generation])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
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:
A fenced retry response returns its attempt identity instead of its payload

start allocates a strictly increasing generation. complete(generation,value) publishes only the current active generation and terminates it; duplicate/stale results are rejected. timeout(generation) deactivates only that generation. cancel terminates the logical request permanently. Return accepted/rejected results plus current generation and cancellation flag.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=str(e[2]),e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body="global",e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
Retry receipts collide across logical operation keys

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[None,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[str(body),'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
Receipt binding loses the original request representation

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'done',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'failed',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
An in-flight retry receipt is treated as committed

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif False:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body and receipts[key][1]=="pending":
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
Reusing an idempotency key for changed content replays an unrelated result

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('new')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('conflict')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
An in-progress operation is duplicated or rejected as a content conflict

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',body])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',None])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
A committed retry returns request data instead of saved response

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and True:
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]!='missing':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
Late duplicate commits overwrite the first durable result

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='pending'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='failed'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
A durable commit remains reported as an in-flight request

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[1]
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=None
        elif e[0]=='forget':
            receipts.pop(e[1],None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Commit stores the operation key instead of its response payload

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.clear()
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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):
    receipts={}; out=[]
    for e in events:
        if e[0]=='submit':
            key,body=e[1],e[2]
            if key not in receipts:
                receipts[key]=[body,'pending',None]
                out.append('new')
            elif receipts[key][0]!=body:
                out.append('conflict')
            elif receipts[key][1]=='pending':
                out.append('pending')
            else:
                out.append(['cached',receipts[key][2]])
        elif e[0]=='commit':
            if e[1] in receipts and receipts[e[1]][1]=='pending':
                receipts[e[1]][1]='done'
                receipts[e[1]][2]=e[2]
        elif e[0]=='forget':
            receipts.pop(e[2] if len(e)>2 else None,None)
    return [out,receipts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],{}])
check('1', solve([('submit','a',N),('submit','a',N)]), [['new','pending'],{'a':[N,'pending',None]}])
check('2', solve([('submit','a',N),('submit','b',N),('submit','a',N+1)]), [['new','new','conflict'],{'a':[N,'pending',None],'b':[N,'pending',None]}])
check('3', solve([('submit','a',N),('commit','a',N+5),('commit','a',99),('submit','a',N),('submit','a',N+1)]), [['new',['cached',N+5],'conflict'],{'a':[N,'done',N+5]}])
check('4', solve([('commit','absent',N),('forget','absent')]), [[],{}])
check('5', solve([('submit','a',N),('submit','b',N+1),('forget','a'),('submit','a',N+2)]), [['new','new','new'],{'b':[N+1,'pending',None],'a':[N+2,'pending',None]}])
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:
Receipt eviction removes other requests or leaves the target replayable

submit(key,body) returns new for absent key, pending for matching in-flight key, conflict for a changed body, and cached(value) for a completed matching key. commit(key,value) commits only existing pending entries. forget removes a receipt. Return decisions and receipt table.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=sorted(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(dict.fromkeys(e[1])); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Retry batch reorders or deduplicates requested positions

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:state.get(k,['pending',None]) for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['success',0] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
A fresh batch inherits completed results from an earlier operation

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: state[k]=['pending',None]; order.append(k)
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: state[k]=['pending',None]; order.insert(0,k)
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
An unsolicited result injects an item into the next retry batch

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0]=='permanent': continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0]=='success' and status=='success': continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Late failures overwrite a successful batch member

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0]=='success': continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0]=='permanent' and status=='permanent': continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
A permanently rejected member reenters the retry set

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',k]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',None]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Successful batch retry loses the returned value

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['retry',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['pending',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Permanent failures are resent in a partial retry

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['permanent',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['success',value]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0] in ('pending','retry')])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Retryable batch failure is prematurely finalized

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access


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

N = 1
observations = []
def solve(events):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0]=='retry'])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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):
    order=[]; state={}; out=[]
    for e in events:
        if e[0]=='open':
            order=list(e[1]); state={k:['pending',None] for k in order}
        elif e[0]=='result':
            k,status,value=e[1:]
            if k not in state: continue
            if state[k][0] in ('success','permanent'): continue
            if status=='success': state[k]=['success',value]
            elif status=='permanent': state[k]=['permanent',None]
            else: state[k]=['retry',None]
        elif e[0]=='retry':
            out.append([k for k in order if state[k][0]=='pending'])
        elif e[0]=='done':
            out.append([state[k][1] if state[k][0]=='success' else None for k in order])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',['b','a','b']),('retry',),('result','b','success',N),('done',),('retry',)]), [['b','a','b'],[N,None,N],['a']])
check('2', solve([('open',['a','b']),('result','a','retry',N),('result','b','permanent',N),('retry',),('done',)]), [['a'],[None,None]])
check('3', solve([('open',['a']),('result','z','success',N),('retry',),('done',)]), [['a'],[None]])
check('4', solve([('open',['a','b']),('result','a','success',N),('result','a','retry',0),('result','b','permanent',0),('result','b','retry',0),('retry',),('done',)]), [[],[N,None]])
check('5', solve([('open',['a']),('result','a','success',N),('open',['a']),('retry',),('done',)]), [['a'],[None]])
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:
Partial retry drops pending or explicitly retryable members

open(list of item IDs) establishes ordered batch. result(id,status,value) records first success, retryable failure, or permanent failure; unknown IDs ignored. retry returns unresolved/retryable items in original order including duplicates. done returns values or null in original positions. Success/permanent terminal entries cannot be overwritten by late responses.

split: open-access