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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.clear()
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines[e[1]]=now+durations.get(e[1],0)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True; deadlines.clear()
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=False
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False; deadlines={k:now+durations.get(k,0) for k in deadlines}
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=True
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: deadlines[e[1]]=now+durations.get(e[1],0); continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<=deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<max(deadlines.values(),default=0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[1]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2][:1]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force'):
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)+1
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0]=='emit':
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    now=0; durations={}; deadlines={}; suspended=False; out=[]
    for e in events:
        if e[0]=='configure': durations[e[1]]=max(0,e[2])
        elif e[0]=='tick': now=max(now,e[1])
        elif e[0]=='reset': deadlines.pop(e[1],None)
        elif e[0]=='suspend': suspended=True
        elif e[0]=='resume': suspended=False
        elif e[0] in ('emit','force') and not suspended:
            if e[0]=='emit' and suspended: continue
            if e[0]=='emit' and now<deadlines.get(e[1],0): continue
            out.append([e[1],e[2]])
            deadlines[e[1]]=now+durations.get(e[1],0)
    return [out,sorted(deadlines.items()),now,suspended]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['configure','a',N],['emit','a','first'],['emit','a','suppressed'],['tick',N],['emit','a','next']]", "[['configure','a',N+4],['configure','b',1],['emit','a','alpha'],['emit','b','beta'],['reset','b'],['emit','a','blocked']]", "[['configure','a',N],['emit','a','first'],['suspend']]", "[['configure','a',N],['emit','a','first'],['suspend'],['emit','c','muted'],['force','b','urgent'],['tick',N+2],['resume'],['emit','a','ready']]", "[['configure','a',N+5],['configure','a',0],['emit','a','first'],['emit','a','second']]", "[['tick',N+3],['tick',1],['configure','a',2],['emit','a','later']]", '[]']
expected = {1: [[[['a', 'first'], ['a', 'next']], [('a', 2)], 1, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 5)], 0, False], [[['a', 'first']], [('a', 1)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 4), ('b', 0)], 3, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 6)], 4, False], [[], [], 0, False]], 2: [[[['a', 'first'], ['a', 'next']], [('a', 4)], 2, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 6)], 0, False], [[['a', 'first']], [('a', 2)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 6), ('b', 0)], 4, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 7)], 5, False], [[], [], 0, False]], 3: [[[['a', 'first'], ['a', 'next']], [('a', 6)], 3, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 7)], 0, False], [[['a', 'first']], [('a', 3)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 8), ('b', 0)], 5, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 8)], 6, False], [[], [], 0, False]], 4: [[[['a', 'first'], ['a', 'next']], [('a', 8)], 4, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 8)], 0, False], [[['a', 'first']], [('a', 4)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 10), ('b', 0)], 6, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 9)], 7, False], [[], [], 0, False]], 5: [[[['a', 'first'], ['a', 'next']], [('a', 10)], 5, False], [[['a', 'alpha'], ['b', 'beta']], [('a', 9)], 0, False], [[['a', 'first']], [('a', 5)], 0, True], [[['a', 'first'], ['b', 'urgent'], ['a', 'ready']], [('a', 12), ('b', 0)], 7, False], [[['a', 'first'], ['a', 'second']], [('a', 0)], 0, False], [[['a', 'later']], [('a', 10)], 8, False], [[], [], 0, False]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated speech-cooldown contract.

Each cue kind has its own cooldown duration. Emit [kind,text] speaks only when now reaches that kinds next allowed time; successful emission sets next to now+duration, suppression does not slide it. Tick is monotone. Configure affects future emissions only. Force speaks and resets its deadline. Reset-kind removes one cooldown history. Suspend blocks normal emission but preserves timestamps; resume enables it. Return output, next deadlines and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(max(0,len(text)-1),e[1]))
        elif op=='silent': silent=e[1]
        elif op=='undo' and history:
            text,cursor=history.pop()
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(len(text),e[1]+1))
        elif op=='silent': silent=e[1]
        elif op=='undo' and history:
            text,cursor=history.pop()
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated edit-narration contract.

Document announcement state stores text and a cursor. Insert inserts at clamped cursor and announces inserted span. Backspace removes up to count before cursor and announces removed span in original order. Delete removes after cursor without moving it. Move clamps cursor. Replace range uses sorted clamped endpoints, announces old/new, moves cursor to replacement end. Undo restores text and cursor from last mutating edit and announces restored text. Silent toggles suppress cues but not state or undo. Return cues,text,cursor.

split: open-access


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

N = 1
observations = []
def solve(events):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(len(text),e[1]))
        elif op=='silent': silent=True
        elif op=='undo' and history:
            text,cursor=history.pop()
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(len(text),e[1]))
        elif op=='silent': silent=not e[1]
        elif op=='undo' and history:
            text,cursor=history.pop()
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated edit-narration contract.

Document announcement state stores text and a cursor. Insert inserts at clamped cursor and announces inserted span. Backspace removes up to count before cursor and announces removed span in original order. Delete removes after cursor without moving it. Move clamps cursor. Replace range uses sorted clamped endpoints, announces old/new, moves cursor to replacement end. Undo restores text and cursor from last mutating edit and announces restored text. Silent toggles suppress cues but not state or undo. Return cues,text,cursor.

