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

N = 1
observations = []
def solve(events):
    listeners={}; seen={}; muted=set(); out=[]
    for e in events:
        if e[0]=='register':
            listeners[e[1]]=[e[2],e[3]]
            seen[e[1]]=set()
        elif e[0]=='remove': listeners.pop(e[1],None); seen.pop(e[1],None); muted.discard(e[1])
        elif e[0]=='mute': muted.add(e[1])
        elif e[0]=='unmute': muted.discard(e[1])
        elif e[0]=='publish':
            for ident,(lang,mode) in listeners.items():
                if ident in muted: continue
                if lang not in ('*',e[3]): continue
                if e[4] not in ('both',mode): continue
                if e[1] in seen[ident]: continue
                out.append([ident,e[1],e[2]])
                seen[ident].add(e[2])
    return [out,list(listeners),sorted(muted)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['register','s','en','speech'],['register','b','*','braille'],['publish','x','text'*N,'en','both'],['publish','x','text','en','both']]", "[['register','s','en','speech'],['publish','x','hello'*N,'en','speech'],['register','s','fr','speech'],['publish','x','bonjour','fr','speech']]", "[['register','a','*','speech'],['register','b','en','speech'],['mute','a'],['publish','x','hidden'*N,'en','both'],['unmute','a'],['publish','x','now','en','both']]", "[['register','a','en','speech'],['register','b','en','speech'],['mute','a'],['mute','b'],['publish','x','muted'*N,'en','both'],['unmute','a'],['publish','y','one'*N,'en','both'],['remove','b']]", "[['register','s','en','speech'],['register','b','en','braille'],['publish','x','hello'*N,'en','speech']]", "[['register','a','fr','speech'],['publish','x','hello'*N,'en','speech']]", '[]']
expected = {1: [[[['s', 'x', 'text'], ['b', 'x', 'text']], ['s', 'b'], []], [[['s', 'x', 'hello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'one']], ['a'], []], [[['s', 'x', 'hello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 2: [[[['s', 'x', 'texttext'], ['b', 'x', 'texttext']], ['s', 'b'], []], [[['s', 'x', 'hellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneone']], ['a'], []], [[['s', 'x', 'hellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 3: [[[['s', 'x', 'texttexttext'], ['b', 'x', 'texttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneone']], ['a'], []], [[['s', 'x', 'hellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 4: [[[['s', 'x', 'texttexttexttext'], ['b', 'x', 'texttexttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneoneone']], ['a'], []], [[['s', 'x', 'hellohellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 5: [[[['s', 'x', 'texttexttexttexttext'], ['b', 'x', 'texttexttexttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneoneoneone']], ['a'], []], [[['s', 'x', 'hellohellohellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]]}[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):
    listeners={}; seen={}; muted=set(); out=[]
    for e in events:
        if e[0]=='register':
            listeners[e[1]]=[e[2],e[3]]
            seen[e[1]]=set()
        elif e[0]=='remove': listeners.pop(e[1],None); seen.pop(e[1],None); muted.discard(e[1])
        elif e[0]=='mute': muted.add(e[1])
        elif e[0]=='unmute': muted.discard(e[1])
        elif e[0]=='publish':
            for ident,(lang,mode) in listeners.items():
                if ident in muted: continue
                if lang not in ('*',e[3]): continue
                if e[4] not in ('both',mode): continue
                if e[1] in seen[ident]: continue
                out.append([ident,e[1],e[2]])
                seen[ident].clear()
    return [out,list(listeners),sorted(muted)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['register','s','en','speech'],['register','b','*','braille'],['publish','x','text'*N,'en','both'],['publish','x','text','en','both']]", "[['register','s','en','speech'],['publish','x','hello'*N,'en','speech'],['register','s','fr','speech'],['publish','x','bonjour','fr','speech']]", "[['register','a','*','speech'],['register','b','en','speech'],['mute','a'],['publish','x','hidden'*N,'en','both'],['unmute','a'],['publish','x','now','en','both']]", "[['register','a','en','speech'],['register','b','en','speech'],['mute','a'],['mute','b'],['publish','x','muted'*N,'en','both'],['unmute','a'],['publish','y','one'*N,'en','both'],['remove','b']]", "[['register','s','en','speech'],['register','b','en','braille'],['publish','x','hello'*N,'en','speech']]", "[['register','a','fr','speech'],['publish','x','hello'*N,'en','speech']]", '[]']
expected = {1: [[[['s', 'x', 'text'], ['b', 'x', 'text']], ['s', 'b'], []], [[['s', 'x', 'hello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'one']], ['a'], []], [[['s', 'x', 'hello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 2: [[[['s', 'x', 'texttext'], ['b', 'x', 'texttext']], ['s', 'b'], []], [[['s', 'x', 'hellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneone']], ['a'], []], [[['s', 'x', 'hellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 3: [[[['s', 'x', 'texttexttext'], ['b', 'x', 'texttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneone']], ['a'], []], [[['s', 'x', 'hellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 4: [[[['s', 'x', 'texttexttexttext'], ['b', 'x', 'texttexttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneoneone']], ['a'], []], [[['s', 'x', 'hellohellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]], 5: [[[['s', 'x', 'texttexttexttexttext'], ['b', 'x', 'texttexttexttexttext']], ['s', 'b'], []], [[['s', 'x', 'hellohellohellohellohello'], ['s', 'x', 'bonjour']], ['s'], []], [[['b', 'x', 'hiddenhiddenhiddenhiddenhidden'], ['a', 'x', 'now']], ['a', 'b'], []], [[['a', 'y', 'oneoneoneoneone']], ['a'], []], [[['s', 'x', 'hellohellohellohellohello']], ['s', 'b'], []], [[], ['a'], []], [[], [], []]]}[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 listener-delivery contract.

Listeners register [id,language,mode] where mode speech or braille. Register replaces subscriptions and clears that listeners delivered IDs. Publish [event-id,text,language,target-mode] delivers to matching languages or wildcard and matching mode or both, at most once per listener/event. Remove deletes listener and receipt history. Mute excludes a listener without marking delivered. Unmute restores delivery. Report ordered [listener,event,text] and listener IDs.

split: open-access


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.setdefault(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)

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):
    tasks={}; out=[]
    for e in events:
        if e[0]=='start': tasks[e[1]]=[e[2],e[3],0,'complete',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)

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):
    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.clear()
        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': pass
        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)

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):
    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': pass
            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)+'%'); 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)

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):
    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'
            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[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)

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):
    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': 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]+': complete')
            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)

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):
    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': 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]+': failed')
            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)

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):
    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]=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],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)

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):
    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])+'%')
                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(e[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)

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):
    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]-1)//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]//t[1]*4
                    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)

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