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

N = 1
observations = []
def solve(sorting, column, multi, removable):
    sorting = list(sorting)
    index = next((i for i, (c, d) in enumerate(sorting) if c == column), None)
    if index is None: entry = (column, 'asc')
    elif sorting[index][1] == 'asc': entry = (column, 'desc')
    else: entry = None if removable else (column, 'asc')
    if not multi: return sorting + ([entry] if entry else [])
    if index is None: return sorting + [entry]
    if entry is None: return sorting[:index] + sorting[index+1:]
    sorting[index] = entry
    return sorting
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve([], 'a', False, True), [('a', 'asc')])
check('reverse', solve([('a','asc')], 'a', False, True), [('a', 'desc')])
check('locked', solve([('a','desc')], 'a', False, False), [('a', 'asc')])
check('remove', solve([('a','desc')], 'a', False, True), [])
check('single', solve([('a','asc')], 'b', False, True), [('b', 'asc')])
check('priority', solve([('a','asc'),('b','asc')], 'a', True, True), [('a', 'desc'), ('b', 'asc')])
check('append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
check('parameterized sort identity', solve([],str(N),False,True), [(str(N),'asc')])
for repetition in range(N):
    check('repeat append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
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)

evaluation_group: xi-sort-indicator

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

N = 1
observations = []
def solve(sorting, column, multi, removable):
    sorting = list(sorting)
    index = next((i for i, (c, d) in enumerate(sorting) if c == column), None)
    if index is None: entry = (column, 'asc')
    elif sorting[index][1] == 'asc': entry = (column, 'desc')
    else: entry = None if removable else (column, 'asc')
    if not multi: return sorting
    if index is None: return sorting + [entry]
    if entry is None: return sorting[:index] + sorting[index+1:]
    sorting[index] = entry
    return sorting
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve([], 'a', False, True), [('a', 'asc')])
check('reverse', solve([('a','asc')], 'a', False, True), [('a', 'desc')])
check('locked', solve([('a','desc')], 'a', False, False), [('a', 'asc')])
check('remove', solve([('a','desc')], 'a', False, True), [])
check('single', solve([('a','asc')], 'b', False, True), [('b', 'asc')])
check('priority', solve([('a','asc'),('b','asc')], 'a', True, True), [('a', 'desc'), ('b', 'asc')])
check('append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
check('parameterized sort identity', solve([],str(N),False,True), [(str(N),'asc')])
for repetition in range(N):
    check('repeat append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
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:
Single-sort activation retains other sort priorities.

New sort is ascending; activation cycles ascending to descending to removed when allowed; single mode replaces all sorts; multi mode preserves priorities when changing direction.

split: open-access


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

N = 1
observations = []
def solve(sorting, column, multi, removable):
    sorting = list(sorting)
    index = next((i for i, (c, d) in enumerate(sorting) if c == column), None)
    if index is None: entry = (column, 'asc')
    elif sorting[index][1] == 'asc': entry = (column, 'desc')
    else: entry = None if removable else (column, 'asc')
    if not multi: return [entry] if entry else []
    if index is None: return sorting + [entry]
    if entry is None: return sorting[:index] + sorting[index+1:]
    sorting.pop(index); sorting.append(entry)
    return sorting
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve([], 'a', False, True), [('a', 'asc')])
check('reverse', solve([('a','asc')], 'a', False, True), [('a', 'desc')])
check('locked', solve([('a','desc')], 'a', False, False), [('a', 'asc')])
check('remove', solve([('a','desc')], 'a', False, True), [])
check('single', solve([('a','asc')], 'b', False, True), [('b', 'asc')])
check('priority', solve([('a','asc'),('b','asc')], 'a', True, True), [('a', 'desc'), ('b', 'asc')])
check('append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
check('parameterized sort identity', solve([],str(N),False,True), [(str(N),'asc')])
for repetition in range(N):
    check('repeat append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
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

evaluation_group: xi-sort-indicator

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

N = 1
observations = []
def solve(sorting, column, multi, removable):
    sorting = list(sorting)
    index = next((i for i, (c, d) in enumerate(sorting) if c == column), None)
    if index is None: entry = (column, 'asc')
    elif sorting[index][1] == 'asc': entry = (column, 'desc')
    else: entry = None if removable else (column, 'asc')
    if not multi: return [entry] if entry else []
    if index is None: return sorting + [entry]
    if entry is None: return sorting[:index] + sorting[index+1:]
    sorting.insert(0, entry)
    return sorting
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve([], 'a', False, True), [('a', 'asc')])
check('reverse', solve([('a','asc')], 'a', False, True), [('a', 'desc')])
check('locked', solve([('a','desc')], 'a', False, False), [('a', 'asc')])
check('remove', solve([('a','desc')], 'a', False, True), [])
check('single', solve([('a','asc')], 'b', False, True), [('b', 'asc')])
check('priority', solve([('a','asc'),('b','asc')], 'a', True, True), [('a', 'desc'), ('b', 'asc')])
check('append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
check('parameterized sort identity', solve([],str(N),False,True), [(str(N),'asc')])
for repetition in range(N):
    check('repeat append', solve([('a','asc')], 'b', True, True), [('a', 'asc'), ('b', 'asc')])
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:
Changing direction moves the column to lowest priority.

New sort is ascending; activation cycles ascending to descending to removed when allowed; single mode replaces all sorts; multi mode preserves priorities when changing direction.

split: open-access


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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if any(v == value for f,v in chips): return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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)

evaluation_group: xi-filter-chips

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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if False: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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:
Equal values in different filter fields are collapsed.

Chip identity includes field and value; exclusive replacement clears only that field; removal targets one identity; field clear and global clear have distinct scope.

split: open-access


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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = []
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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)

evaluation_group: xi-filter-chips

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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = chips
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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:
Replacing an exclusive field clears unrelated filters.

Chip identity includes field and value; exclusive replacement clears only that field; removal targets one identity; field clear and global clear have distinct scope.

split: open-access


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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if v != value]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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)

