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

N = 1
observations = []
def solve(d):
    local=d['width']-d['x'] if d['rtl'] else d['x']
    logical=local+d['scroll']
    start=d['depth']*d['indent']
    end=start+d['indent']
    inside=0<=d['x']<d['width'] and 0<=d['y']<d['height']
    disclosure=start<=logical<end and d['branch']
    text=logical>=end
    control=next((name for name,left,right in d['controls'] if left<=logical<right),None)
    action=('control:'+control) if control is not None else ('toggle' if disclosure else ('select' if text else 'none'))
    action=action if inside else 'none'
    return [action,logical,start,end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('disclosure start', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 130, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 130, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 130, 'x': 110, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 130, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 130, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 130, 'x': 130, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 130, 20, 30]), ('bottom edge', {'width': 130, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 130, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 2: [('disclosure start', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 140, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 140, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 140, 'x': 120, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 140, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 140, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 140, 'x': 140, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 140, 20, 30]), ('bottom edge', {'width': 140, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 140, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 3: [('disclosure start', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 150, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 150, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 150, 'x': 130, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 150, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 150, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 150, 'x': 150, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 150, 20, 30]), ('bottom edge', {'width': 150, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 150, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 4: [('disclosure start', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 160, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 160, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 160, 'x': 140, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 160, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 160, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 160, 'x': 160, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 160, 20, 30]), ('bottom edge', {'width': 160, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 160, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 5: [('disclosure start', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 170, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 170, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 170, 'x': 150, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 170, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 170, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 170, 'x': 170, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 170, 20, 30]), ('bottom edge', {'width': 170, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 170, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])]}
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):
    local=d['width']-d['x'] if d['rtl'] else d['x']
    logical=local+d['scroll']
    start=d['depth']*d['indent']
    end=start+d['indent']
    inside=0<=d['x']<d['width'] and 0<=d['y']<d['height']
    disclosure=start<=logical<end and d['branch']
    text=logical>=end
    control=next((name for name,left,right in d['controls'] if left<=logical<right),None)
    action=('control:'+control) if control is not None else ('toggle' if disclosure else ('select' if text else 'none'))
    action=action if not d['disabled'] else 'none'
    return [action,logical,start,end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('disclosure start', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 130, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 130, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 130, 'x': 110, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 130, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 130, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 130, 'x': 130, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 130, 20, 30]), ('bottom edge', {'width': 130, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 130, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 130, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 2: [('disclosure start', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 140, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 140, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 140, 'x': 120, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 140, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 140, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 140, 'x': 140, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 140, 20, 30]), ('bottom edge', {'width': 140, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 140, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 140, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 3: [('disclosure start', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 150, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 150, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 150, 'x': 130, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 150, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 150, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 150, 'x': 150, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 150, 20, 30]), ('bottom edge', {'width': 150, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 150, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 150, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 4: [('disclosure start', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 160, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 160, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 160, 'x': 140, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 160, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 160, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 160, 'x': 160, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 160, 20, 30]), ('bottom edge', {'width': 160, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 160, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 160, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])], 5: [('disclosure start', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('text boundary', {'width': 170, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['select', 30, 20, 30]), ('leaf disclosure', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 20, 20, 30]), ('leaf indent', {'width': 170, 'x': 25, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': False, 'controls': [], 'disabled': False}, ['none', 25, 20, 30]), ('scrolled control', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('RTL', {'width': 170, 'x': 150, 'y': 3, 'rtl': True, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('scrolled', {'width': 170, 'x': 10, 'y': 3, 'rtl': False, 'scroll': 10, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['toggle', 20, 20, 30]), ('control overlay', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 20, 30]], 'disabled': False}, ['control:edit', 20, 20, 30]), ('control start', {'width': 170, 'x': 30, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [['edit', 30, 40]], 'disabled': False}, ['control:edit', 30, 20, 30]), ('right edge', {'width': 170, 'x': 170, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 170, 20, 30]), ('bottom edge', {'width': 170, 'x': 40, 'y': 20, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('above row', {'width': 170, 'x': 40, 'y': -1, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': False}, ['none', 40, 20, 30]), ('disabled', {'width': 170, 'x': 20, 'y': 3, 'rtl': False, 'scroll': 0, 'depth': 2, 'indent': 10, 'height': 20, 'branch': True, 'controls': [], 'disabled': True}, ['none', 20, 20, 30])]}
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:
Disabled or outside row still performs hit action produces the wrong hierarchical widget state in a regression fixture.

Hit testing is in logical row coordinates after horizontal scrolling. Disclosure zone occupies one indent unit at the row depth; row text starts after it. Leaves have no disclosure action. RTL reflects the physical x coordinate. Drag handles and editable fields take priority over row selection.

split: open-access


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

N = 1
observations = []
def solve(d):
    current=True
    opened=set(d['opened']); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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):
    current=False
    opened=set(d['opened']); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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:
Stale reveal request expands current tree produces the wrong hierarchical widget state in a regression fixture.

Reveal consumes an ordered root-to-target path. Already loaded branches are opened in order until the first missing child link, then exactly one load is requested. Focus moves only when the target is visible and the request generation is current. A denied branch stops reveal before opening it.

split: open-access


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

N = 1
observations = []
def solve(d):
    current=d['generation']==d['request_generation']
    opened=set(); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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):
    current=d['generation']==d['request_generation']
    opened=set(d['path']); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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:
Reveal discards unrelated expansion or opens full path prematurely produces the wrong hierarchical widget state in a regression fixture.

Reveal consumes an ordered root-to-target path. Already loaded branches are opened in order until the first missing child link, then exactly one load is requested. Focus moves only when the target is visible and the request generation is current. A denied branch stops reveal before opening it.

split: open-access


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

N = 1
observations = []
def solve(d):
    current=d['generation']==d['request_generation']
    opened=set(d['opened']); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(list(reversed(d['path']))):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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):
    current=d['generation']==d['request_generation']
    opened=set(d['opened']); request=None; blocked=None; reached=None
    if current:
        for i,node in enumerate(d['path'][:1]):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][i-1]; break
            reached=node
            if i<len(d['path'])-1: opened.add(node)
    finished=current and bool(d['path']) and reached==d['path'][-1] and blocked is None and request is None
    focus=d['path'][-1] if finished else d['focus']
    pending=d['path'][d['path'].index(reached)+1:] if current and reached in d['path'] else (d['path'] if current else [])
    return [sorted(opened),request,blocked,finished,focus,pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('complete reveal', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 1, 'request_generation': 0, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 1, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 2: [('complete reveal', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 2, 'request_generation': 1, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 2, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 3: [('complete reveal', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 3, 'request_generation': 2, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 3, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 4: [('complete reveal', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 4, 'request_generation': 3, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 4, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])], 5: [('complete reveal', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], None, None, True, 'c', []]), ('missing deep child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': []}, 'focus': 'q'}, [['a', 'b', 'q', 'r'], 'b', None, False, 'q', ['c']]), ('wrong branch child', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a', 'b'], 'a': [], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], 'a', None, False, 'q', ['b', 'c']]), ('denied middle', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['b'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['a', 'q', 'r'], None, 'b', False, 'q', ['b', 'c']]), ('stale request', {'generation': 5, 'request_generation': 4, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('empty path', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': [], 'denied': [], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, None, False, 'q', []]), ('denied root', {'generation': 5, 'request_generation': 5, 'opened': ['q'], 'path': ['r', 'a', 'b', 'c'], 'denied': ['r'], 'children': {'r': ['a'], 'a': ['b'], 'b': ['c']}, 'focus': 'q'}, [['q'], None, 'r', False, 'q', ['r', 'a', 'b', 'c']])]}
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:
Reveal walks target path in wrong direction or stops at root produces the wrong hierarchical widget state in a regression fixture.

Reveal consumes an ordered root-to-target path. Already loaded branches are opened in order until the first missing child link, then exactly one load is requested. Focus moves only when the target is visible and the request generation is current. A denied branch stops reveal before opening it.

split: open-access