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

N = 1
observations = []
def solve(d):
    intent=dict(d['intent'])
    if d['toggle'] is not None: intent[d['branch']]=d['toggle']
    if d['complete'] and not d['descendants']: intent.pop(d['branch'],None)
    result={}
    for x in d['descendants']:
        nearest=next((a for a in d['ancestors'][x] if a in intent),None)
        inherited=intent[nearest] if nearest is not None else d['stored'].get(x,False)
        value=d['overrides'].get(x,inherited)
        result[x]=d['stored'].get(x,False) if x in d['disabled'] else value
    pending={x:v for x,v in intent.items() if x in d['unknown']}
    checked=[x for x in d['descendants'] if result[x]]
    return [intent,result,pending,checked]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 2: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 3: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 4: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 5: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])]}
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):
    intent=dict(d['intent'])
    if d['toggle'] is not None: intent[d['branch']]=d['toggle']
    if d['complete'] and not d['descendants']: intent.pop(d['branch'],None)
    result={}
    for x in d['descendants']:
        nearest=next((a for a in d['ancestors'][x][:1] if a in intent),None)
        inherited=intent[nearest] if nearest is not None else d['stored'].get(x,False)
        value=d['overrides'].get(x,inherited)
        result[x]=d['stored'].get(x,False) if x in d['disabled'] else value
    pending={x:v for x,v in intent.items() if x in d['unknown']}
    checked=[x for x in d['descendants'] if result[x]]
    return [intent,result,pending,checked]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 2: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 3: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 4: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 5: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])]}
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:
Nested branch intent loses nearest-ancestor priority produces the wrong hierarchical widget state in a regression fixture.

Checking an incompletely loaded branch stores inherited intent. Loaded writable descendants receive nearest ancestor intent unless they have an explicit override. Disabled descendants keep stored state. A fully loaded empty branch removes obsolete intent; pending intent remains for unknown descendants.

split: open-access


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

N = 1
observations = []
def solve(d):
    intent=dict(d['intent'])
    if d['toggle'] is not None: intent[d['branch']]=d['toggle']
    if d['complete'] and not d['descendants']: intent.pop(d['branch'],None)
    result={}
    for x in d['descendants']:
        nearest=next((a for a in reversed(d['ancestors'][x]) if a==d['branch']),None)
        inherited=intent[nearest] if nearest is not None else d['stored'].get(x,False)
        value=d['overrides'].get(x,inherited)
        result[x]=d['stored'].get(x,False) if x in d['disabled'] else value
    pending={x:v for x,v in intent.items() if x in d['unknown']}
    checked=[x for x in d['descendants'] if result[x]]
    return [intent,result,pending,checked]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 2: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 3: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 4: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 5: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])]}
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):
    intent=dict(d['intent'])
    if d['toggle'] is not None: intent[d['branch']]=d['toggle']
    if d['complete'] and not d['descendants']: intent.pop(d['branch'],None)
    result={}
    for x in d['descendants']:
        nearest=next((a for a in reversed(d['ancestors'][x]) if a in d['unknown'] and a in intent),None)
        inherited=intent[nearest] if nearest is not None else d['stored'].get(x,False)
        value=d['overrides'].get(x,inherited)
        result[x]=d['stored'].get(x,False) if x in d['disabled'] else value
    pending={x:v for x,v in intent.items() if x in d['unknown']}
    checked=[x for x in d['descendants'] if result[x]]
    return [intent,result,pending,checked]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 2: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 3: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 4: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])], 5: [('inherit', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('no toggle', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': None, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('uncheck', {'intent': {'r': True, 'b': True, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']]), ('empty unknown', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': False, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {}, {'b': True, 'q': True}, []]), ('empty complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': [], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'q': True}, {}, {'q': True}, []]), ('loaded complete', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': True, 'branch': 'b', 'complete': True, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': True, 'q': True}, {'z': True, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': True, 'v1': True, 'v2': True, 'v3': True, 'v4': True}, {'b': True, 'q': True}, ['z', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4']]), ('disabled uncheck', {'intent': {'r': True, 'b': False, 'q': True}, 'toggle': False, 'branch': 'b', 'complete': False, 'descendants': ['z', 'a', 'c', 'd', 'e', 'v0', 'v1', 'v2', 'v3', 'v4'], 'ancestors': {'z': ['r', 'b'], 'a': ['r', 'b'], 'c': ['r', 'b'], 'd': [], 'e': ['r'], 'v0': ['r', 'b'], 'v1': ['r', 'b'], 'v2': ['r', 'b'], 'v3': ['r', 'b'], 'v4': ['r', 'b']}, 'stored': {'c': True, 'd': True}, 'overrides': {'a': False}, 'disabled': ['c'], 'unknown': ['b', 'q']}, [{'r': True, 'b': False, 'q': True}, {'z': False, 'a': False, 'c': True, 'd': True, 'e': True, 'v0': False, 'v1': False, 'v2': False, 'v3': False, 'v4': False}, {'b': False, 'q': True}, ['c', 'd', 'e']])]}
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:
Inherited check lookup ignores completed ancestor intents produces the wrong hierarchical widget state in a regression fixture.

Checking an incompletely loaded branch stores inherited intent. Loaded writable descendants receive nearest ancestor intent unless they have an explicit override. Disabled descendants keep stored state. A fully loaded empty branch removes obsolete intent; pending intent remains for unknown descendants.

split: open-access