split: open-access


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

N = 1
observations = []
def solve(events):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(len(text),e[1]))
        elif op=='silent': silent=e[1]
        elif op=='undo' and history:
            text,cursor=history.pop(0)
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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):
    text=''; cursor=0; history=[]; silent=False; out=[]
    for e in events:
        op=e[0]
        if op=='move': cursor=max(0,min(len(text),e[1]))
        elif op=='silent': silent=e[1]
        elif op=='undo' and history:
            text,cursor=history[-1]
            if not silent: out.append(['undo',text])
        elif op in ('insert','backspace','delete','replace'):
            history.append([text,cursor])
            if op=='insert':
                text=text[:cursor]+e[1]+text[cursor:]; cursor+=len(e[1]); cue=['insert',e[1]]
            elif op=='backspace':
                start=max(0,cursor-e[1]); cue=['remove',text[start:cursor]]
                text=text[:start]+text[cursor:]; cursor=start
            elif op=='delete':
                end=min(len(text),cursor+e[1]); cue=['remove',text[cursor:end]]
                text=text[:cursor]+text[end:]
            else:
                a,b=sorted([max(0,min(len(text),e[1])),max(0,min(len(text),e[2]))])
                cue=['replace',text[a:b],e[3]]; text=text[:a]+e[3]+text[b:]; cursor=a+len(e[3])
            if not silent: out.append(cue)
    return [out,text,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['insert','abcd'*N],['move',2],['insert','XY'],['backspace',2],['undo'],['undo']]", "[['insert','abcdef'*N],['move',4],['backspace',2]]", "[['insert','abcdef'*N],['move',2],['delete',2]]", "[['insert','abcdef'*N],['replace',5,2,'Z']]", "[['insert','abcdef'*N],['replace',5,2,'Z'],['undo']]", "[['silent',True],['insert','secret'*N],['silent',False],['move',99],['insert','!']]", "[['insert','x'*N],['move',-5],['backspace',4],['delete',99],['undo']]", '[]']
expected = {1: [[[['insert', 'abcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcd'], ['undo', 'abcd']], 'abcd', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['remove', 'cd']], 'abef', 2], [[['insert', 'abcdef'], ['replace', 'cde', 'Z']], 'abZf', 3], [[['insert', 'abcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdef']], 'abcdef', 6], [[['insert', '!']], 'secret!', 7], [[['insert', 'x'], ['remove', ''], ['remove', 'x'], ['undo', 'x']], 'x', 0], [[], '', 0]], 2: [[[['insert', 'abcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcd'], ['undo', 'abcdabcd']], 'abcdabcd', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['remove', 'cd']], 'abefabcdef', 2], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdef', 3], [[['insert', 'abcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdef']], 'abcdefabcdef', 12], [[['insert', '!']], 'secretsecret!', 13], [[['insert', 'xx'], ['remove', ''], ['remove', 'xx'], ['undo', 'xx']], 'xx', 0], [[], '', 0]], 3: [[[['insert', 'abcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcd'], ['undo', 'abcdabcdabcd']], 'abcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdef']], 'abcdefabcdefabcdef', 18], [[['insert', '!']], 'secretsecretsecret!', 19], [[['insert', 'xxx'], ['remove', ''], ['remove', 'xxx'], ['undo', 'xxx']], 'xxx', 0], [[], '', 0]], 4: [[[['insert', 'abcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcd']], 'abcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdef', 24], [[['insert', '!']], 'secretsecretsecretsecret!', 25], [[['insert', 'xxxx'], ['remove', ''], ['remove', 'xxxx'], ['undo', 'xxxx']], 'xxxx', 0], [[], '', 0]], 5: [[[['insert', 'abcdabcdabcdabcdabcd'], ['insert', 'XY'], ['remove', 'XY'], ['undo', 'abXYcdabcdabcdabcdabcd'], ['undo', 'abcdabcdabcdabcdabcd']], 'abcdabcdabcdabcdabcd', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['remove', 'cd']], 'abefabcdefabcdefabcdefabcdef', 2], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z']], 'abZfabcdefabcdefabcdefabcdef', 3], [[['insert', 'abcdefabcdefabcdefabcdefabcdef'], ['replace', 'cde', 'Z'], ['undo', 'abcdefabcdefabcdefabcdefabcdef']], 'abcdefabcdefabcdefabcdefabcdef', 30], [[['insert', '!']], 'secretsecretsecretsecretsecret!', 31], [[['insert', 'xxxxx'], ['remove', ''], ['remove', 'xxxxx'], ['undo', 'xxxxx']], 'xxxxx', 0], [[], '', 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
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:
The announcement trace violates the stated edit-narration contract.

Document announcement state stores text and a cursor. Insert inserts at clamped cursor and announces inserted span. Backspace removes up to count before cursor and announces removed span in original order. Delete removes after cursor without moving it. Move clamps cursor. Replace range uses sorted clamped endpoints, announces old/new, moves cursor to replacement end. Undo restores text and cursor from last mutating edit and announces restored text. Silent toggles suppress cues but not state or undo. Return cues,text,cursor.

split: open-access