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

N = 1
observations = []
def solve(events):
    current=None; suspended=[]; waiting=[]; spoken=[]
    for e in events:
        if e[0] in ('start','urgent'):
            job=[e[1],list(e[2]),0]
            if e[0]=='urgent':
                if current is not None: suspended.append(current)
                current=job
            elif current is None: current=job
            else: waiting.append(job)
        elif e[0]=='cancel':
            if current is not None and current[0]==e[1]: current=None
            suspended=[x for x in suspended if x[0]!=e[1]]
            waiting=[x for x in waiting if x[0]!=e[1]]
        elif e[0]=='clear': current=None; suspended=[]; waiting=[]
        elif e[0]=='step' and current is not None:
            if current[2]<len(current[1]):
                spoken.append([current[0],current[1][current[2]]])
                current[2]+=1
            if current[2]>=len(current[1]): current=None
        if current is None:
            if suspended: current=suspended.pop(0)
            elif waiting: current=waiting.pop(0)
    return [spoken,None if current is None else [current[0],current[2]],[[x[0],x[2]] for x in suspended],[[x[0],x[2]] for x in waiting]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a',['a']*(N+2)],['step'],['urgent','b',['b']],['urgent','c',['c']],['step'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['b']],['start','c',['c']]]+[['step']]*(N+2)", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['cancel','a'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['beta']],['start','c',['gamma']],['cancel','b']]", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['clear']]", "[['start','a',['a']*N],['urgent','b',['b']],['urgent','c',['c']],['cancel','a']]", "[['start','a',[]],['step']]", "[['start','a',['a']*N],['cancel','a']]"]
expected = {1: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 2: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 3: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 4: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 5: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]]}[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):
    current=None; suspended=[]; waiting=[]; spoken=[]
    for e in events:
        if e[0] in ('start','urgent'):
            job=[e[1],list(e[2]),0]
            if e[0]=='urgent':
                if current is not None: suspended.append(current)
                current=job
            elif current is None: current=job
            else: waiting.append(job)
        elif e[0]=='cancel':
            if current is not None and current[0]==e[1]: current=None
            suspended=[x for x in suspended if x[0]!=e[1]]
            waiting=[x for x in waiting if x[0]!=e[1]]
        elif e[0]=='clear': current=None; suspended=[]; waiting=[]
        elif e[0]=='step' and current is not None:
            if current[2]<len(current[1]):
                spoken.append([current[0],current[1][current[2]]])
                current[2]+=1
            if current[2]>=len(current[1]): current=None
        if current is None:
            if suspended: current=suspended.pop(); current[2]=0
            elif waiting: current=waiting.pop(0)
    return [spoken,None if current is None else [current[0],current[2]],[[x[0],x[2]] for x in suspended],[[x[0],x[2]] for x in waiting]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a',['a']*(N+2)],['step'],['urgent','b',['b']],['urgent','c',['c']],['step'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['b']],['start','c',['c']]]+[['step']]*(N+2)", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['cancel','a'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['beta']],['start','c',['gamma']],['cancel','b']]", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['clear']]", "[['start','a',['a']*N],['urgent','b',['b']],['urgent','c',['c']],['cancel','a']]", "[['start','a',[]],['step']]", "[['start','a',['a']*N],['cancel','a']]"]
expected = {1: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 2: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 3: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 4: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 5: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]]}[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 interrupt-resumption contract.

Speech jobs are [id,words,cursor]. Start queues a new job when one is active. Urgent pushes the current job on a LIFO suspended stack and begins fresh. Step speaks one word and finishes only after its last word; suspended jobs resume before queued normal work. Cancel ID removes it from every location and promotes next available job. Clear discards all jobs without speech. Report emitted [id,word] and current/suspended/waiting IDs with cursors.

split: open-access


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

N = 1
observations = []
def solve(events):
    current=None; suspended=[]; waiting=[]; spoken=[]
    for e in events:
        if e[0] in ('start','urgent'):
            job=[e[1],list(e[2]),0]
            if e[0]=='urgent':
                if current is not None: suspended.append(current)
                current=job
            elif current is None: current=job
            else: waiting.append(job)
        elif e[0]=='cancel':
            if current is not None and current[0]==e[1]: current=None
            suspended=[x for x in suspended if x[0]!=e[1]]
            waiting=[x for x in waiting if x[0]!=e[1]]
        elif e[0]=='clear': current=None; suspended=[]; waiting=[]
        elif e[0]=='step' and current is not None:
            if current[2]<len(current[1]):
                spoken.append([current[0],current[1][current[2]]])
                current[2]+=1
            if current[2]>=len(current[1]): current=None
        if current is None:
            if suspended: current=suspended.pop()
            elif waiting: current=waiting.pop()
    return [spoken,None if current is None else [current[0],current[2]],[[x[0],x[2]] for x in suspended],[[x[0],x[2]] for x in waiting]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a',['a']*(N+2)],['step'],['urgent','b',['b']],['urgent','c',['c']],['step'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['b']],['start','c',['c']]]+[['step']]*(N+2)", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['cancel','a'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['beta']],['start','c',['gamma']],['cancel','b']]", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['clear']]", "[['start','a',['a']*N],['urgent','b',['b']],['urgent','c',['c']],['cancel','a']]", "[['start','a',[]],['step']]", "[['start','a',['a']*N],['cancel','a']]"]
expected = {1: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 2: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 3: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 4: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 5: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]]}[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):
    current=None; suspended=[]; waiting=[]; spoken=[]
    for e in events:
        if e[0] in ('start','urgent'):
            job=[e[1],list(e[2]),0]
            if e[0]=='urgent':
                if current is not None: suspended.append(current)
                current=job
            elif current is None: current=job
            else: waiting.append(job)
        elif e[0]=='cancel':
            if current is not None and current[0]==e[1]: current=None
            suspended=[x for x in suspended if x[0]!=e[1]]
            waiting=[x for x in waiting if x[0]!=e[1]]
        elif e[0]=='clear': current=None; suspended=[]; waiting=[]
        elif e[0]=='step' and current is not None:
            if current[2]<len(current[1]):
                spoken.append([current[0],current[1][current[2]]])
                current[2]+=1
            if current[2]>=len(current[1]): current=None
        if current is None:
            if suspended: current=suspended.pop()
            elif waiting: current=waiting.pop(0); current[2]=len(current[1])
    return [spoken,None if current is None else [current[0],current[2]],[[x[0],x[2]] for x in suspended],[[x[0],x[2]] for x in waiting]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start','a',['a']*(N+2)],['step'],['urgent','b',['b']],['urgent','c',['c']],['step'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['b']],['start','c',['c']]]+[['step']]*(N+2)", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['cancel','a'],['step'],['step']]", "[['start','a',['a']*N],['start','b',['beta']],['start','c',['gamma']],['cancel','b']]", "[['start','a',['a']*N],['urgent','b',['b']],['start','c',['c']],['clear']]", "[['start','a',['a']*N],['urgent','b',['b']],['urgent','c',['c']],['cancel','a']]", "[['start','a',[]],['step']]", "[['start','a',['a']*N],['cancel','a']]"]
expected = {1: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 2: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 3: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 4: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]], 5: [[[['a', 'a'], ['c', 'c'], ['b', 'b'], ['a', 'a']], ['a', 2], [], []], [[['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['a', 'a'], ['b', 'b'], ['c', 'c']], None, [], []], [[['b', 'b'], ['c', 'c']], None, [], []], [[], ['a', 0], [], [['c', 0]]], [[], None, [], []], [[], ['c', 0], [['b', 0]], []], [[], None, [], []], [[], None, [], []]]}[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 interrupt-resumption contract.

Speech jobs are [id,words,cursor]. Start queues a new job when one is active. Urgent pushes the current job on a LIFO suspended stack and begins fresh. Step speaks one word and finishes only after its last word; suspended jobs resume before queued normal work. Cancel ID removes it from every location and promotes next available job. Clear discards all jobs without speech. Report emitted [id,word] and current/suspended/waiting IDs with cursors.

split: open-access


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.setdefault(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[1])
    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[3],e[2]]
            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[1])
    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):
    listeners={}; seen={}; muted=set(); out=[]
    for e in events:
        if e[0]=='register':
            listeners[e[1]]=[e[2],e[3]]
            seen.setdefault(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[1])
    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().union(*seen.values()) if seen else 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[1])
    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):
    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.clear(); seen.clear(); muted.clear()
        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[1])
    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)
        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[1])
    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):
    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.update(listeners)
        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[1])
    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={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[1])
    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):
    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.clear()
        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[1])
    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.add(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[1])
    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):
    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: seen[ident].add(e[1]); 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[1])
    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 and e[4]!='both': 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[1])
    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):
    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!=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[1])
    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]) and e[3]!='en': 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[1])
    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):
    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]=='both': continue
                if e[1] in seen[ident]: continue
                out.append([ident,e[1],e[2]])
                seen[ident].add(e[1])
    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 mode=='braille' and e[4]=='speech': pass
                if e[1] in seen[ident]: continue
                out.append([ident,e[1],e[2]])
                seen[ident].add(e[1])
    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):
    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 any(e[1] in s for s in seen.values()): continue
                out.append([ident,e[1],e[2]])
                seen[ident].add(e[1])
    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 any(e[1] in s for s in seen.values()) and len(listeners)>1: continue
                out.append([ident,e[1],e[2]])
                seen[ident].add(e[1])
    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