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

N = 1
observations = []
def solve(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected'])-bool(d['draft']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return d['limit']
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 capacity completion transition produces an incorrect observable state.

Accepting a suggestion appends its identifier once, preserving selection order and independent duplicate labels. Removing a token removes that identity only. Already-selected results are excluded, pending query text is separate from selected values, and capacity is measured in committed identities.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return bool(d['selected']) and len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 at-limit completion transition produces an incorrect observable state.

Accepting a suggestion appends its identifier once, preserving selection order and independent duplicate labels. Removing a token removes that identity only. Already-selected results are excluded, pending query text is separate from selected values, and capacity is measured in committed identities.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']+[d['draft']]
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['labels']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 submit completion transition produces an incorrect observable state.

Accepting a suggestion appends its identifier once, preserving selection order and independent duplicate labels. Removing a token removes that identity only. Already-selected results are excluded, pending query text is separate from selected values, and capacity is measured in committed identities.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':d['draft'],'epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']}
    if event == 'undo-remove': return [d['remove']]+[x for x in d['selected'] if x!=d['remove']] if d['remove'] in d['selected'] else d['selected']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 after-accept completion transition produces an incorrect observable state.

Accepting a suggestion appends its identifier once, preserving selection order and independent duplicate labels. Removing a token removes that identity only. Already-selected results are excluded, pending query text is separate from selected values, and capacity is measured in committed identities.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return [d['remove']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'repeat': return d['selected'] if d['candidate'] in d['selected'] else d['selected']+[d['candidate']]
    if event == 'append': return d['selected']+[d['new']]
    if event == 'remove': return [x for x in d['selected'] if x!=d['remove']]
    if event == 'filter': return [x for x in d['results'] if x not in d['selected']]
    if event == 'labels': return list(zip(d['selected'],d['labels']))
    if event == 'capacity': return max(0,d['limit']-len(d['selected']))
    if event == 'at-limit': return len(d['selected'])>=d['limit']
    if event == 'submit': return d['selected']
    if event == 'after-accept': return {'draft':'','epoch':d['epoch']+1}
    if event == 'undo-remove': return d['selected']+[d['remove']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'selected':['a','b'],'labels':['Same','Same'],'candidate':'b','new':'c','remove':'a','results':['a','c','d'],'draft':'ca','limit':3,'epoch':N}
boundary = {'selected':[],'labels':[],'candidate':'','new':'','remove':'missing','results':[''],'draft':'','limit':0,'epoch':N}
check('normal repeat', solve('repeat', normal), ['a','b'])
check('boundary repeat', solve('repeat', boundary), [''])
check('normal append', solve('append', normal), ['a','b','c'])
check('boundary append', solve('append', boundary), [''])
check('normal remove', solve('remove', normal), ['b'])
check('boundary remove', solve('remove', boundary), [])
check('normal filter', solve('filter', normal), ['c','d'])
check('boundary filter', solve('filter', boundary), [''])
check('normal labels', solve('labels', normal), [('a','Same'),('b','Same')])
check('boundary labels', solve('labels', boundary), [])
check('normal capacity', solve('capacity', normal), 1)
check('boundary capacity', solve('capacity', boundary), 0)
check('normal at-limit', solve('at-limit', normal), False)
check('boundary at-limit', solve('at-limit', boundary), True)
check('normal submit', solve('submit', normal), ['a','b'])
check('boundary submit', solve('submit', boundary), [])
check('normal after-accept', solve('after-accept', normal), {'draft':'','epoch':N+1})
check('boundary after-accept', solve('after-accept', boundary), {'draft':'','epoch':N+1})
check('normal undo-remove', solve('undo-remove', normal), ['a','b'])
check('boundary undo-remove', solve('undo-remove', boundary), [])
variant = dict(normal, **{'new':'id'+str(N)})
check('variant query or selection payload', solve('append', variant), ['a','b','id'+str(N)])
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 undo-remove completion transition produces an incorrect observable state.

Accepting a suggestion appends its identifier once, preserving selection order and independent duplicate labels. Removing a token removes that identity only. Already-selected results are excluded, pending query text is separate from selected values, and capacity is measured in committed identities.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['insert']
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 replace completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['caret']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return ''
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 prefix completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][max(0,d['end']-1):]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return ''
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 suffix completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['end']
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 caret completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return [d['caret'],d['caret']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 selection completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']<=d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']<d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 stale-span completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start'],d['end']]
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start'],d['start']+len(d['insert'])]
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 collapse completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['suffix']+d['insert']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 delimiter completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return d['end']-d['start']
    if event == 'capture': return d['text'][d['start']:d['end']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 delta completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access


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

N = 1
observations = []
def solve(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text']
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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(event, d):
    if event == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
    if event == 'prefix': return d['text'][:d['start']]
    if event == 'suffix': return d['text'][d['end']:]
    if event == 'caret': return d['start']+len(d['insert'])
    if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
    if event == 'stale-span': return d['span_epoch']==d['epoch']
    if event == 'collapse': return [d['start']+len(d['insert'])]*2
    if event == 'delimiter': return d['insert']+d['suffix']
    if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
    if event == 'capture': return d['text'][d['start']:d['caret']]
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
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 capture completion transition produces an incorrect observable state.

Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.

split: open-access