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

N = 1
observations = []
def solve(events):
    tasks={}; out=[]
    for e in events:
        if e[0]=='start': tasks[e[1]]=[e[2],e[3],0,'running',0]
        elif e[0]=='cancel': tasks.pop(e[1],None)
        elif e[1] in tasks:
            t=tasks[e[1]]
            if e[0]=='rename': t[0]=e[2]
            elif e[0]=='retry': t[2]=0; t[3]='running'; t[4]=0
            elif e[0]=='fail' and t[3]=='running': t[3]='failed'; out.append(t[0]+': failed')
            elif e[0]=='complete' and t[3]=='running': t[3]='complete'; out.append(t[0]+': complete')
            elif e[0]=='advance' and t[3]=='running':
                t[2]=max(t[2],min(e[2],t[1]) if t[1]>=0 else e[2])
                if t[1]<0: out.append(t[0]+': '+str(t[2])+' items')
                elif t[1]>0:
                    bucket=t[2]*4//t[1]
                    if bucket>=t[4]: out.append(t[0]+': '+str(bucket*25)+'%'); t[4]=bucket
    return [out,[[k,v[2],v[3],v[4]] for k,v in tasks.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a','Download',4*N],['advance','a',N],['advance','a',N],['advance','a',0],['advance','a',8*N],['complete','a'],['complete','a']]", "[['start','a','Work',4*N],['advance','a',N],['fail','a'],['advance','a',4*N],['retry','a'],['advance','a',N],['rename','a','Retry'],['complete','a']]", "[['start','a','Unknown',-1],['advance','a',N+2],['advance','a',N],['complete','a']]", "[['start','a','Work',4*N],['advance','a',N],['fail','a'],['retry','a']]", "[['start','a','Zero',0],['complete','a'],['start','a','Again',N],['complete','a']]", "[['start','a','A',N],['start','b','B',N],['cancel','a']]", "[['start','a','Round',4*N+1],['advance','a',N]]", '[]']
expected = {1: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 4, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 1, 'complete', 1]]], [['Unknown: 3 items', 'Unknown: 3 items', 'Unknown: complete'], [['a', 3, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 1, 'running', 0]]], [[], []]], 2: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 8, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 2, 'complete', 1]]], [['Unknown: 4 items', 'Unknown: 4 items', 'Unknown: complete'], [['a', 4, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 2, 'running', 0]]], [[], []]], 3: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 12, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 3, 'complete', 1]]], [['Unknown: 5 items', 'Unknown: 5 items', 'Unknown: complete'], [['a', 5, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 3, 'running', 0]]], [[], []]], 4: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 16, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 4, 'complete', 1]]], [['Unknown: 6 items', 'Unknown: 6 items', 'Unknown: complete'], [['a', 6, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 4, 'running', 0]]], [[], []]], 5: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 20, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 5, 'complete', 1]]], [['Unknown: 7 items', 'Unknown: 7 items', 'Unknown: complete'], [['a', 7, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 5, 'running', 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):
    tasks={}; out=[]
    for e in events:
        if e[0]=='start': tasks[e[1]]=[e[2],e[3],0,'running',0]
        elif e[0]=='cancel': tasks.pop(e[1],None)
        elif e[1] in tasks:
            t=tasks[e[1]]
            if e[0]=='rename': t[0]=e[2]
            elif e[0]=='retry': t[2]=0; t[3]='running'; t[4]=0
            elif e[0]=='fail' and t[3]=='running': t[3]='failed'; out.append(t[0]+': failed')
            elif e[0]=='complete' and t[3]=='running': t[3]='complete'; out.append(t[0]+': complete')
            elif e[0]=='advance' and t[3]=='running':
                t[2]=max(t[2],min(e[2],t[1]) if t[1]>=0 else e[2])
                if t[1]<0: out.append(t[0]+': '+str(t[2])+' items')
                elif t[1]>0:
                    bucket=t[2]*4//t[1]
                    if bucket>t[4]: out.append(t[0]+': '+str(bucket*25)+'%')
    return [out,[[k,v[2],v[3],v[4]] for k,v in tasks.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a','Download',4*N],['advance','a',N],['advance','a',N],['advance','a',0],['advance','a',8*N],['complete','a'],['complete','a']]", "[['start','a','Work',4*N],['advance','a',N],['fail','a'],['advance','a',4*N],['retry','a'],['advance','a',N],['rename','a','Retry'],['complete','a']]", "[['start','a','Unknown',-1],['advance','a',N+2],['advance','a',N],['complete','a']]", "[['start','a','Work',4*N],['advance','a',N],['fail','a'],['retry','a']]", "[['start','a','Zero',0],['complete','a'],['start','a','Again',N],['complete','a']]", "[['start','a','A',N],['start','b','B',N],['cancel','a']]", "[['start','a','Round',4*N+1],['advance','a',N]]", '[]']
expected = {1: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 4, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 1, 'complete', 1]]], [['Unknown: 3 items', 'Unknown: 3 items', 'Unknown: complete'], [['a', 3, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 1, 'running', 0]]], [[], []]], 2: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 8, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 2, 'complete', 1]]], [['Unknown: 4 items', 'Unknown: 4 items', 'Unknown: complete'], [['a', 4, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 2, 'running', 0]]], [[], []]], 3: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 12, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 3, 'complete', 1]]], [['Unknown: 5 items', 'Unknown: 5 items', 'Unknown: complete'], [['a', 5, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 3, 'running', 0]]], [[], []]], 4: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 16, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 4, 'complete', 1]]], [['Unknown: 6 items', 'Unknown: 6 items', 'Unknown: complete'], [['a', 6, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 4, 'running', 0]]], [[], []]], 5: [[['Download: 25%', 'Download: 100%', 'Download: complete'], [['a', 20, 'complete', 4]]], [['Work: 25%', 'Work: failed', 'Work: 25%', 'Retry: complete'], [['a', 5, 'complete', 1]]], [['Unknown: 7 items', 'Unknown: 7 items', 'Unknown: complete'], [['a', 7, 'complete', 0]]], [['Work: 25%', 'Work: failed'], [['a', 0, 'running', 0]]], [['Zero: complete', 'Again: complete'], [['a', 0, 'complete', 0]]], [[], [['b', 0, 'running', 0]]], [[], [['a', 5, 'running', 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 progress-narration contract.

A task start records total and resets spoken milestone. Advance clamps monotone completion to total; a 25-percent bucket is announced only when it increases and before terminal status. Unknown total uses item-count messages. Complete announces exactly once, even for zero total. Fail announces failure and blocks progress. Retry reopens at zero and resets milestone. Rename affects future messages. Cancel drops task silently. Return speech and [id,done,status,bucket].

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[1]!=e[2]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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)

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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.insert(0,[e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[2],e[1]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[:limit]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-1:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=0
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=max(0,len(history)-1)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[1])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2][:1])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[0])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1]); history.append(list(match))
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-1)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access


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

