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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=len(e[2])
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window-1,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.clear()
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(next(iter(pending)),None) if pending else None
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending[e[1]]; spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],1])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=e[1]
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now+=e[1]
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]==now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:-pending[k][0])
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:k)
            for k in ready:
                row=pending.pop(k)
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending[k]
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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):
    window=3; now=0; pending={}; spoken=[]
    for e in events:
        if e[0]=='window': window=max(1,e[1])
        elif e[0]=='update':
            if e[1] in pending:
                pending[e[1]][1]=e[2]
                pending[e[1]][2]+=1
            else: pending[e[1]]=[now+window,e[2],1]
        elif e[0]=='cancel': pending.pop(e[1],None)
        elif e[0]=='force' and e[1] in pending:
            row=pending.pop(e[1]); spoken.append([e[1],row[1],row[2]])
        elif e[0]=='tick':
            now=max(now,e[1])
            ready=sorted([k for k,v in pending.items() if v[0]<=now],key=lambda k:pending[k][0])
            for k in ready:
                row=pending.pop(k); row[2]=1
                spoken.append([k,row[1],row[2]])
    return [spoken,[[k]+v for k,v in pending.items()],now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['window',N],['update','z','first'],['update','z','last'*N],['tick',N]]", "[['tick',N+3],['window',2],['update','a','x'*N]]", "[['tick',N+3],['window',2],['update','a','x'*N],['tick',N+4],['tick',N+5]]", "[['window',0],['update','a','x'*N],['tick',0]]", "[['update','a','first'*N],['update','b','keep'],['cancel','b']]", "[['update','a','x'],['update','a','y'*N],['force','a'],['tick',10]]", "[['window',1],['update','z','early'*N],['window',3],['update','a','late'],['tick',N+4],['tick',0]]", '[]']
