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

N = 1
observations = []
def solve(d):
    nearest=next((x[1] for x in d['path'] if x[0]=='tree'),None)
    owned=nearest==d['tree']
    row=next((x[1] for x in d['path'] if x[0]=='row'),None)
    editor=any(x[0]=='editor' for x in d['path'][:next((i for i,x in enumerate(d['path']) if x[0]=='row'),len(d['path']))])
    already=d['handled']
    command=owned and row in d['rows'] and not already and not editor
    activate=command and d['event']=='activate' and row not in d['disabled']
    inspect=command and d['event']=='inspect'
    stop=owned
    focus=row if activate else d['focus']
    return [owned,row,editor,activate,inspect,stop,focus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 2: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 3: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 4: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 5: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    nearest=next((x[1] for x in d['path'] if x[0]=='tree'),None)
    owned=nearest==d['tree']
    row=next((x[1] for x in d['path'] if x[0]=='row'),None)
    editor=any(x[0]=='editor' for x in d['path'][:next((i for i,x in enumerate(d['path']) if x[0]=='row'),len(d['path']))])
    already=d['handled']
    command=owned and row in d['rows'] and not already and not editor
    activate=command and d['event']=='activate' and row not in d['disabled']
    inspect=command and d['event']=='inspect'
    stop=False
    focus=row if activate else d['focus']
    return [owned,row,editor,activate,inspect,stop,focus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 2: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 3: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 4: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 5: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Tree event propagation is stopped without consuming command produces the wrong hierarchical widget state in a regression fixture.

A nested tree handles row events only for its nearest owning tree. Composed event paths may contain row editors and embedded widgets. Editing-origin keys remain with the editor; handled child-tree events do not bubble into ancestor tree commands. Disabled rows suppress activation but still permit context inspection.

split: open-access


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

N = 1
observations = []
def solve(d):
    nearest=next((x[1] for x in d['path'] if x[0]=='tree'),None)
    owned=nearest==d['tree']
    row=next((x[1] for x in d['path'] if x[0]=='row'),None)
    editor=any(x[0]=='editor' for x in d['path'][:next((i for i,x in enumerate(d['path']) if x[0]=='row'),len(d['path']))])
    already=d['handled']
    command=owned and row in d['rows'] and not already and not editor
    activate=command and d['event']=='activate' and row not in d['disabled']
    inspect=command and d['event']=='inspect'
    stop=command and (activate or inspect)
    focus=row if command else d['focus']
    return [owned,row,editor,activate,inspect,stop,focus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 2: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 3: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 4: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 5: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    nearest=next((x[1] for x in d['path'] if x[0]=='tree'),None)
    owned=nearest==d['tree']
    row=next((x[1] for x in d['path'] if x[0]=='row'),None)
    editor=any(x[0]=='editor' for x in d['path'][:next((i for i,x in enumerate(d['path']) if x[0]=='row'),len(d['path']))])
    already=d['handled']
    command=owned and row in d['rows'] and not already and not editor
    activate=command and d['event']=='activate' and row not in d['disabled']
    inspect=command and d['event']=='inspect'
    stop=command and (activate or inspect)
    focus=d['focus']
    return [owned,row,editor,activate,inspect,stop,focus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 2: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 3: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 4: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])], 5: [('inner activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('outer listener', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'outer', 'rows': ['outerrow'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [False, 'b', False, False, False, False, 'a']), ('editor origin', {'path': [['editor', 'e'], ['row', 'b'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', True, False, False, False, 'a']), ('editor outside row', {'path': [['row', 'b'], ['editor', 'outer'], ['tree', 'inner']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, True, False, True, 'b']), ('handled child', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': True, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled activation', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'activate', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('disabled inspect', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'inspect', 'disabled': ['b'], 'focus': 'a'}, [True, 'b', False, False, True, True, 'a']), ('unregistered row', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a'], 'handled': False, 'event': 'activate', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a']), ('other event', {'path': [['row', 'b'], ['tree', 'inner'], ['row', 'outerrow'], ['tree', 'outer']], 'tree': 'inner', 'rows': ['a', 'b', 'v0', 'v1', 'v2', 'v3', 'v4'], 'handled': False, 'event': 'hover', 'disabled': [], 'focus': 'a'}, [True, 'b', False, False, False, False, 'a'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Inspection steals focus or activation fails to move it produces the wrong hierarchical widget state in a regression fixture.

A nested tree handles row events only for its nearest owning tree. Composed event paths may contain row editors and embedded widgets. Editing-origin keys remain with the editor; handled child-tree events do not bubble into ancestor tree commands. Disabled rows suppress activation but still permit context inspection.

split: open-access


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

N = 1
observations = []
def solve(d):
    same=d['target']==d['previous_target']
    since=d['since'] if same else d['now']
    eligible=d['target'] in d['branches'] and d['target'] not in d['closure'] and d['legal']
    elapsed=max(0,d['now']-since)
    trigger=eligible and elapsed>=d['dwell'] and d['active']
    auto=set(d['auto'])
    if trigger and d['target'] not in d['user_open']: auto.add(d['target'])
    if not d['active'] and d['cancelled']: auto.clear()
    expanded=sorted(set(d['user_open'])|auto)
    timer=[d['target'],since,d['drag']] if eligible and d['active'] and not trigger else None
    return [expanded,sorted(auto),timer,trigger]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 10, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 1], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 11, 1], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 0, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 11, 1], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 9, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 1], False])], 2: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 11, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 2], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 12, 2], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 1, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 12, 2], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 9, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 2], False])], 3: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 12, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 3], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 13, 3], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 2, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 13, 3], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 9, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 3], False])], 4: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 13, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 4], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 14, 4], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 3, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 14, 4], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 9, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 4], False])], 5: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 14, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 5], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 15, 5], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 4, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 15, 5], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 9, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 5], False])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    same=d['drag']==d['timer_drag']
    since=d['since'] if same else d['now']
    eligible=d['target'] in d['branches'] and d['target'] not in d['closure'] and d['legal']
    elapsed=max(0,d['now']-since)
    trigger=eligible and elapsed>=d['dwell'] and d['active']
    auto=set(d['auto'])
    if trigger and d['target'] not in d['user_open']: auto.add(d['target'])
    if not d['active'] and d['cancelled']: auto.clear()
    expanded=sorted(set(d['user_open'])|auto)
    timer=[d['target'],since,d['drag']] if eligible and d['active'] and not trigger else None
    return [expanded,sorted(auto),timer,trigger]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 10, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 1], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 11, 1], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 0, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 11, 1], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 11, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 1, 'timer_drag': 1, 'since': 10, 'now': 9, 'dwell': 1, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 1], False])], 2: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 11, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 2], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 12, 2], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 1, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 12, 2], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 12, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 2, 'timer_drag': 2, 'since': 10, 'now': 9, 'dwell': 2, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 2], False])], 3: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 12, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 3], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 13, 3], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 2, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 13, 3], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 13, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 3, 'timer_drag': 3, 'since': 10, 'now': 9, 'dwell': 3, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 3], False])], 4: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 13, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 4], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 14, 4], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 3, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 14, 4], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 14, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 4, 'timer_drag': 4, 'since': 10, 'now': 9, 'dwell': 4, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 4], False])], 5: [('at deadline', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'b', 'r'], ['a', 'b'], None, True]), ('before deadline', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 14, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 5], False]), ('changed target', {'target': 'b', 'previous_target': 'a', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 15, 5], False]), ('new drag', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 4, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 15, 5], False]), ('illegal descendant', {'target': 'c', 'previous_target': 'c', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b', 'c'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('permission denied', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': False, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('cancelled', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': True}, [['r'], [], None, False]), ('committed drop', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': False, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], None, False]), ('user opened', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 15, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r', 'b'], 'cancelled': False}, [['a', 'b', 'r'], ['a'], None, True]), ('negative elapsed', {'target': 'b', 'previous_target': 'b', 'drag': 5, 'timer_drag': 5, 'since': 10, 'now': 9, 'dwell': 5, 'branches': ['a', 'b'], 'closure': ['s', 'c'], 'legal': True, 'active': True, 'auto': ['a'], 'user_open': ['r'], 'cancelled': False}, [['a', 'r'], ['a'], ['b', 10, 5], False])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Hover timer reuses another target or drag generation produces the wrong hierarchical widget state in a regression fixture.

Hover expansion processing occurs only after dwell on a legal branch. Already user-open branches must not acquire hover ownership. Leaving or changing target resets the timer. A drag generation prevents old timers expanding a later drag. Auto-opened branches close on cancelled drag but user-open branches remain.

split: open-access