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(d['path']):
            if False:
                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']):
            if node==d['path'][-1] and 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 opens a denied intermediate branch 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(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(node,[]):
                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=d['generation']==d['request_generation']
    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 sum(d['children'].values(),[]):
                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 readiness checks unrelated parent-child links 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(d['path']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=node; 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']):
            if node in d['denied']:
                blocked=node; break
            if i and node not in d['children'].get(d['path'][i-1],[]):
                request=d['path'][0]; 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 loads missing child instead of its owning parent 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(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
            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']):
            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==0: 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 adds leaf expansion or omits intermediate branches 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(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 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']):
            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 is not 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 reports completion before target is reached 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