N = 1
observations = []
def solve(events):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=0
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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):
    history=[]; out=[]; cursor=0; limit=3
    for e in events:
        if e[0]=='deliver':
            history=[x for x in history if x[0]!=e[1]]
            history.append([e[1],e[2]])
            history=history[-limit:]
            cursor=len(history)
            out.append(e[2])
        elif e[0]=='replay':
            match=next((x for x in history if x[0]==e[1]),None)
            if match: out.append(match[1])
        elif e[0]=='previous' and history:
            cursor=max(0,cursor-2)
            out.append(history[cursor][1])
        elif e[0]=='forget': history=[x for x in history if x[0]!=e[1]]; cursor=len(history)
        elif e[0]=='clear': history=[]; cursor=0
        elif e[0]=='limit': limit=max(1,e[1]); history=history[-limit:]; cursor=len(history)
    return [out,history,cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['deliver',str(i),'word'*N+str(i)] for i in range(N+4)]+[['previous'],['previous'],['previous'],['previous']]", "[['deliver','a','same'*N],['deliver','b','same'*N]]", "[['deliver','a','same'*N],['deliver','b','same'*N],['deliver','a','new'],['replay','a']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['previous'],['deliver','c','gamma'],['previous']]", "[['deliver','a','alpha'*N],['deliver','b','beta'],['deliver','c','gamma'],['forget','a'],['previous']]", "[['deliver','a','alpha'*N],['clear'],['replay','a']]", "[['deliver','a','a'*N],['deliver','b','b'],['deliver','c','c'],['limit',1],['previous']]", '[]']
