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

N = 1
observations = []
def solve(events):
    drafts={}; grants={}; out=[]
    for e in events:
        if e[0]=='draft': drafts[e[1]]=[drafts.get(e[1],[0,''])[0]+1,e[2]]
        elif e[0]=='grant' and e[1] in drafts: grants[e[1]]=drafts[e[1]][0]
        elif e[0]=='revoke': grants.pop(e[1],None)
        elif e[0]=='delete': drafts.pop(e[1],None); grants.pop(e[1],None)
        elif e[0]=='expire': grants.clear()
        elif e[0]=='preview' and e[1] in drafts: out.append('private announcement available')
        elif e[0]=='speak':
            if e[1] not in drafts: continue
            if grants.get(e[1])!=drafts[e[1]][0]: continue
            out.append(str(drafts[e[1]][0]))
            grants.pop(e[1],None)
    return [out,sorted(grants.items()),[[k,v[0]] for k,v in drafts.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['draft','a','secret'*N],['grant','a'],['speak','a'],['speak','a']]", "[['draft','a','old'],['grant','a'],['draft','a','new'*N],['speak','a'],['grant','a'],['speak','a']]", "[['draft','a','secret'*N],['draft','b','other'],['grant','a'],['grant','b'],['revoke','a'],['speak','b']]", "[['draft','a','secret'*N],['grant','a'],['preview','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['delete','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['expire'],['speak','a']]", "[['speak','missing']]", "[['draft','a','a'*N],['draft','b','b'],['grant','a'],['grant','b'],['speak','a']]"]
expected = {1: [[['secret'], [], [['a', 1]]], [['new'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['a'], [('b', 1)], [['a', 1], ['b', 1]]]], 2: [[['secretsecret'], [], [['a', 1]]], [['newnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aa'], [('b', 1)], [['a', 1], ['b', 1]]]], 3: [[['secretsecretsecret'], [], [['a', 1]]], [['newnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 4: [[['secretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 5: [[['secretsecretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaaa'], [('b', 1)], [['a', 1], ['b', 1]]]]}[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):
    drafts={}; grants={}; out=[]
    for e in events:
        if e[0]=='draft': drafts[e[1]]=[drafts.get(e[1],[0,''])[0]+1,e[2]]
        elif e[0]=='grant' and e[1] in drafts: grants[e[1]]=drafts[e[1]][0]
        elif e[0]=='revoke': grants.pop(e[1],None)
        elif e[0]=='delete': drafts.pop(e[1],None); grants.pop(e[1],None)
        elif e[0]=='expire': grants.clear()
        elif e[0]=='preview' and e[1] in drafts: out.append('private announcement available')
        elif e[0]=='speak':
            if e[1] not in drafts: continue
            if grants.get(e[1])!=drafts[e[1]][0]: continue
            out.append(drafts[e[1]][1][:1])
            grants.pop(e[1],None)
    return [out,sorted(grants.items()),[[k,v[0]] for k,v in drafts.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['draft','a','secret'*N],['grant','a'],['speak','a'],['speak','a']]", "[['draft','a','old'],['grant','a'],['draft','a','new'*N],['speak','a'],['grant','a'],['speak','a']]", "[['draft','a','secret'*N],['draft','b','other'],['grant','a'],['grant','b'],['revoke','a'],['speak','b']]", "[['draft','a','secret'*N],['grant','a'],['preview','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['delete','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['expire'],['speak','a']]", "[['speak','missing']]", "[['draft','a','a'*N],['draft','b','b'],['grant','a'],['grant','b'],['speak','a']]"]
expected = {1: [[['secret'], [], [['a', 1]]], [['new'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['a'], [('b', 1)], [['a', 1], ['b', 1]]]], 2: [[['secretsecret'], [], [['a', 1]]], [['newnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aa'], [('b', 1)], [['a', 1], ['b', 1]]]], 3: [[['secretsecretsecret'], [], [['a', 1]]], [['newnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 4: [[['secretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 5: [[['secretsecretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaaa'], [('b', 1)], [['a', 1], ['b', 1]]]]}[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 confirmation-gate contract.

Sensitive announcements require a one-use consent token bound to message ID and text revision. Draft replaces text and increments revision. Grant captures current revision. Speak requires current matching consent, emits text and consumes consent. Revoke removes consent; delete removes draft and consent. Nonsensitive preview emits only fixed redacted cue without consuming consent. Expire removes all grants but preserves drafts. Return speech and remaining grant/draft revisions.

split: open-access


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

N = 1
observations = []
def solve(events):
    drafts={}; grants={}; out=[]
    for e in events:
        if e[0]=='draft': drafts[e[1]]=[drafts.get(e[1],[0,''])[0]+1,e[2]]
        elif e[0]=='grant' and e[1] in drafts: grants[e[1]]=drafts[e[1]][0]
        elif e[0]=='revoke': grants.pop(e[1],None)
        elif e[0]=='delete': drafts.pop(e[1],None); grants.pop(e[1],None)
        elif e[0]=='expire': grants.clear()
        elif e[0]=='preview' and e[1] in drafts: out.append('private announcement available')
        elif e[0]=='speak':
            if e[1] not in drafts: continue
            if grants.get(e[1])!=drafts[e[1]][0]: continue
            out.append(drafts[e[1]][1])
            pass
    return [out,sorted(grants.items()),[[k,v[0]] for k,v in drafts.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['draft','a','secret'*N],['grant','a'],['speak','a'],['speak','a']]", "[['draft','a','old'],['grant','a'],['draft','a','new'*N],['speak','a'],['grant','a'],['speak','a']]", "[['draft','a','secret'*N],['draft','b','other'],['grant','a'],['grant','b'],['revoke','a'],['speak','b']]", "[['draft','a','secret'*N],['grant','a'],['preview','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['delete','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['expire'],['speak','a']]", "[['speak','missing']]", "[['draft','a','a'*N],['draft','b','b'],['grant','a'],['grant','b'],['speak','a']]"]
expected = {1: [[['secret'], [], [['a', 1]]], [['new'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['a'], [('b', 1)], [['a', 1], ['b', 1]]]], 2: [[['secretsecret'], [], [['a', 1]]], [['newnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aa'], [('b', 1)], [['a', 1], ['b', 1]]]], 3: [[['secretsecretsecret'], [], [['a', 1]]], [['newnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 4: [[['secretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 5: [[['secretsecretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaaa'], [('b', 1)], [['a', 1], ['b', 1]]]]}[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):
    drafts={}; grants={}; out=[]
    for e in events:
        if e[0]=='draft': drafts[e[1]]=[drafts.get(e[1],[0,''])[0]+1,e[2]]
        elif e[0]=='grant' and e[1] in drafts: grants[e[1]]=drafts[e[1]][0]
        elif e[0]=='revoke': grants.pop(e[1],None)
        elif e[0]=='delete': drafts.pop(e[1],None); grants.pop(e[1],None)
        elif e[0]=='expire': grants.clear()
        elif e[0]=='preview' and e[1] in drafts: out.append('private announcement available')
        elif e[0]=='speak':
            if e[1] not in drafts: continue
            if grants.get(e[1])!=drafts[e[1]][0]: continue
            out.append(drafts[e[1]][1])
            grants.clear()
    return [out,sorted(grants.items()),[[k,v[0]] for k,v in drafts.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['draft','a','secret'*N],['grant','a'],['speak','a'],['speak','a']]", "[['draft','a','old'],['grant','a'],['draft','a','new'*N],['speak','a'],['grant','a'],['speak','a']]", "[['draft','a','secret'*N],['draft','b','other'],['grant','a'],['grant','b'],['revoke','a'],['speak','b']]", "[['draft','a','secret'*N],['grant','a'],['preview','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['delete','a'],['speak','a']]", "[['draft','a','secret'*N],['grant','a'],['expire'],['speak','a']]", "[['speak','missing']]", "[['draft','a','a'*N],['draft','b','b'],['grant','a'],['grant','b'],['speak','a']]"]
expected = {1: [[['secret'], [], [['a', 1]]], [['new'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['a'], [('b', 1)], [['a', 1], ['b', 1]]]], 2: [[['secretsecret'], [], [['a', 1]]], [['newnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aa'], [('b', 1)], [['a', 1], ['b', 1]]]], 3: [[['secretsecretsecret'], [], [['a', 1]]], [['newnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 4: [[['secretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaa'], [('b', 1)], [['a', 1], ['b', 1]]]], 5: [[['secretsecretsecretsecretsecret'], [], [['a', 1]]], [['newnewnewnewnew'], [], [['a', 2]]], [['other'], [], [['a', 1], ['b', 1]]], [['private announcement available', 'secretsecretsecretsecretsecret'], [], [['a', 1]]], [[], [], []], [[], [], [['a', 1]]], [[], [], []], [['aaaaa'], [('b', 1)], [['a', 1], ['b', 1]]]]}[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 confirmation-gate contract.

Sensitive announcements require a one-use consent token bound to message ID and text revision. Draft replaces text and increments revision. Grant captures current revision. Speak requires current matching consent, emits text and consumes consent. Revoke removes consent; delete removes draft and consent. Nonsensitive preview emits only fixed redacted cue without consuming consent. Expire removes all grants but preserves drafts. Return speech and remaining grant/draft revisions.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=2
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=0
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-2)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth<=1:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in reversed(list(pending.items()))])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],1] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pass
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.pop(next(iter(pending)),None) if pending else None
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.clear()
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pass
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': pass
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency' and not depth: out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[old[0] or e[2],old[1]+1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],1]
            else: out.append([e[1],e[2],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


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

N = 1
observations = []
def solve(events):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[2],0])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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):
    depth=0; pending={}; out=[]
    for e in events:
        if e[0]=='enter': depth+=1
        elif e[0]=='leave':
            was=depth; depth=max(0,depth-1)
            if was>0 and depth==0:
                out.extend([[k,v[0],v[1]] for k,v in pending.items()])
                pending.clear()
        elif e[0]=='reset': depth=0; pending.clear()
        elif e[0]=='remove': pending.pop(e[1],None)
        elif e[0]=='message':
            if e[3]=='emergency': out.append([e[1],e[2],1])
            elif depth:
                old=pending.get(e[1],['',0])
                pending[e[1]]=[e[2],old[1]+1]
            else: out.append([e[1],e[1],1])
    return [out,depth,[[k]+v for k,v in pending.items()]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = ["[['enter'],['enter'],['message','a','first'*N,'normal'],['leave']]", "[['enter'],['message','z','old','normal'],['message','a','a'*N,'normal'],['message','z','new','normal'],['leave'],['enter'],['leave']]", "[['enter'],['message','a','urgent'*N,'emergency']]", "[['enter'],['message','a','urgent'*N,'emergency'],['message','b','deferred','normal'],['leave']]", "[['enter'],['message','a','a'*N,'normal'],['message','b','b','normal'],['remove','a']]", "[['enter'],['message','a','x'*N,'normal'],['reset']]", "[['message','a','direct'*N,'normal'],['leave'],['leave']]", "[['enter'],['message','a','x'*N,'normal'],['leave'],['leave']]"]
expected = {1: [[[], 1, [['a', 'first', 1]]], [[['z', 'new', 2], ['a', 'a', 1]], 0, []], [[['a', 'urgent', 1]], 1, []], [[['a', 'urgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'direct', 1]], 0, []], [[['a', 'x', 1]], 0, []]], 2: [[[], 1, [['a', 'firstfirst', 1]]], [[['z', 'new', 2], ['a', 'aa', 1]], 0, []], [[['a', 'urgenturgent', 1]], 1, []], [[['a', 'urgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirect', 1]], 0, []], [[['a', 'xx', 1]], 0, []]], 3: [[[], 1, [['a', 'firstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaa', 1]], 0, []], [[['a', 'urgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirect', 1]], 0, []], [[['a', 'xxx', 1]], 0, []]], 4: [[[], 1, [['a', 'firstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirect', 1]], 0, []], [[['a', 'xxxx', 1]], 0, []]], 5: [[[], 1, [['a', 'firstfirstfirstfirstfirst', 1]]], [[['z', 'new', 2], ['a', 'aaaaa', 1]], 0, []], [[['a', 'urgenturgenturgenturgenturgent', 1]], 1, []], [[['a', 'urgenturgenturgenturgenturgent', 1], ['b', 'deferred', 1]], 0, []], [[], 1, [['b', 'b', 1]]], [[], 0, []], [[['a', 'directdirectdirectdirectdirect', 1]], 0, []], [[['a', 'xxxxx', 1]], 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 quiet-session contract.

Quiet nesting is a counter. Enter increments; leave decrements without going negative. Ordinary messages during quiet replace a per-topic summary [latest,count], emergency speech always emits immediately. Final leave emits summaries in topic first-seen order as [topic,latest,count]. Remove-topic discards only that summary. Reset quiet silently discards backlog. Ordinary speech outside quiet emits directly with count1. Report output, nesting and pending summaries.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access


prompt:
The announcement trace violates the stated escalation-ladder contract.

Unacknowledged notices have [text,level,next-due]. Open replaces notice at level0 due after2 ticks. Tick uses monotonic clock and emits at most one escalation per notice when due; levels1 and2 schedule another2 ticks, level3 is final and has no future due. Ack removes notice. Snooze adds delay to existing deadline, not now. Edit text preserves escalation level. Reset-level sets level0 and next due now+2. Report [id,text,level] speech and pending state.

split: open-access