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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard("all")
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.clear()
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cancel running violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

prompt:
Due inclusive violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted(((due,k) for k,due in queued.items() if due<=e[1]), key=lambda item:item[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted(((due,k) for k,due in queued.items() if due<=e[1]), reverse=True)
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Due order violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.get(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop("all",None)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Dequeue on start violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add("all")
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.discard(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Running mark violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',due])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',None])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Start identity violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: running.add(e[1])
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: out.append(['finish',e[1]]); continue
            running.remove(e[1])
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Finish gate violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.discard("all")
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.clear()
            out.append(['finish',e[1]])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Finish consumption violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish',None])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    queued={}; running=set(); cancelled=set(); out=[]
    for e in events:
        if e[0]=='schedule':
            if e[1] in cancelled: continue
            if e[1] in running: continue
            queued[e[1]]=e[2]
        elif e[0]=='cancel':
            cancelled.add(e[1])
            queued.pop(e[1],None)
            running.discard(e[1])
        elif e[0]=='poll':
            ready=sorted((due,k) for k,due in queued.items() if due<=e[1])
            for due,k in ready:
                queued.pop(k)
                running.add(k)
                out.append(['start',k])
        elif e[0]=='finish':
            if e[1] not in running: continue
            running.remove(e[1])
            out.append(['finish','all'])
    return [out,sorted(queued),sorted(running)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('cancel','a'),('poll',N+5)]), [[],[],[]])
check('1', solve([]), [[],[],[]])
check('2', solve([('schedule','b',N),('schedule','a',N),('poll',N),('poll',N),('finish','a'),('finish','a')]), [[['start','a'],['start','b'],['finish','a']],[],['b']])
check('3', solve([('schedule','a',1),('schedule','a',N+5),('poll',1),('poll',N+5)]), [[['start','a']],[],['a']])
check('4', solve([('schedule','a',1),('schedule','b',2),('cancel','a'),('schedule','a',3),('poll',5)]), [[['start','b']],[],['b']])
check('5', solve([('schedule','a',1),('schedule','b',1),('poll',1),('cancel','a'),('finish','a')]), [[['start','a'],['start','b']],[],['b']])
check('6', solve([('schedule','a',1),('poll',1),('schedule','a',3),('poll',3),('finish','z')]), [[['start','a']],[],['a']])
check('7', solve([('schedule','z',1),('schedule','a',2),('poll',3)]), [[['start','z'],['start','a']],[],['a','z']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Finish identity violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=e[1]
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=min(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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:
Monotonic time violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<0:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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:
Expired replacement violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=old
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=[None,now,False,None]
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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:
Eviction state violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<0: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
New expiry violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,now+expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires+1,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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:
Expiry storage violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>=now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>=0 and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<=now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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 live violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None or old[1]<now: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; records={}; out=[]
    for e in events:
        if e[0]=='at': now=max(now,e[1])
        elif e[0]=='put':
            k,body,expires=e[1:]
            old=records.get(k)
            if old is not None and old[1]<=now:
                records.pop(k); old=None
            if old is None:
                if expires<=now: out.append('expired'); continue
                records[k]=[body,expires,False,None]; out.append('new')
            elif old[0]!=body: out.append('conflict')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
        elif e[0]=='commit':
            old=records.get(e[1])
            if old is not None and old[1]>now and not old[2]:
                old[2]=True; old[3]=e[2]; out.append('committed')
            else: out.append('ignored')
        elif e[0]=='lookup':
            old=records.get(e[1])
            if old is None: out.append('missing')
            elif old[2]: out.append(['cached',old[3]])
            else: out.append('pending')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('lookup','x'),('put','a',N,3),('put','a',N,3),('commit','a',N+9),('commit','a',999),('lookup','a'),('put','a',N,3),('put','a',N+1,3)]), ['missing','new','pending','committed','ignored',['cached',N+9],['cached',N+9],'conflict'])
check('2', solve([('at',3),('put','a',N,3),('put','b',N,2)]), ['expired','expired'])
check('3', solve([('put','a',N,3),('at',3),('commit','a',99),('lookup','a'),('put','a',N+1,5),('lookup','a')]), ['new','ignored','missing','new','pending'])
check('4', solve([('at',4),('put','a',N,6),('at',6),('lookup','a')]), ['new','missing'])
check('5', solve([('put','a',N,2),('at',3),('at',1),('lookup','a')]), ['new','missing'])
check('6', solve([('commit','absent',N),('lookup','absent')]), ['ignored','missing'])
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:
Lookup expired violates retry transition semantics