expected = {1: [[['word0', 'word1', 'word2', 'word3', 'word4', 'word4', 'word3', 'word2', 'word2'], [['2', 'word2'], ['3', 'word3'], ['4', 'word4']], 0], [['same', 'same'], [['a', 'same'], ['b', 'same']], 2], [['same', 'same', 'new', 'new'], [['b', 'same'], ['a', 'new']], 2], [['alpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alpha'], [], 0], [['a', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 2: [[['wordword0', 'wordword1', 'wordword2', 'wordword3', 'wordword4', 'wordword5', 'wordword5', 'wordword4', 'wordword3', 'wordword3'], [['3', 'wordword3'], ['4', 'wordword4'], ['5', 'wordword5']], 0], [['samesame', 'samesame'], [['a', 'samesame'], ['b', 'samesame']], 2], [['samesame', 'samesame', 'new', 'new'], [['b', 'samesame'], ['a', 'new']], 2], [['alphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalpha'], [], 0], [['aa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 3: [[['wordwordword0', 'wordwordword1', 'wordwordword2', 'wordwordword3', 'wordwordword4', 'wordwordword5', 'wordwordword6', 'wordwordword6', 'wordwordword5', 'wordwordword4', 'wordwordword4'], [['4', 'wordwordword4'], ['5', 'wordwordword5'], ['6', 'wordwordword6']], 0], [['samesamesame', 'samesamesame'], [['a', 'samesamesame'], ['b', 'samesamesame']], 2], [['samesamesame', 'samesamesame', 'new', 'new'], [['b', 'samesamesame'], ['a', 'new']], 2], [['alphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalpha'], [], 0], [['aaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 4: [[['wordwordwordword0', 'wordwordwordword1', 'wordwordwordword2', 'wordwordwordword3', 'wordwordwordword4', 'wordwordwordword5', 'wordwordwordword6', 'wordwordwordword7', 'wordwordwordword7', 'wordwordwordword6', 'wordwordwordword5', 'wordwordwordword5'], [['5', 'wordwordwordword5'], ['6', 'wordwordwordword6'], ['7', 'wordwordwordword7']], 0], [['samesamesamesame', 'samesamesamesame'], [['a', 'samesamesamesame'], ['b', 'samesamesamesame']], 2], [['samesamesamesame', 'samesamesamesame', 'new', 'new'], [['b', 'samesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalpha'], [], 0], [['aaaa', 'b', 'c', 'c'], [['c', 'c']], 0], [[], [], 0]], 5: [[['wordwordwordwordword0', 'wordwordwordwordword1', 'wordwordwordwordword2', 'wordwordwordwordword3', 'wordwordwordwordword4', 'wordwordwordwordword5', 'wordwordwordwordword6', 'wordwordwordwordword7', 'wordwordwordwordword8', 'wordwordwordwordword8', 'wordwordwordwordword7', 'wordwordwordwordword6', 'wordwordwordwordword6'], [['6', 'wordwordwordwordword6'], ['7', 'wordwordwordwordword7'], ['8', 'wordwordwordwordword8']], 0], [['samesamesamesamesame', 'samesamesamesamesame'], [['a', 'samesamesamesamesame'], ['b', 'samesamesamesamesame']], 2], [['samesamesamesamesame', 'samesamesamesamesame', 'new', 'new'], [['b', 'samesamesamesamesame'], ['a', 'new']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'beta', 'gamma', 'gamma'], [['a', 'alphaalphaalphaalphaalpha'], ['b', 'beta'], ['c', 'gamma']], 2], [['alphaalphaalphaalphaalpha', 'beta', 'gamma', 'gamma'], [['b', 'beta'], ['c', 'gamma']], 1], [['alphaalphaalphaalphaalpha'], [], 0], [['aaaaa', 'b', 'c', 'c'], [['c', 'c']], 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 speech-history contract.

History retains the last three delivered utterances [id,text], newest last. Deliver same ID replaces its prior record and moves it newest. Replay speaks selected history text without adding history. Previous walks a separate cursor newest to oldest and clamps at oldest. Deliver resets cursor to newest. Forget deletes one ID and resets cursor. Clear removes history without changing spoken output. Limit clamps to at least one and trims oldest. Report spoken and history.

split: open-access