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

N = 1
observations = []
def solve(s):
    return {
        'receiver': next((receiver for ident,receiver in reversed(s['receiver_frames']) if ident not in s['finished_frames']),None),
        'bound_none': s['bound'],
        'locals': dict(s['inherited'],**s['local']),
        'null_shadow': s['local']['x'] if 'x' in s['local'] else s['inherited'].get('x'),
        'restore': s['saved'] if s['exited'] else s['current'],
        'trace': s['spans'][:-1] if s['spans'] and s['spans'][-1]==s['exiting_span'] else list(s['spans']),
        'sender': [x for i,x in enumerate(s['sender_route']) if i==0 or x!=s['sender_route'][i-1]],
        'invoke': not s['disposed'] and not s['exited'],
        'restore_disposed': 'reset',
        'unwind_trace': {k:(s['saved_values'][k] if k in s['modified_names'] else s['current_values'][k]) for k in dict.fromkeys(list(s['current_values'])+list(s['saved_values'])) if (k in s['modified_names'] and k in s['saved_values']) or (k not in s['modified_names'] and k in s['current_values'])},
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0, 'b': 2}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 1, 'b': 2}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a'], 'spans': [], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': 'outer-context', 'trace': [], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': ['root'], 'segment': 'callback', 'disposed': True, 'sender_route': [], 'current_values': {}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root'], 'sender': [], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 2: [({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': [], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'b': 4}}), ({'bound': False, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {'x': None}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root'], 'exiting_span': 'missing', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'b': 4}}), ({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {'a': 0, 'c': 6}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 4}}), ({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 4}}), ({'bound': True, 'receiver': 0, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {'a': 0, 'c': 6}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 3: [({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': ['root'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 6}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root', 'a'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 0, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': [], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': [], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 4: [({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': None, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': [], 'sender': ['a', 'b'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': [], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'used', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': False, 'receiver': 0, 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 5: [({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': 'callback', 'disposed': False, 'sender_route': [], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a'], 'sender': [], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 1, 'b': 10}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {'x': 'local'}, 'inherited': {}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'local'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': True, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': ['a'], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': ['a'], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {'b': 10}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': [], 'current_values': {}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root'], 'sender': [], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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(s):
    return {
        'receiver': next((receiver for ident,receiver in reversed(s['receiver_frames']) if ident not in s['finished_frames']),None),
        'bound_none': s['bound'],
        'locals': dict(s['inherited'],**s['local']),
        'null_shadow': s['local']['x'] if 'x' in s['local'] else s['inherited'].get('x'),
        'restore': s['saved'] if s['exited'] else s['current'],
        'trace': s['spans'][:-1] if s['spans'] and s['spans'][-1]==s['exiting_span'] else list(s['spans']),
        'sender': [x for i,x in enumerate(s['sender_route']) if i==0 or x!=s['sender_route'][i-1]],
        'invoke': not s['disposed'] and not s['exited'],
        'restore_disposed': 'used' if s['reset_token'] in s['used_tokens'] else 'reset',
        'unwind_trace': {k:(s['saved_values'][k] if k in s['modified_names'] else s['current_values'][k]) for k in dict.fromkeys(list(s['current_values'])+list(s['saved_values'])) if (k in s['modified_names'] and k in s['saved_values']) or (k not in s['modified_names'] and k in s['current_values'])},
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0, 'b': 2}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 1, 'b': 2}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a'], 'spans': [], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': 'outer-context', 'trace': [], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': ['root'], 'segment': 'callback', 'disposed': True, 'sender_route': [], 'current_values': {}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root'], 'sender': [], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 2}, 'saved_values': {'a': 0, 'c': 3}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 2: [({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': [], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'b': 4}}), ({'bound': False, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': 'sender', 'local': {'x': None}, 'inherited': {}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root'], 'exiting_span': 'missing', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'b': 4}}), ({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {'a': 0, 'c': 6}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 4}}), ({'bound': False, 'receiver': 'receiver', 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 4}}), ({'bound': True, 'receiver': 0, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 4}, 'saved_values': {'a': 0, 'c': 6}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 3: [({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': ['root'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 6}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root', 'a'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'used', 'unwind_trace': {}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 0, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': [], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': [], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 6}, 'saved_values': {'a': 0, 'c': 9}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 4: [({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': 'inner-context', 'trace': ['root'], 'sender': ['a'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': None, 'sender': 'sender', 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': [], 'sender': ['a', 'b'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': False, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'b', 'reset_token': 't', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': 'outer-context', 'trace': [], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {'x': None}, 'inherited': {}, 'saved': None, 'current': 'inner-context', 'exited': False, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': ['t'], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': None}, 'null_shadow': None, 'restore': 'inner-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'used', 'unwind_trace': {'a': 1, 'b': 8}}), ({'bound': False, 'receiver': 0, 'sender': None, 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 8}, 'saved_values': {'a': 0, 'c': 12}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})], 5: [({'bound': True, 'receiver': None, 'sender': None, 'local': {'x': None}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': False, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {'x': None, 'y': 'shared'}, 'null_shadow': None, 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b', 'a'], 'invoke': True, 'restore_disposed': 'wrong-context', 'unwind_trace': {'a': 0}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root'], 'segment': 'callback', 'disposed': False, 'sender_route': [], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': [], 'spans': ['root', 'a', 'b'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a'], 'sender': [], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 1, 'b': 10}}), ({'bound': True, 'receiver': 'receiver', 'sender': None, 'local': {}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': None, 'current': None, 'exited': False, 'error': 'failure', 'path': ['root', 'child'], 'segment': None, 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'outer', 'y': 'shared'}, 'null_shadow': 'outer', 'restore': None, 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {'x': 'local'}, 'inherited': {}, 'saved': 'outer-context', 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'a', 'b', 'a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': ['a', 'b'], 'spans': ['root'], 'exiting_span': 'b', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'a', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': False, 'locals': {'x': 'local'}, 'null_shadow': 'local', 'restore': None, 'trace': ['root'], 'sender': ['a', 'b', 'a'], 'invoke': False, 'restore_disposed': 'wrong-context', 'unwind_trace': {}}), ({'bound': True, 'receiver': 0, 'sender': 'sender', 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': 'failure', 'path': ['root'], 'segment': None, 'disposed': False, 'sender_route': ['a'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {}, 'modified_names': ['a'], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': []}, {'receiver': 'B', 'bound_none': True, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': ['a'], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {'b': 10}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': 'outer-context', 'current': None, 'exited': True, 'error': None, 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': [], 'current_values': {}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': [], 'spans': ['root'], 'exiting_span': 'a', 'reset_token': 'new', 'used_tokens': [], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', 'A'], ['inner', 'B']], 'finished_frames': ['inner']}, {'receiver': 'A', 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': 'outer-context', 'trace': ['root'], 'sender': [], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': False, 'receiver': None, 'sender': None, 'local': {}, 'inherited': {}, 'saved': None, 'current': None, 'exited': False, 'error': None, 'path': [], 'segment': None, 'disposed': False, 'sender_route': [], 'current_values': {}, 'saved_values': {}, 'modified_names': [], 'spans': [], 'exiting_span': 'a', 'reset_token': 't', 'used_tokens': [], 'token_context': 'a', 'active_context': 'a', 'receiver_frames': [], 'finished_frames': []}, {'receiver': None, 'bound_none': False, 'locals': {}, 'null_shadow': None, 'restore': None, 'trace': [], 'sender': [], 'invoke': True, 'restore_disposed': 'reset', 'unwind_trace': {}}), ({'bound': True, 'receiver': 'receiver', 'sender': 'sender', 'local': {'x': 'local'}, 'inherited': {'x': 'outer', 'y': 'shared'}, 'saved': 'outer-context', 'current': 'inner-context', 'exited': True, 'error': 'failure', 'path': ['root', 'child'], 'segment': 'callback', 'disposed': True, 'sender_route': ['a', 'b', 'b'], 'current_values': {'a': 1, 'b': 10}, 'saved_values': {'a': 0, 'c': 15}, 'modified_names': ['a', 'b'], 'spans': ['root', 'a', 'b'], 'exiting_span': 'missing', 'reset_token': 'new', 'used_tokens': ['t'], 'token_context': 'b', 'active_context': 'b', 'receiver_frames': [['outer', None], ['inner', 'B']], 'finished_frames': ['outer', 'inner']}, {'receiver': None, 'bound_none': True, 'locals': {'x': 'local', 'y': 'shared'}, 'null_shadow': 'local', 'restore': 'outer-context', 'trace': ['root', 'a', 'b'], 'sender': ['a', 'b'], 'invoke': False, 'restore_disposed': 'reset', 'unwind_trace': {'a': 0}})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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:
A callback context reset token is consumed from the wrong context; the returned lifecycle plan violates the stated transition contract.

Plan an observer callback context frame. The bound receiver is independent from event sender. Explicit None receiver differs from no receiver binding. Context-local values shadow inherited values, including None. An exit restores the saved outer context even after callback failure. Nested callbacks append a trace segment without rewriting the existing path. A disposed binding rejects invocation but still permits frame restoration. A forwarded sender route collapses adjacent duplicate hops only; a later revisit after another sender is meaningful and preserved. Restore only names modified by the callback. Restore their saved values or delete them if previously absent; retain all unmodified current names. Only an exit matching the active top trace span may pop the stack; out-of-order exits are ignored until their span becomes current. A reset token is single-use and context-bound: report used before wrong-context, otherwise permit reset. Restore the nearest remaining receiver frame, scanning nested frames from inner to outer while skipping completed invocation identities. Inputs are finite state snapshots, including transitional and stale states; output fields are the exact independent actions/metadata defined by the corrected expression table. Numeric fixture capacities and counts vary with N.
Field definitions, each independently computed from the input snapshot: receiver = next((receiver for ident,receiver in reversed(s['receiver_frames']) if ident not in s['finished_frames']),None); bound_none = s['bound']; locals = dict(s['inherited'],**s['local']); null_shadow = s['local']['x'] if 'x' in s['local'] else s['inherited'].get('x'); restore = s['saved'] if s['exited'] else s['current']; trace = s['spans'][:-1] if s['spans'] and s['spans'][-1]==s['exiting_span'] else list(s['spans']); sender = [x for i,x in enumerate(s['sender_route']) if i==0 or x!=s['sender_route'][i-1]]; invoke = not s['disposed'] and not s['exited']; restore_disposed = 'used' if s['reset_token'] in s['used_tokens'] else ('wrong-context' if s['token_context']!=s['active_context'] else 'reset'); unwind_trace = {k:(s['saved_values'][k] if k in s['modified_names'] else s['current_values'][k]) for k in dict.fromkeys(list(s['current_values'])+list(s['saved_values'])) if (k in s['modified_names'] and k in s['saved_values']) or (k not in s['modified_names'] and k in s['current_values'])}

split: open-access