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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state=='idle': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state=='overflow': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Capture gate violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>=limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

prompt:
Limit boundary violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='capturing'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='sealed'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Overflow terminal violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>=threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Spill boundary violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=[]; memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(reversed(memory)); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Spill prefix violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='memory'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='failed'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Spill mode violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk[:]=chunk
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(reversed(chunk))
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Disk append violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory[:]=chunk
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(reversed(chunk))
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Memory append violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=1
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Size accounting violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state!='idle': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Seal validity violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='sealed'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='capturing'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk if mode=='disk' else memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Disk failure violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(memory))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    threshold=0; limit=0; memory=[]; disk=[]; size=0; mode='memory'; state='idle'; out=[]
    for e in events:
        if e[0]=='open':
            threshold=e[1]; limit=e[2]; memory=[]; disk=[]; size=0; mode='memory'; state='capturing'
        elif e[0]=='append':
            if state!='capturing': continue
            chunk=list(e[1])
            if size+len(chunk)>limit:
                state='overflow'; memory=[]; disk=[]; continue
            if mode=='memory' and size+len(chunk)>threshold:
                disk=list(memory); memory=[]; mode='disk'
            if mode=='disk': disk.extend(chunk)
            else: memory.extend(chunk)
            size+=len(chunk)
        elif e[0]=='seal':
            if state=='capturing': state='sealed'
        elif e[0]=='fail_disk':
            if mode=='disk': state='io-error'; memory=[]; disk=[]
        elif e[0]=='replay':
            if state!='sealed': out.append(state); continue
            out.append(list(disk))
    return [out,mode]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [[],'memory'])
check('1', solve([('open',3,8),('append',[N,N+1]),('append',[N+2]),('seal',),('replay',)]), [[[N,N+1,N+2]],'memory'])
check('2', solve([('open',2,8),('append',[N,N+1]),('append',[N+2,N+3]),('append',[N+4]),('seal',),('replay',)]), [[[N,N+1,N+2,N+3,N+4]],'disk'])
check('3', solve([('open',2,3),('append',[N,N+1]),('append',[N+2]),('append',[N+3]),('seal',),('replay',)]), [['overflow'],'disk'])
check('4', solve([('open',0,4),('append',[N]),('fail_disk',),('seal',),('replay',),('open',4,4),('append',[N+1]),('seal',),('replay',)]), [['io-error',[N+1]],'memory'])
check('5', solve([('open',2,2),('append',[N]),('replay',),('seal',),('append',[N+1]),('replay',)]), [['capturing',[N]],'memory'])
check('6', solve([('open',0,0),('append',[]),('seal',),('replay',)]), [[[]],'memory'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Replay store violates retry transition semantics

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

split: open-access


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

N = 1
observations = []
def solve(events):
    generation=0; active=False; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=result; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=['cancelled',None]; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Begin result violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None and result[0]=='success': continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None and result[0]=='failure': continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Terminal first violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if generation>1: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Initial launch violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation=0; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=2; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Launch generation violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active and e[1]!=generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Response active violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]>generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]<generation: continue
            active=False
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Response generation violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=True
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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; token=False; result=None
    for e in events:
        if e[0]=='begin': generation=0; active=False; token=False; result=None; continue
        if result is not None: continue
        if e[0]=='launch':
            if active or generation!=0: continue
            generation+=1; active=True
        elif e[0]=='response':
            if not active or e[1]!=generation: continue
            active=e[2] in (429,503)
            if 200<=e[2]<300: result=['success',e[3]]
            elif e[2] in (429,503): token=True
            else: result=['failure',e[2]]
        elif e[0]=='retry':
            if not token or active: continue
            token=False; generation+=1; active=True
        elif e[0]=='cancel':
            result=['cancelled',None]; active=False; token=False
    return [result,generation]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([]), [None,0])
check('1', solve([('begin',),('launch',),('response',1,200,N),('cancel',),('launch',)]), [['success',N],1])
check('2', solve([('begin',),('launch',),('response',1,503,0),('launch',),('retry',),('response',1,200,0),('response',3,200,0),('response',2,204,N)]), [['success',N],2])
check('3', solve([('launch',),('response',1,429,0),('response',1,200,N),('retry',),('response',2,400,N),('cancel',)]), [['failure',400],2])
check('4', solve([('launch',),('cancel',),('response',1,200,N),('retry',)]), [['cancelled',None],1])
check('5', solve([('retry',),('launch',),('response',1,300,N)]), [['failure',300],1])
check('6', solve([('launch',),('response',1,199,N)]), [['failure',199],1])
check('7', solve([('launch',),('response',1,500,N)]), [['failure',500],1])
check('8', solve([('launch',),('response',1,200,0),('begin',),('launch',),('response',1,201,N)]), [['success',N],1])
check('9', solve([('launch',),('response',1,503,N),('launch',)]), [None,1])
check('10', solve([('launch',),('launch',)]), [None,1])
check('11', solve([('retry',)]), [None,0])
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:
Response consumed violates retry transition semantics

begin resets generation and final result. launch creates next active generation; response(generation,status,payload) accepts only current active attempt. A 2xx result completes immediately, retryable statuses 429/503 leave logical request pending with a retry token, other statuses terminally fail. retry consumes token to launch next attempt. cancel wins if no final result. Once final, every later event except begin is ignored. Return result and number of attempts launched.

split: open-access