put(key,body,expires) creates a pending receipt if no live receipt exists at current logical time. Existing live matching key returns pending or cached; mismatched body returns conflict. commit succeeds only for a live pending receipt. at(time) moves monotonic time forward. Expiry at now is expired. lookup(key) reports missing/pending/cached. Return outcomes. Commit appends committed or ignored to expose whether a durable receipt write occurred.

split: open-access


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

N = 1
observations = []
def solve(events):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=(None,e[2],e[3]); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=(e[1],e[2],0); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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:
Identity snapshot violates retry transition semantics

open(file identity,size,mtime,offset) snapshots file metadata and starting byte. inspect(current identity,size,mtime) records current metadata. read(count) advances bounded cursor only while valid. retry compares all snapshot metadata before rewinding; any mismatch permanently invalidates this body. close invalidates. New open resets validity. Return read byte counts and retry dispositions.

split: open-access


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

N = 1
observations = []
def solve(events):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=False
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=snapshot[1]>0
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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:
Open valid violates retry transition semantics

open(file identity,size,mtime,offset) snapshots file metadata and starting byte. inspect(current identity,size,mtime) records current metadata. read(count) advances bounded cursor only while valid. retry compares all snapshot metadata before rewinding; any mismatch permanently invalidates this body. close invalidates. New open resets validity. Return read byte counts and retry dispositions.

split: open-access


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

N = 1
observations = []
def solve(events):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=snapshot
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=(e[1],snapshot[1],e[3])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],max(0,snapshot[1]-cursor))
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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:
Inspect full violates retry transition semantics

open(file identity,size,mtime,offset) snapshots file metadata and starting byte. inspect(current identity,size,mtime) records current metadata. read(count) advances bounded cursor only while valid. retry compares all snapshot metadata before rewinding; any mismatch permanently invalidates this body. close invalidates. New open resets validity. Return read byte counts and retry dispositions.

split: open-access


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

N = 1
observations = []
def solve(events):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=e[1]
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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):
    snapshot=None; current=None; origin=0; cursor=0; valid=False; out=[]
    for e in events:
        if e[0]=='open':
            snapshot=tuple(e[1:4]); current=snapshot
            origin=e[4]; cursor=origin
            valid=True
        elif e[0]=='inspect': current=tuple(e[1:4])
        elif e[0]=='close': valid=False
        elif e[0]=='read':
            if not valid: out.append('invalid'); continue
            amount=min(e[1],snapshot[1])
            cursor+=amount
            out.append(amount)
        elif e[0]=='retry':
            if not valid: out.append('invalid'); continue
            if current!=snapshot:
                valid=False; out.append('changed'); continue
            cursor=origin
            out.append('rewound')
    return [out,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0])
check('1', solve([('open','a',N+5,1,2),('read',2),('read',N+9),('read',1),('retry',),('read',1)]), [[2,N+1,0,'rewound',1],3])
check('2', solve([('open','a',5,1,0),('inspect','b',5,1),('retry',),('read',1)]), [['changed','invalid'],0])
check('3', solve([('open','a',5,1,0),('inspect','a',6,1),('retry',),('retry',)]), [['changed','invalid'],0])
check('4', solve([('open','a',5,1,0),('inspect','a',5,2),('retry',),('inspect','a',5,1),('retry',)]), [['changed','invalid'],0])
check('5', solve([('open','a',0,1,0),('read',1),('retry',),('close',),('read',1),('retry',)]), [[0,'rewound','invalid','invalid'],0])
check('6', solve([('open','a',N+3,1,1),('close',),('open','b',2,2,1),('read',1)]), [[1],2])
check('7', solve([('open','a',N+3,1,1),('inspect','a',N+3,1),('retry',),('close',),('read',1),('retry',)]), [['rewound','invalid','invalid'],1])
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:
Read bound violates retry transition semantics

open(file identity,size,mtime,offset) snapshots file metadata and starting byte. inspect(current identity,size,mtime) records current metadata. read(count) advances bounded cursor only while valid. retry compares all snapshot metadata before rewinding; any mismatch permanently invalidates this body. close invalidates. New open resets validity. Return read byte counts and retry dispositions.

split: open-access