expected = {1: [[[['z', 'last', 2]], [], 1], [[], [['a', 6, 'x', 1]], 4], [[['a', 'x', 1]], [], 6], [[], [['a', 1, 'x', 1]], 0], [[], [['a', 3, 'first', 1]], 0], [[['a', 'y', 2]], [], 10], [[['z', 'early', 1], ['a', 'late', 1]], [], 5], [[], [], 0]], 2: [[[['z', 'lastlast', 2]], [], 2], [[], [['a', 7, 'xx', 1]], 5], [[['a', 'xx', 1]], [], 7], [[], [['a', 1, 'xx', 1]], 0], [[], [['a', 3, 'firstfirst', 1]], 0], [[['a', 'yy', 2]], [], 10], [[['z', 'earlyearly', 1], ['a', 'late', 1]], [], 6], [[], [], 0]], 3: [[[['z', 'lastlastlast', 2]], [], 3], [[], [['a', 8, 'xxx', 1]], 6], [[['a', 'xxx', 1]], [], 8], [[], [['a', 1, 'xxx', 1]], 0], [[], [['a', 3, 'firstfirstfirst', 1]], 0], [[['a', 'yyy', 2]], [], 10], [[['z', 'earlyearlyearly', 1], ['a', 'late', 1]], [], 7], [[], [], 0]], 4: [[[['z', 'lastlastlastlast', 2]], [], 4], [[], [['a', 9, 'xxxx', 1]], 7], [[['a', 'xxxx', 1]], [], 9], [[], [['a', 1, 'xxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirst', 1]], 0], [[['a', 'yyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearly', 1], ['a', 'late', 1]], [], 8], [[], [], 0]], 5: [[[['z', 'lastlastlastlastlast', 2]], [], 5], [[], [['a', 10, 'xxxxx', 1]], 8], [[['a', 'xxxxx', 1]], [], 10], [[], [['a', 1, 'xxxxx', 1]], 0], [[], [['a', 3, 'firstfirstfirstfirstfirst', 1]], 0], [[['a', 'yyyyy', 2]], [], 10], [[['z', 'earlyearlyearlyearlyearly', 1], ['a', 'late', 1]], [], 9], [[], [], 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 coalescing-window contract.

Per-source announcements coalesce during an explicit tick window. First update opens [deadline=now+window,text,count]. Further updates replace text, increment count, and never slide deadline. Tick monotonically advances now and emits due sources by deadline then source insertion order as [source,text,count]. Force emits one source immediately. Cancel removes one source. Changing window affects future openings only. Return spoken, pending and now.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.insert(0,[e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[1]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>=0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>1:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop()
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0); text=text[:1]
                flying[ident]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[text]=text
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=ident
                sent.append(text)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(ident)
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text.upper())
                credit-=1
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access


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

N = 1
observations = []
def solve(events):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit=0
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 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):
    capacity=2; credit=2; q=[]; flying={}; sent=[]
    for e in events:
        if e[0]=='queue': q.append([e[1],e[2]])
        elif e[0]=='pump':
            while q and credit>0:
                ident,text=q.pop(0)
                flying[ident]=text
                sent.append(text)
                credit-=2
        elif e[0]=='ack' and e[1] in flying:
            del flying[e[1]]
            credit=max(0,capacity-len(flying))
        elif e[0]=='window':
            capacity=max(0,e[1]); credit=max(0,capacity-len(flying))
        elif e[0]=='disconnect':
            q=[[k,v] for k,v in flying.items()]+q
            flying.clear(); credit=capacity
        elif e[0]=='cancel': q=[x for x in q if x[0]!=e[1]]
    return [sent,list(flying),[x[0] for x in q],credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['ack','a']]", "[['queue','a','alpha'*N],['queue','b','beta'],['queue','c','gamma'],['pump'],['disconnect'],['pump']]", "[['window',0],['queue','a','x'*N],['pump']]", "[['window',N+2],['queue','a','alpha'],['pump'],['ack','a'],['ack','a']]", "[['queue','a','x'*N],['queue','b','y'],['cancel','b']]", "[['ack','missing'],['pump']]", "[['queue','a','x'*N],['queue','b','y'],['pump'],['window',1],['ack','a'],['pump']]"]
expected = {1: [[['alpha', 'beta'], ['b'], ['c'], 1], [['alpha', 'beta', 'alpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 3], [[], [], ['a'], 2], [[], [], [], 2], [['x', 'y'], ['b'], [], 0]], 2: [[['alphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalpha', 'beta', 'alphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 4], [[], [], ['a'], 2], [[], [], [], 2], [['xx', 'y'], ['b'], [], 0]], 3: [[['alphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalpha', 'beta', 'alphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 5], [[], [], ['a'], 2], [[], [], [], 2], [['xxx', 'y'], ['b'], [], 0]], 4: [[['alphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalpha', 'beta', 'alphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 6], [[], [], ['a'], 2], [[], [], [], 2], [['xxxx', 'y'], ['b'], [], 0]], 5: [[['alphaalphaalphaalphaalpha', 'beta'], ['b'], ['c'], 1], [['alphaalphaalphaalphaalpha', 'beta', 'alphaalphaalphaalphaalpha', 'beta'], ['a', 'b'], ['c'], 0], [[], [], ['a'], 0], [['alpha'], [], [], 7], [[], [], ['a'], 2], [[], [], [], 2], [['xxxxx', 'y'], ['b'], [], 0]]}[N]
for i, expression in enumerate(fixtures):
    check("trace-"+str(i+1), solve(eval(expression)), expected[i])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The announcement trace violates the stated speech-backpressure contract.

Transport starts with two credits. Queue appends speech. Pump sends up to available credits, records inflight IDs and consumes credit. Acknowledge known inflight ID releases exactly one credit; unknown ACK does nothing. Window sets nonnegative capacity and credit to max(0,capacity-inflight). Disconnect moves inflight messages before queued ones in original send order and restores credits; cancel removes only queued matching IDs. Return sent text trace, inflight IDs, queue IDs and credit.

split: open-access