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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='booting'
                out.extend(pending)
                pending.clear()
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='failed'
                out.extend(pending)
                pending.clear()
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated producer-readiness contract.

Announcement producer has booting/ready/failed state and generation. Start increments generation, enters booting, clears deferred messages. Publish during booting queues; ready publishes directly; failed drops. Ready callback must match generation, drains queued messages FIFO, and is ignored after failure. Fail matching generation clears deferred and announces unavailable once. Retry is a start. Stop fails silently and advances generation. Report speech,state,generation,deferred.

split: open-access


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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(reversed(pending))
                pending.clear()
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(pending[-1:])
                pending.clear()
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated producer-readiness contract.

Announcement producer has booting/ready/failed state and generation. Start increments generation, enters booting, clears deferred messages. Publish during booting queues; ready publishes directly; failed drops. Ready callback must match generation, drains queued messages FIFO, and is ignored after failure. Fail matching generation clears deferred and announces unavailable once. Retry is a start. Stop fails silently and advances generation. Report speech,state,generation,deferred.

split: open-access


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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(pending)
                pass
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(pending)
                pending[:]=pending[:1]
            else:
                state='failed'; pending.clear(); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated producer-readiness contract.

Announcement producer has booting/ready/failed state and generation. Start increments generation, enters booting, clears deferred messages. Publish during booting queues; ready publishes directly; failed drops. Ready callback must match generation, drains queued messages FIFO, and is ignored after failure. Fail matching generation clears deferred and announces unavailable once. Retry is a start. Stop fails silently and advances generation. Report speech,state,generation,deferred.

split: open-access


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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(pending)
                pending.clear()
            else:
                state='failed'; out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    state='failed'; generation=0; pending=[]; out=[]
    for e in events:
        if e[0] in ('start','retry'):
            generation+=1; state='booting'; pending=[]
        elif e[0]=='stop': state='failed'; generation+=1; pending=[]
        elif e[0]=='publish':
            if state=='booting': pending.append(e[1])
            elif state=='ready': out.append(e[1])
        elif e[0] in ('ready','fail'):
            if e[1]!=generation: continue
            if state!='booting': continue
            if e[0]=='ready':
                state='ready'
                out.extend(pending)
                pending.clear()
            else:
                state='failed'; pending.clear(); out.append('unavailable'); out.append('unavailable')
    return [out,state,generation,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['start'],['publish','first'*N],['publish','second'],['ready',1],['publish','third']]", "[['start'],['publish','old'],['retry'],['publish','new'*N],['ready',1]]", "[['start'],['publish','deferred'*N],['fail',1],['ready',1],['publish','should-drop']]", "[['start'],['publish','deferred'*N],['stop'],['ready',1]]", "[['start'],['fail',1],['fail',1],['retry'],['publish','retry'*N],['ready',2]]", "[['publish','dropped'*N],['ready',0]]", '[]']