evaluation_group: xi-filter-chips

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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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:
Removing one chip removes equal values from other fields.

Chip identity includes field and value; exclusive replacement clears only that field; removal targets one identity; field clear and global clear have distinct scope.

split: open-access


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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = []
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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)

evaluation_group: xi-filter-chips

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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f == field]
    elif event == 'clear-all': chips = []
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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:
Clearing one field clears every filter.

Chip identity includes field and value; exclusive replacement clears only that field; removal targets one identity; field clear and global clear have distinct scope.

split: open-access


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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = chips[:-1]
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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)

evaluation_group: xi-filter-chips

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

N = 1
observations = []
def solve(chips, event, field, value, exclusive):
    chips = list(chips)
    if event == 'add':
        if (field,value) in chips: return chips
        if exclusive: chips = [(f,v) for f,v in chips if f != field]
        chips.append((field,value))
    elif event == 'remove': chips = [(f,v) for f,v in chips if (f,v) != (field,value)]
    elif event == 'clear-field': chips = [(f,v) for f,v in chips if f != field]
    elif event == 'clear-all': chips = [(f,v) for f,v in chips if f != field]
    return chips
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cross field', solve([('color','red')], 'add', 'tag', 'red', False), [('color', 'red'), ('tag', 'red')])
check('duplicate', solve([('color','red')], 'add', 'color', 'red', False), [('color', 'red')])
check('exclusive', solve([('color','red'),('tag','new')], 'add', 'color', 'blue', True), [('tag', 'new'), ('color', 'blue')])
check('remove identity', solve([('color','red'),('color','blue'),('tag','red')], 'remove', 'color', 'red', False), [('color', 'blue'), ('tag', 'red')])
check('clear field', solve([('color','red'),('tag','new')], 'clear-field', 'color', None, False), [('tag', 'new')])
check('clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
check('parameterized filter criterion', solve([],'add','field',str(N),False), [('field',str(N))])
for repetition in range(N):
    check('repeat clear all', solve([('color','red'),('tag','new')], 'clear-all', 'color', None, False), [])
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:
Clear-all removes only the last criterion.

Chip identity includes field and value; exclusive replacement clears only that field; removal targets one identity; field clear and global clear have distinct scope.

split: open-access


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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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)

evaluation_group: xi-ime-keys

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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing and code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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:
Composition Enter triggers a submit before IME commitment.

Composition state or legacy code 229 delegates to native input; plain multiline Enter inserts newline; other Enter submits; Escape preserves draft; Tab honors Shift.

split: open-access


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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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)

evaluation_group: xi-ime-keys

prompt:
Legacy composition key events bypass the IME guard.

Composition state or legacy code 229 delegates to native input; plain multiline Enter inserts newline; other Enter submits; Escape preserves draft; Tab honors Shift.

split: open-access


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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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)

evaluation_group: xi-ime-keys

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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if multiline: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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:
Single-line Enter inserts a newline instead of submitting.

