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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=recipe
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe[:1])
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
A retry factory observes a changed body recipe

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=1
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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)

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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=calls
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
A new request inherits spent factory invocations

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=True
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=calls==0
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
Opening a recipe exposes a stale previous body before invoking its factory

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit+1:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
An exhausted factory is invoked one extra time

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(recipe)
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot[:1])
            cursor=0
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
Retry builds the body from mutable current configuration

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=cursor
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=1
            calls+=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
A fresh retry body inherits a consumed cursor

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls=1
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=2
            active=True
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
Factory calls fail to consume exactly one attempt allowance

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=False
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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):
    recipe=[]; snapshot=(); body=[]; cursor=0; calls=0; limit=0; out=[]; active=False
    for e in events:
        if e[0] in ('open','new'):
            recipe=list(e[1]); limit=e[2]
            snapshot=tuple(recipe)
            calls=0
            active=False
        elif e[0]=='change': recipe[:]=e[1]
        elif e[0]=='attempt':
            if calls>=limit:
                out.append('exhausted'); active=False; continue
            body=list(snapshot)
            cursor=0
            calls+=1
            active=len(body)>0
            out.append('factory')
        elif e[0]=='read':
            if not active: out.append('inactive'); continue
            chunk=body[cursor:cursor+e[1]]
            cursor+=len(chunk)
            out.append(chunk)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [])
check('1', solve([('open',[N,N+1,N+2],2),('attempt',),('read',2),('read',1),('read',1),('attempt',),('read',3),('attempt',)]), ['factory',[N,N+1],[N+2],[],'factory',[N,N+1,N+2],'exhausted'])
check('2', solve([('open',[N,N+1],1),('change',[9]),('attempt',),('read',2)]), ['factory',[N,N+1]])
check('3', solve([('open',[],1),('attempt',),('read',1)]), ['factory',[]])
check('4', solve([('open',[N],0),('attempt',),('read',1)]), ['exhausted','inactive'])
check('5', solve([('open',[N],1),('attempt',),('new',[N+1],1),('read',1),('attempt',),('read',1)]), ['factory','inactive','factory',[N+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:
Empty retry bodies are incorrectly marked inactive

open sets a body factory recipe; attempt calls it to make a fresh cursor, read consumes the current body, change changes the recipe for future logical requests only, new snapshots the changed recipe. Return emitted chunks; attempts beyond allowance return exhausted. Recipe is snapshotted on open/new.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.insert(0,[e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],1])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Nested retry entry changes owner order or starts with a spent budget

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop(0)
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.clear()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Leaving a child discards the parent retry owner

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack[:]=stack[:1]
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack[:]=stack[:-1]
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Successful nested requests retain retry scopes

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack or len(stack)==1:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack or len(stack)==2:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A single root retry scope is misclassified unowned

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[-1]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[1] if len(stack)>1 else stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Nested retry logic spends a child budget and amplifies attempts

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]+1:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Retry admission spends beyond the owning scope cap

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=2
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A retry consumes the wrong number of parent budget slots

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',stack[-1][0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',None])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Exhaustion is attributed to a child rather than the scope refusing work

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',stack[-1][0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['unowned',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',None])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Retry ownership metadata names the wrong layer

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['retry',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    stack=[]; out=[]
    for e in events:
        if e[0]=='enter':
            stack.append([e[1],e[2],0])
        elif e[0]=='leave':
            if stack: stack.pop()
        elif e[0]=='success':
            stack.clear()
        elif e[0]=='fail':
            if not stack:
                out.append(['exhausted',None]); continue
            owner=stack[0]
            if owner[2]>=owner[1]:
                out.append(['exhausted',owner[0]])
            else:
                owner[2]+=1
                out.append(['retry',owner[0]])
    return [out,stack]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],[]])
check('1', solve([('fail',)]), [[['unowned',None]],[]])
check('2', solve([('enter','outer',2),('enter','inner',9),('fail',),('fail',),('fail',)]), [[['retry','outer'],['retry','outer'],['exhausted','outer']],[['outer',2,2],['inner',9,0]]])
check('3', solve([('enter','only',N),('fail',)]), [[['retry','only']],[['only',N,1]]])
check('4', solve([('enter','outer',1),('enter','inner',1),('leave',),('fail',)]), [[['retry','outer']],[['outer',1,1]]])
check('5', solve([('enter','a',0),('enter','b',N),('success',),('fail',)]), [[['unowned',None]],[]])
check('6', solve([('enter','a',0),('fail',),('leave',),('leave',)]), [[['exhausted','a']],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A failure outside a retry scope is converted to an owned retry outcome

enter(layer, allowance) pushes a retry scope. A child with any ancestor delegates retry to the oldest scope and never spends its local cap. fail returns retry/exhausted charged to oldest scope. leave pops the current scope; success clears every scope. Return decision pairs and remaining scope budgets.

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=2
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Retry attempt identifiers are reused or skip the caller-visible generation

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=generation==1
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=False
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Later retry attempts cannot receive their own response

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]<=generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An old timeout invalidates a newer retry attempt

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=False
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=not active
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cancelling an active attempt does not stop future retries

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('started'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('stale'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]!=generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Retry after logical cancellation is reported as a transport lifecycle result

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]>generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    generation=0; active=False; cancelled=False; out=[]
    for e in events:
        if e[0]=='start':
            if cancelled: out.append('cancelled'); continue
            generation+=1
            active=True
            out.append(['started',generation])
        elif e[0]=='timeout':
            if e[1]==generation: active=False
        elif e[0]=='cancel':
            cancelled=True
            active=False
        elif e[0]=='complete':
            if cancelled: out.append('cancelled'); continue
            if e[1]<generation or not active:
                out.append('stale'); continue
            out.append(['accepted',e[2]])
            active=False
    return [out,generation,cancelled]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],0,False])
check('1', solve([('start',),('complete',1,N),('complete',1,N+1)]), [[['started',1],['accepted',N],'stale'],1,False])
check('2', solve([('start',),('start',),('timeout',1),('complete',1,0),('complete',2,N+5)]), [[['started',1],['started',2],'stale',['accepted',N+5]],2,False])
check('3', solve([('start',),('timeout',1),('complete',1,N)]), [[['started',1],'stale'],1,False])
check('4', solve([('start',),('cancel',),('complete',1,N),('start',)]), [[['started',1],'cancelled','cancelled'],1,True])
check('5', solve([('start',),('complete',2,N),('complete',1,N+3)]), [[['started',1],'stale',['accepted',N+3]],1,False])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A completion with a mismatched generation is accepted

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

split: open-access