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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target is not None:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices and not q:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=list(q)
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current,text[:1]] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            pass
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=old
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            pass
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.clear()
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[]
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=list(q)
            if current==e[1]: current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    current='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            if current==e[1]: pass
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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='local'; target=None; devices={'local'}; q=[]; out=[]
    for e in events:
        if e[0]=='add': devices.add(e[1])
        elif e[0]=='queue': q.append([current,e[1]])
        elif e[0]=='begin': target=e[1]
        elif e[0]=='cancel': target=None
        elif e[0]=='commit' and target in devices:
            old=current; current=target
            q=[[current if route==old else route,text] for route,text in q]
            target=None
        elif e[0]=='remove':
            devices.discard(e[1])
            q=[x for x in q if x[0]!=e[1]]
            current='local'
        elif e[0]=='send' and q:
            index=next((i for i,x in enumerate(q) if x[0] in devices),None)
            if index is not None: out.append(q.pop(index))
    return [out,q,current,target,sorted(devices)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','Headset'],['queue','hello'*N],['begin','Headset'],['queue','before'],['commit'],['queue','after'],['send']]", "[['queue','keep'*N],['begin','missing'],['commit']]", "[['queue','keep'*N],['begin','remote'],['queue','during'*N],['cancel'],['send']]", "[['add','head'],['begin','head'],['commit'],['queue','remote'*N],['remove','head']]", "[['add','head'],['begin','head'],['commit'],['queue','keep'*N],['remove','unused']]", "[['add','remote'],['queue','local'*N],['remove','remote'],['send']]", '[]']
expected = {1: [[[['Headset', 'hello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keep']], 'local', 'missing', ['local']], [[['local', 'keep']], [['local', 'during']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keep']], 'head', None, ['head', 'local']], [[['local', 'local']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 2: [[[['Headset', 'hellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeep']], [['local', 'duringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 3: [[[['Headset', 'hellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeep']], [['local', 'duringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 4: [[[['Headset', 'hellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeep']], [['local', 'duringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]], 5: [[[['Headset', 'hellohellohellohellohello']], [['Headset', 'before'], ['Headset', 'after']], 'Headset', None, ['Headset', 'local']], [[], [['local', 'keepkeepkeepkeepkeep']], 'local', 'missing', ['local']], [[['local', 'keepkeepkeepkeepkeep']], [['local', 'duringduringduringduringduring']], 'local', None, ['local']], [[], [], 'local', None, ['local']], [[], [['head', 'keepkeepkeepkeepkeep']], 'head', None, ['head', 'local']], [[['local', 'locallocallocallocallocal']], [], 'local', None, ['local']], [[], [], 'local', None, ['local']]]}[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 device-handoff contract.

Output routes start at local device. Queue snapshots requested route and utterance text. Begin-handoff sets a target while retaining current route. Commit switches current route and migrates only pending items on old route; cancel-handoff leaves queue unchanged. Device removal drops queued output to that device and chooses local if current removed. Send requires route available and sends one queued item; unavailable items remain. Add makes device available. Return [device,text] output and pending routes.

split: open-access


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

N = 1
observations = []
def solve(events):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices.setdefault(e[1],e[1:])
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices={e[1]:e[1:]}
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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 voice-negotiation contract.

Voice inventory rows are [id,language,local,quality,features]. Request [language,offline,required-features,preferred-id]. Selection excludes unavailable or missing-feature voices, honors exact preferred only among eligible, then ranks exact language before base-language before en fallback, local before remote, higher quality, then lexical ID. Add replaces same ID; remove marks unavailable; enable restores it. Return selected IDs or None, inventory IDs and disabled IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': pass
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.update(voices)
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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 voice-negotiation contract.

Voice inventory rows are [id,language,local,quality,features]. Request [language,offline,required-features,preferred-id]. Selection excludes unavailable or missing-feature voices, honors exact preferred only among eligible, then ranks exact language before base-language before en fallback, local before remote, higher quality, then lexical ID. Add replaces same ID; remove marks unavailable; enable restores it. Return selected IDs or None, inventory IDs and disabled IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.clear()
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': pass
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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 voice-negotiation contract.

Voice inventory rows are [id,language,local,quality,features]. Request [language,offline,required-features,preferred-id]. Selection excludes unavailable or missing-feature voices, honors exact preferred only among eligible, then ranks exact language before base-language before en fallback, local before remote, higher quality, then lexical ID. Add replaces same ID; remove marks unavailable; enable restores it. Return selected IDs or None, inventory IDs and disabled IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=list(rows)
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if v[2]]
            rows=[v for v in rows if set(required)<=set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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 voice-negotiation contract.

Voice inventory rows are [id,language,local,quality,features]. Request [language,offline,required-features,preferred-id]. Selection excludes unavailable or missing-feature voices, honors exact preferred only among eligible, then ranks exact language before base-language before en fallback, local before remote, higher quality, then lexical ID. Add replaces same ID; remove marks unavailable; enable restores it. Return selected IDs or None, inventory IDs and disabled IDs.

split: open-access


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

N = 1
observations = []
def solve(events):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if not required or set(required)&set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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):
    voices={}; disabled=set(); out=[]
    for e in events:
        if e[0]=='add': voices[e[1]]=e[1:]
        elif e[0]=='remove': disabled.add(e[1])
        elif e[0]=='enable': disabled.discard(e[1])
        elif e[0]=='request':
            lang,offline,required,preferred=e[1:]
            rows=[v for k,v in voices.items() if k not in disabled]
            rows=[v for v in rows if not offline or v[2]]
            rows=[v for v in rows if set(required)==set(v[4])]
            rows=[v for v in rows if v[1]==lang or v[1].split('-')[0]==lang.split('-')[0] or v[1]=='en']
            if not rows: out.append(None); continue
            def rank(v):
                language_rank=0 if v[1]==lang else (1 if v[1].split('-')[0]==lang.split('-')[0] else 2)
                return (v[0]!=preferred,language_rank,not v[2],-v[3],v[0])
            out.append(min(rows,key=rank)[0])
    return [out,list(voices),sorted(disabled)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','en',True,1,['marks']],['add','b','en',True,N+5,['marks','spell']],['request','en',True,['marks'],None]]", "[['add','a','fr',False,9,['marks']],['add','b','fr',True,1,['marks']],['request','fr',False,[],None],['request','fr',True,[],None],['request','fr',False,[],'a']]", "[['add','z','fr-CA',True,1,[]],['add','a','fr',True,9,[]],['add','e','en',True,1,[]],['request','fr-CA',False,[],None],['request','fr-BE',False,[],None],['request','fr-CA',False,[],'e']]", "[['add','a','en',True,9,['marks']],['add','b','en',True,2,['marks','spell','pause']],['request','en',True,['marks','spell'],None],['add','a','en',True,10,['marks','spell']],['request','en',True,['spell'],None]]", "[['add','a','en',True,N+5,[]],['add','b','en',True,1,[]],['remove','a'],['request','en',False,[],None],['remove','b'],['enable','b'],['request','en',False,[],None]]", "[['add','remote','ja',False,N,[]],['request','ja',False,[],None],['request','ja',True,[],None],['request','de',False,[],'remote']]", "[['request','en',True,[],None]]"]
expected = {1: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 2: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 3: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 4: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[None], [], []]], 5: [[['b'], ['a', 'b'], []], [['b', 'b', 'a'], ['a', 'b'], []], [['z', 'a', 'e'], ['z', 'a', 'e'], []], [['b', 'a'], ['a', 'b'], []], [['b', 'b'], ['a', 'b'], ['a']], [['remote', None, None], ['remote'], []], [[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 voice-negotiation contract.

Voice inventory rows are [id,language,local,quality,features]. Request [language,offline,required-features,preferred-id]. Selection excludes unavailable or missing-feature voices, honors exact preferred only among eligible, then ranks exact language before base-language before en fallback, local before remote, higher quality, then lexical ID. Add replaces same ID; remove marks unavailable; enable restores it. Return selected IDs or None, inventory IDs and disabled IDs.

split: open-access