Composition state or legacy code 229 delegates to native input; plain multiline Enter inserts newline; other Enter submits; Escape preserves draft; Tab honors Shift.

split: open-access


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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', '')
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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)

evaluation_group: xi-ime-keys

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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('submit', value)
    if key == 'Tab': return ('previous' if shift else 'next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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:
Escape clears the draft before cancellation handling.

Composition state or legacy code 229 delegates to native input; plain multiline Enter inserts newline; other Enter submits; Escape preserves draft; Tab honors Shift.

split: open-access


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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('next', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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)

evaluation_group: xi-ime-keys

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

N = 1
observations = []
def solve(key, composing, code, shift, multiline, value):
    if composing or code == 229: return ('native', value)
    if key == 'Enter':
        if multiline and not shift: return ('insert', value + '\n')
        return ('submit', value)
    if key == 'Escape': return ('cancel', value)
    if key == 'Tab': return ('previous', value)
    return ('native', value)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('Enter', True, 13, False, False, 'draft'), ('native', 'draft'))
check('legacy', solve('Enter', False, 229, False, False, 'draft'), ('native', 'draft'))
check('single', solve('Enter', False, 13, False, False, 'draft'), ('submit', 'draft'))
check('multiline', solve('Enter', False, 13, False, True, 'draft'), ('insert', 'draft\n'))
check('shift submit', solve('Enter', False, 13, True, True, 'draft'), ('submit', 'draft'))
check('escape', solve('Escape', False, 27, False, False, 'draft'), ('cancel', 'draft'))
check('shift tab', solve('Tab', False, 9, True, False, 'draft'), ('previous', 'draft'))
check('tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
check('parameterized composition text', solve('Enter',True,13,False,False,'draft'+str(N)), ('native','draft'+str(N)))
for repetition in range(N):
    check('repeat tab', solve('Tab', False, 9, False, False, 'draft'), ('next', 'draft'))
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:
Shift-Tab moves focus forward.

Composition state or legacy code 229 delegates to native input; plain multiline Enter inserts newline; other Enter submits; Escape preserves draft; Tab honors Shift.

split: open-access


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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if repeat: return None
    if editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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)

evaluation_group: xi-shortcut

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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented and repeat: return None
    if editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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:
Already-consumed key events dispatch another command.

Ignore prevented, repeated, and editable-origin events; use platform primary modifier; Alt blocks shortcuts; Shift-Z redoes, Z undoes, unshifted S saves.

split: open-access


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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented: return None
    if editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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)

evaluation_group: xi-shortcut

prompt:
Held shortcut keys repeatedly dispatch one-shot actions.

Ignore prevented, repeated, and editable-origin events; use platform primary modifier; Alt blocks shortcuts; Shift-Z redoes, Z undoes, unshifted S saves.

split: open-access


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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if False: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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)

evaluation_group: xi-shortcut

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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if not editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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:
Global undo intercepts editing inside text fields.

Ignore prevented, repeated, and editable-origin events; use platform primary modifier; Alt blocks shortcuts; Shift-Z redoes, Z undoes, unshifted S saves.

split: open-access


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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if editable: return None
    primary = ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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)

evaluation_group: xi-shortcut

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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if editable: return None
    primary = meta
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo' if shift else 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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:
Mac command shortcuts require Control instead of Command.

Ignore prevented, repeated, and editable-origin events; use platform primary modifier; Alt blocks shortcuts; Shift-Z redoes, Z undoes, unshifted S saves.

split: open-access


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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'undo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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)

evaluation_group: xi-shortcut

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

N = 1
observations = []
def solve(key, ctrl, meta, alt, shift, platform, editable, repeat, prevented):
    if prevented or repeat: return None
    if editable: return None
    primary = meta if platform == 'mac' else ctrl
    if not primary or alt: return None
    if key.lower() == 'z': return 'redo'
    if key.lower() == 's' and not shift: return 'save'
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prevented', solve('z', True, False, False, False, 'win', False, False, True), None)
check('repeat', solve('z', True, False, False, False, 'win', False, True, False), None)
check('editable', solve('z', True, False, False, False, 'win', True, False, False), None)
check('mac', solve('z', False, True, False, False, 'mac', False, False, False), 'undo')
check('win', solve('z', True, False, False, False, 'win', False, False, False), 'undo')
check('redo', solve('z', True, False, False, True, 'win', False, False, False), 'redo')
check('alt', solve('z', True, False, True, False, 'win', False, False, False), None)
check('parameterized target context', solve('z',True,False,False,False,'win',bool(N%2),False,False), None if N%2 else 'undo')
for repetition in range(N):
    check('repeat alt', solve('z', True, False, True, False, 'win', False, False, False), None)
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:
Shift-Undo dispatches undo instead of redo.

