{"abstract":"Restoration reads selection or only first expansion produces the wrong hierarchical widget state in a regression fixture.","category":"Tree accessibility","checks":8,"contract":"Only present branch IDs may be restored. Ancestors of restored open branches are opened unless explicitly blocked. Selection and focus restore independently: selection keeps present enabled rows; hidden focus falls back to nearest visible ancestor. The persisted root instance must match.","evaluation_group":"s3-tree-expansion-restore","failed_approach":"The partial repair `set(d['saved_open'][:1]) if valid else set()` still violates a boundary or preservation case.","family":"s3-tree_accessibility-expansion-restore-02","id":"FA-38546","implementations":{"attempt":{"sha256":"015f7eefb1a237387c15c449f983d58cca73a908fd7b622d07f51b150f576ac7","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    valid=d['saved_tree']==d['tree']\n    wanted=set(d['saved_open'][:1]) if valid else set()\n    branches=wanted & set(d['branches'])\n    ancestors={a for x in branches for a in d['ancestors'].get(x,[])}\n    expanded=(branches|ancestors)-set(d['blocked'])\n    selected=[x for x in d['saved_selected'] if valid and x in d['present'] and x not in d['disabled']]\n    visible=[x for x in d['present'] if all(a in expanded for a in d['ancestors'].get(x,[]))]\n    candidate=d['saved_focus'] if valid else None\n    fallback=next((a for a in reversed(d['ancestors'].get(candidate,[])) if a in visible),None)\n    focus=candidate if candidate in visible else (fallback if fallback is not None else (visible[0] if visible else None))\n    return [sorted(expanded),selected,visible,focus]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {1: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'leaf'])], 2: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'leaf'])], 3: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'leaf'])], 4: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'leaf'])], 5: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'leaf'])]}\nfor label, data, expected in cases[N]:\n    check(label, solve(data), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"db6ea32a8aef33c6796777019512220797527245e699b57e12151bcff4a3f8b5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    valid=d['saved_tree']==d['tree']\n    wanted=set(d['saved_selected']) if valid else set()\n    branches=wanted & set(d['branches'])\n    ancestors={a for x in branches for a in d['ancestors'].get(x,[])}\n    expanded=(branches|ancestors)-set(d['blocked'])\n    selected=[x for x in d['saved_selected'] if valid and x in d['present'] and x not in d['disabled']]\n    visible=[x for x in d['present'] if all(a in expanded for a in d['ancestors'].get(x,[]))]\n    candidate=d['saved_focus'] if valid else None\n    fallback=next((a for a in reversed(d['ancestors'].get(candidate,[])) if a in visible),None)\n    focus=candidate if candidate in visible else (fallback if fallback is not None else (visible[0] if visible else None))\n    return [sorted(expanded),selected,visible,focus]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {1: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'leaf'])], 2: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'leaf'])], 3: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'leaf'])], 4: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'leaf'])], 5: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'leaf'])]}\nfor label, data, expected in cases[N]:\n    check(label, solve(data), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"bc4505aa47e30ddeb3b16427c618a7a81e08add271343ca2484643471ae3d28d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    valid=d['saved_tree']==d['tree']\n    wanted=set(d['saved_open']) if valid else set()\n    branches=wanted & set(d['branches'])\n    ancestors={a for x in branches for a in d['ancestors'].get(x,[])}\n    expanded=(branches|ancestors)-set(d['blocked'])\n    selected=[x for x in d['saved_selected'] if valid and x in d['present'] and x not in d['disabled']]\n    visible=[x for x in d['present'] if all(a in expanded for a in d['ancestors'].get(x,[]))]\n    candidate=d['saved_focus'] if valid else None\n    fallback=next((a for a in reversed(d['ancestors'].get(candidate,[])) if a in visible),None)\n    focus=candidate if candidate in visible else (fallback if fallback is not None else (visible[0] if visible else None))\n    return [sorted(expanded),selected,visible,focus]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {1: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0'], 'leaf'])], 2: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1'], 'leaf'])], 3: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2'], 'leaf'])], 4: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3'], 'leaf'])], 5: [('deep saved', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('deep branch alone', {'saved_tree': 't', 'tree': 't', 'saved_open': ['b'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'leaf']), ('foreign snapshot', {'saved_tree': 'other', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'other'}, [[], [], ['r', 'other'], 'r']), ('blocked middle', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['b'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'r'], ['leaf'], ['r', 'a', 'b', 'other'], 'b']), ('blocked root', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': ['r'], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b'], ['leaf'], ['r', 'other'], 'r']), ('no saved branch', {'saved_tree': 't', 'tree': 't', 'saved_open': [], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [[], ['leaf'], ['r', 'other'], 'r']), ('missing focus', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf', 'gone', 'a'], 'present': ['r', 'a', 'b', 'leaf', 'other'], 'disabled': ['a'], 'saved_focus': 'gone'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other'], 'r']), ('deep varying chain', {'saved_tree': 't', 'tree': 't', 'saved_open': ['a', 'b', 'leaf', 'gone'], 'branches': ['r', 'a', 'b'], 'ancestors': {'r': [], 'a': ['r'], 'b': ['r', 'a'], 'leaf': ['r', 'a', 'b'], 'other': []}, 'blocked': [], 'saved_selected': ['leaf'], 'present': ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'disabled': ['a'], 'saved_focus': 'leaf'}, [['a', 'b', 'r'], ['leaf'], ['r', 'a', 'b', 'leaf', 'other', 'v0', 'v1', 'v2', 'v3', 'v4'], 'leaf'])]}\nfor label, data, expected in cases[N]:\n    check(label, solve(data), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"Synthetic deterministic hierarchical-widget data contract; not an implementation of a browser accessibility tree. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"s3-tree_accessibility-expansion-restore-02","generated_at":"2026-09-29T14:43:12.278871+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Offline executable model of a hierarchical accessibility interaction; inputs are bounded and valid as stipulated. No browser, assistive technology, or normative ARIA conformance is claimed.","repair":"Restore `set(d['saved_open']) if valid else set()` at this fault site while retaining the other tree state decisions.","root_cause":"The expansion-restore contract is violated at `set(d['saved_open']) if valid else set()` by replacing it with `set(d['saved_selected']) if valid else set()`.","sha256":"ffb807c6fba2d1d4f6d17231260dc0253c060894af439a255dd59aa8fd9766a1","title":"Persisted hierarchical expansion restoration: Restoration reads selection or only first expansion · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":48.27,"exit_code":1,"observations":[{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"deep saved","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":false},{"actual":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"check":"deep branch alone","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":true},{"actual":[[],[],["r","other"],"r"],"check":"foreign snapshot","expected":[[],[],["r","other"],"r"],"passed":true},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"blocked middle","expected":[["a","r"],["leaf"],["r","a","b","other"],"b"],"passed":true},{"actual":[["a"],["leaf"],["r","other"],"r"],"check":"blocked root","expected":[["a","b"],["leaf"],["r","other"],"r"],"passed":false},{"actual":[[],["leaf"],["r","other"],"r"],"check":"no saved branch","expected":[[],["leaf"],["r","other"],"r"],"passed":true},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"r"],"check":"missing focus","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"r"],"passed":false},{"actual":[["a","r"],["leaf"],["r","a","b","other","v0"],"b"],"check":"deep varying chain","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other","v0"],"leaf"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"deep saved\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": false}, {\"check\": \"deep branch alone\", \"actual\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": true}, {\"check\": \"foreign snapshot\", \"actual\": [[], [], [\"r\", \"other\"], \"r\"], \"expected\": [[], [], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"blocked middle\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"passed\": true}, {\"check\": \"blocked root\", \"actual\": [[\"a\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": false}, {\"check\": \"no saved branch\", \"actual\": [[], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"expected\": [[], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"missing focus\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"r\"], \"passed\": false}, {\"check\": \"deep varying chain\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\", \"v0\"], \"b\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\", \"v0\"], \"leaf\"], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":47.163,"exit_code":1,"observations":[{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"deep saved","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":false},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"deep branch alone","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":false},{"actual":[[],[],["r","other"],"r"],"check":"foreign snapshot","expected":[[],[],["r","other"],"r"],"passed":true},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"blocked middle","expected":[["a","r"],["leaf"],["r","a","b","other"],"b"],"passed":true},{"actual":[["a"],["leaf"],["r","other"],"r"],"check":"blocked root","expected":[["a","b"],["leaf"],["r","other"],"r"],"passed":false},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"no saved branch","expected":[[],["leaf"],["r","other"],"r"],"passed":false},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"r"],"check":"missing focus","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"r"],"passed":false},{"actual":[[],["leaf"],["r","other","v0"],"r"],"check":"deep varying chain","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other","v0"],"leaf"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"deep saved\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": false}, {\"check\": \"deep branch alone\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": false}, {\"check\": \"foreign snapshot\", \"actual\": [[], [], [\"r\", \"other\"], \"r\"], \"expected\": [[], [], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"blocked middle\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"passed\": true}, {\"check\": \"blocked root\", \"actual\": [[\"a\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": false}, {\"check\": \"no saved branch\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": false}, {\"check\": \"missing focus\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"r\"], \"passed\": false}, {\"check\": \"deep varying chain\", \"actual\": [[], [\"leaf\"], [\"r\", \"other\", \"v0\"], \"r\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\", \"v0\"], \"leaf\"], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":46.695,"exit_code":0,"observations":[{"actual":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"check":"deep saved","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":true},{"actual":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"check":"deep branch alone","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"leaf"],"passed":true},{"actual":[[],[],["r","other"],"r"],"check":"foreign snapshot","expected":[[],[],["r","other"],"r"],"passed":true},{"actual":[["a","r"],["leaf"],["r","a","b","other"],"b"],"check":"blocked middle","expected":[["a","r"],["leaf"],["r","a","b","other"],"b"],"passed":true},{"actual":[["a","b"],["leaf"],["r","other"],"r"],"check":"blocked root","expected":[["a","b"],["leaf"],["r","other"],"r"],"passed":true},{"actual":[[],["leaf"],["r","other"],"r"],"check":"no saved branch","expected":[[],["leaf"],["r","other"],"r"],"passed":true},{"actual":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"r"],"check":"missing focus","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other"],"r"],"passed":true},{"actual":[["a","b","r"],["leaf"],["r","a","b","leaf","other","v0"],"leaf"],"check":"deep varying chain","expected":[["a","b","r"],["leaf"],["r","a","b","leaf","other","v0"],"leaf"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"deep saved\", \"actual\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": true}, {\"check\": \"deep branch alone\", \"actual\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"leaf\"], \"passed\": true}, {\"check\": \"foreign snapshot\", \"actual\": [[], [], [\"r\", \"other\"], \"r\"], \"expected\": [[], [], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"blocked middle\", \"actual\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"expected\": [[\"a\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"other\"], \"b\"], \"passed\": true}, {\"check\": \"blocked root\", \"actual\": [[\"a\", \"b\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\"], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"no saved branch\", \"actual\": [[], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"expected\": [[], [\"leaf\"], [\"r\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"missing focus\", \"actual\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"r\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\"], \"r\"], \"passed\": true}, {\"check\": \"deep varying chain\", \"actual\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\", \"v0\"], \"leaf\"], \"expected\": [[\"a\", \"b\", \"r\"], [\"leaf\"], [\"r\", \"a\", \"b\", \"leaf\", \"other\", \"v0\"], \"leaf\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}