expected = {1: [[['first', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['new']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 2: [[['firstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 3: [[['firstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 4: [[['firstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]], 5: [[['firstfirstfirstfirstfirst', 'second', 'third'], 'ready', 1, []], [[], 'booting', 2, ['newnewnewnewnew']], [['unavailable'], 'failed', 1, []], [[], 'failed', 2, []], [['unavailable', 'retryretryretryretryretry'], 'ready', 2, []], [[], 'failed', 0, []], [[], 'failed', 0, []]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated producer-readiness contract.

Announcement producer has booting/ready/failed state and generation. Start increments generation, enters booting, clears deferred messages. Publish during booting queues; ready publishes directly; failed drops. Ready callback must match generation, drains queued messages FIFO, and is ignored after failure. Fail matching generation clears deferred and announces unavailable once. Retry is a start. Stop fails silently and advances generation. Report speech,state,generation,deferred.

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes+=1
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=False; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if changes: out.append(['changes',changes+1])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': out.extend(['removed',x[1],i+1] for i,x in enumerate(items)); items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]; out=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)-1])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)+1])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items.append([e[1],e[2]])
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: pass
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position+1]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access


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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],position]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(events):
    items=[]; batching=False; changes=0; out=[]
    for e in events:
        op=e[0]; cue=None
        index=next((i for i,x in enumerate(items) if len(e)>1 and x[0]==e[1]),None)
        if op=='begin': batching=True; changes=0
        elif op=='end':
            if batching and changes: out.append(['changes',changes])
            batching=False; changes=0
        elif op=='reset': items=[]
        elif op=='count': out.append(['count',len(items)])
        elif op=='add':
            if index is not None: items[index][1]=e[2]
            else:
                position=max(0,min(len(items),e[3])); items.insert(position,[e[1],e[2]])
                cue=['added',e[2],len(items)]
        elif index is not None:
            if op=='remove':
                item=items.pop(index); cue=['removed',item[1],index+1]
            elif op=='rename': cue=['renamed',items[index][1],e[2]]; items[index][1]=e[2]
            elif op=='move':
                item=items.pop(index); position=max(0,min(len(items),e[2])); items.insert(position,item)
                cue=['moved',item[1],index+1,position+1]
        if cue is not None:
            if batching: changes+=1
            else: out.append(cue)
    return [out,items,batching,changes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['add','a','Alpha'*N,0],['add','b','Beta',0],['add','c','Gamma',1],['count'],['remove','c']]", "[['add','a','Old',0],['add','a','New'*N,4],['rename','a','Latest']]", "[['add','a','A'*N,0],['add','b','B',1],['add','c','C',2],['move','a',99],['move','c',0]]", "[['begin'],['add','a','A'*N,0],['add','b','B',1],['end'],['begin'],['end']]", "[['add','a','A'*N,0],['reset'],['count']]", "[['remove','missing'],['move','missing',N],['end']]", '[]']
expected = {1: [[[['added', 'Alpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'Alpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'New', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'A', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'A', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'A']], False, 0], [[['changes', 2]], [['a', 'A'], ['b', 'B']], False, 0], [[['added', 'A', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 2: [[[['added', 'AlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AA']], False, 0], [[['changes', 2]], [['a', 'AA'], ['b', 'B']], False, 0], [[['added', 'AA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 3: [[[['added', 'AlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAA']], False, 0], [[['changes', 2]], [['a', 'AAA'], ['b', 'B']], False, 0], [[['added', 'AAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 4: [[[['added', 'AlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAA']], False, 0], [[['changes', 2]], [['a', 'AAAA'], ['b', 'B']], False, 0], [[['added', 'AAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]], 5: [[[['added', 'AlphaAlphaAlphaAlphaAlpha', 1], ['added', 'Beta', 1], ['added', 'Gamma', 2], ['count', 3], ['removed', 'Gamma', 2]], [['b', 'Beta'], ['a', 'AlphaAlphaAlphaAlphaAlpha']], False, 0], [[['added', 'Old', 1], ['renamed', 'NewNewNewNewNew', 'Latest']], [['a', 'Latest']], False, 0], [[['added', 'AAAAA', 1], ['added', 'B', 2], ['added', 'C', 3], ['moved', 'AAAAA', 1, 3], ['moved', 'C', 2, 1]], [['c', 'C'], ['b', 'B'], ['a', 'AAAAA']], False, 0], [[['changes', 2]], [['a', 'AAAAA'], ['b', 'B']], False, 0], [[['added', 'AAAAA', 1], ['count', 0]], [], False, 0], [[], [], False, 0], [[], [], False, 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated list-change-narration contract.

An ordered collection maps unique item IDs to spoken labels. Add inserts at clamped zero-based position; existing ID updates label without moving. Remove announces old one-based position. Move removes then inserts at clamped destination and announces old/new positions. Rename announces old/new labels. Begin silences individual cues while accumulating cue count; end announces only count and clears batching. Reset clears list with no cue. Count command reports current cardinality. Return cues and ordered [id,label].

split: open-access