Ignore prevented, repeated, and editable-origin events; use platform primary modifier; Alt blocks shortcuts; Shift-Z redoes, Z undoes, unshifted S saves.

split: open-access


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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if False: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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)

evaluation_group: xi-undo-grouping

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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before != after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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:
Unchanged input creates an undo record.

Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.

split: open-access


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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and True and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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)

evaluation_group: xi-undo-grouping

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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'delete' and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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:
Deletion transactions merge as if they were adjacent typing.

Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.

split: open-access


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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and True and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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)

evaluation_group: xi-undo-grouping

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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret != caret and not boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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:
Typing at a moved caret merges with a distant edit.

Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.

split: open-access


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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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)

evaluation_group: xi-undo-grouping

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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and boundary
    if merge: history[-1] = (history[-1][0], after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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:
Explicit undo boundaries fail to split typing groups.

Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.

split: open-access


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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (before, after)
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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)

evaluation_group: xi-undo-grouping

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

N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
    history = list(history)
    if before == after: return history
    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary
    if merge: history[-1] = (history[-1][0], history[-1][1])
    else: history.append((before, after))
    return history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
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:
Coalescing loses the text preceding the first grouped edit.

Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.

split: open-access


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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if False: return (None, 0, 0)
    if locked is None:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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)

evaluation_group: xi-gesture-lock

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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (locked, dx, dy)
    if locked is None:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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:
Cancelled gestures continue delivering movement.

Cancelled gestures emit no movement; activate at the maximum absolute-axis threshold; choose dominant magnitude with horizontal tie; lock persists and suppresses cross-axis displacement.

split: open-access


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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if max(dx, dy) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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)

evaluation_group: xi-gesture-lock

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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if min(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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:
Negative-direction drags never cross the gesture threshold.

Cancelled gestures emit no movement; activate at the maximum absolute-axis threshold; choose dominant magnitude with horizontal tie; lock persists and suppresses cross-axis displacement.

split: open-access


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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if max(abs(dx), abs(dy)) <= threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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)

evaluation_group: xi-gesture-lock

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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if max(abs(dx), abs(dy)) > threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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:
Motion exactly at the activation threshold is ignored.

Cancelled gestures emit no movement; activate at the maximum absolute-axis threshold; choose dominant magnitude with horizontal tie; lock persists and suppresses cross-axis displacement.

split: open-access


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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if dx >= dy else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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)

evaluation_group: xi-gesture-lock

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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if locked is None:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'y' if abs(dx) >= abs(dy) else 'x'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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:
Axis choice depends on signed direction rather than magnitude.

Cancelled gestures emit no movement; activate at the maximum absolute-axis threshold; choose dominant magnitude with horizontal tie; lock persists and suppresses cross-axis displacement.

split: open-access


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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if True:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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)

evaluation_group: xi-gesture-lock

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

N = 1
observations = []
def solve(dx, dy, threshold, locked, cancelled):
    if cancelled: return (None, 0, 0)
    if False:
        if max(abs(dx), abs(dy)) < threshold: return (None, 0, 0)
        locked = 'x' if abs(dx) >= abs(dy) else 'y'
    if locked == 'x': return ('x', dx, 0)
    return ('y', 0, dy)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(10, 2, 5, 'x', True), (None, 0, 0))
check('negative', solve(-10, 0, 5, None, False), ('x', -10, 0))
check('threshold', solve(5, 0, 5, None, False), ('x', 5, 0))
check('small', solve(2, 1, 5, None, False), (None, 0, 0))
check('dominant negative', solve(-10, 3, 5, None, False), ('x', -10, 0))
check('vertical', solve(2, -10, 5, None, False), ('y', 0, -10))
check('locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
check('parameterized gesture distance', solve(2*N,0,N,None,False), ('x',2*N,0))
for repetition in range(N):
    check('repeat locked', solve(2, 20, 5, "x", False), ('x', 2, 0))
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:
Established gesture locks switch axes mid-drag.

Cancelled gestures emit no movement; activate at the maximum absolute-axis threshold; choose dominant magnitude with horizontal tie; lock persists and suppresses cross-axis displacement.

split: open-access