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

N = 1
observations = []
def solve(s):
    return {
        'replace': s['outer_value'] and s['inner_active'],
        'generation': s['generation']+int(s['outer_value']),
        'accept': s['inner_active'],
        'outer_complete': s['outer_done'] and not any(active for generation,active in s['inner_records'] if generation==s['generation']),
        'inner_complete': s['inner_done'] and s['outer_done'],
        'start': s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None,
        'transition_order': ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []),
        'active_after_done': s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']),
        'dispose_outer': s['error'] is not None or s['cancel'],
        'late_value': s['event_generation']!=s['generation'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [2, True]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [2, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [2, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 2, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 2, 'accept': True, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [2, False]]}, {'replace': False, 'generation': 2, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 2: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': False, 'generation': 4, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 5, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 4, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 5, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 3: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 6, 'event_generation': 6, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 7, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 4: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [8, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 8, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [8, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 8, 'event_generation': 8, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 5: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': False, 'generation': 10, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': True, 'generation': 1, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 10, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})]}
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 {
        'replace': s['outer_value'] and s['inner_active'],
        'generation': s['generation']+int(s['outer_value']),
        'accept': s['event_generation']==s['generation'] and s['inner_active'],
        'outer_complete': s['outer_done'] and not any(active for generation,active in s['inner_records'] if generation==s['generation']),
        'inner_complete': s['inner_done'] and s['outer_done'],
        'start': s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None,
        'transition_order': ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []),
        'active_after_done': s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']),
        'dispose_outer': s['error'] is not None or s['cancel'],
        'late_value': s['event_generation']!=s['generation'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [2, True]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [2, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [2, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 2, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 2, 'accept': True, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [2, False]]}, {'replace': False, 'generation': 2, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 2: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': False, 'generation': 4, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 5, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 4, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 5, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 3: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 6, 'event_generation': 6, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 7, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 4: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [8, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 8, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [8, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 8, 'event_generation': 8, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 5: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': False, 'generation': 10, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': True, 'generation': 1, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 10, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})]}
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 replaced inner callback is published after switching; the returned lifecycle plan violates the stated transition contract.

Plan switch-to-latest observer ownership. A new outer value replaces the active inner and advances an inner generation. Late values from the replaced generation are suppressed. Outer completion waits for the current inner, while an inner completion alone does not close a live outer. An error closes both. Dispose the old inner before starting the replacement, even if it emitted no value. Completion considers only active inner records belonging to the current generation; stale active records and current inactive records do not block it. 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: replace = s['outer_value'] and s['inner_active']; generation = s['generation']+int(s['outer_value']); accept = s['event_generation']==s['generation'] and s['inner_active'] and not s['cancel'] and s['error'] is None; outer_complete = s['outer_done'] and not any(active for generation,active in s['inner_records'] if generation==s['generation']); inner_complete = s['inner_done'] and s['outer_done']; start = s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None; transition_order = ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []); active_after_done = s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']); dispose_outer = s['error'] is not None or s['cancel']; late_value = s['event_generation']!=s['generation']

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'replace': s['outer_value'] and s['inner_active'],
        'generation': s['generation']+int(s['outer_value']),
        'accept': s['event_generation']==s['generation'] and s['inner_active'] and not s['cancel'] and s['error'] is None,
        'outer_complete': s['outer_done'] and not any(active for generation,active in s['inner_records']),
        'inner_complete': s['inner_done'] and s['outer_done'],
        'start': s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None,
        'transition_order': ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []),
        'active_after_done': s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']),
        'dispose_outer': s['error'] is not None or s['cancel'],
        'late_value': s['event_generation']!=s['generation'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [2, True]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [2, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [2, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 2, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 2, 'accept': True, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [2, False]]}, {'replace': False, 'generation': 2, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 2: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': False, 'generation': 4, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 5, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 4, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 5, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 3: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 6, 'event_generation': 6, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 7, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 4: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [8, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 8, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [8, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 8, 'event_generation': 8, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 5: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': False, 'generation': 10, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': True, 'generation': 1, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 10, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})]}
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)

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(s):
    return {
        'replace': s['outer_value'] and s['inner_active'],
        'generation': s['generation']+int(s['outer_value']),
        'accept': s['event_generation']==s['generation'] and s['inner_active'] and not s['cancel'] and s['error'] is None,
        'outer_complete': s['outer_done'] and not any(generation==s['generation'] for generation,active in s['inner_records']),
        'inner_complete': s['inner_done'] and s['outer_done'],
        'start': s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None,
        'transition_order': ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []),
        'active_after_done': s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']),
        'dispose_outer': s['error'] is not None or s['cancel'],
        'late_value': s['event_generation']!=s['generation'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [2, True]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [2, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [2, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 2, 'event_generation': 2, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 2, 'accept': True, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [2, False]]}, {'replace': False, 'generation': 2, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 2, 'event_generation': 2, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 3, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 2: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': False, 'generation': 4, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 4, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 5, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, True], [4, False]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [4, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 4, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [4, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 4, 'event_generation': 4, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 5, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 3: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 6, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [6, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, False], [6, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 6, 'event_generation': 6, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 7, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 4: [({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': True, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False], [8, True]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 8, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': True, 'inner_active': False, 'inner_done': True, 'generation': 0, 'event_generation': 8, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [8, False]]}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': True, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 8, 'event_generation': 8, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': False, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 8, 'event_generation': 8, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 9, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})], 5: [({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': False}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': False, 'generation': 10, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': True, 'outer_done': True, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': 'bad', 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 1, 'accept': False, 'outer_complete': True, 'inner_complete': False, 'start': False, 'transition_order': ['start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': True, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': True, 'inner_records': [[0, False], [10, True]]}, {'replace': True, 'generation': 1, 'accept': True, 'outer_complete': False, 'inner_complete': False, 'start': True, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 10, 'event_generation': 0, 'error': None, 'cancel': True, 'inner_value': 'value', 'inner_seen': False, 'inner_records': [[0, True], [10, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': True, 'dispose_outer': True, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': True, 'inner_done': False, 'generation': 0, 'event_generation': 10, 'error': None, 'cancel': False, 'inner_value': 'value', 'inner_seen': True, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': True, 'dispose_outer': False, 'late_value': True}), ({'outer_value': False, 'outer_done': False, 'inner_active': False, 'inner_done': False, 'generation': 0, 'event_generation': 0, 'error': None, 'cancel': False, 'inner_value': None, 'inner_seen': False, 'inner_records': []}, {'replace': False, 'generation': 0, 'accept': False, 'outer_complete': False, 'inner_complete': False, 'start': False, 'transition_order': [], 'active_after_done': False, 'dispose_outer': False, 'late_value': False}), ({'outer_value': True, 'outer_done': True, 'inner_active': True, 'inner_done': True, 'generation': 10, 'event_generation': 10, 'error': 'bad', 'cancel': True, 'inner_value': 'value', 'inner_seen': True, 'inner_records': [[0, False]]}, {'replace': True, 'generation': 11, 'accept': False, 'outer_complete': True, 'inner_complete': True, 'start': False, 'transition_order': ['dispose', 'start'], 'active_after_done': False, 'dispose_outer': True, 'late_value': False})]}
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:
Stale inner records prevent completion of the current switched generation; the returned lifecycle plan violates the stated transition contract.

Plan switch-to-latest observer ownership. A new outer value replaces the active inner and advances an inner generation. Late values from the replaced generation are suppressed. Outer completion waits for the current inner, while an inner completion alone does not close a live outer. An error closes both. Dispose the old inner before starting the replacement, even if it emitted no value. Completion considers only active inner records belonging to the current generation; stale active records and current inactive records do not block it. 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: replace = s['outer_value'] and s['inner_active']; generation = s['generation']+int(s['outer_value']); accept = s['event_generation']==s['generation'] and s['inner_active'] and not s['cancel'] and s['error'] is None; outer_complete = s['outer_done'] and not any(active for generation,active in s['inner_records'] if generation==s['generation']); inner_complete = s['inner_done'] and s['outer_done']; start = s['outer_value'] and not s['outer_done'] and not s['cancel'] and s['error'] is None; transition_order = ['dispose','start'] if s['outer_value'] and s['inner_active'] else (['start'] if s['outer_value'] else []); active_after_done = s['inner_active'] and not(s['inner_done'] and s['event_generation']==s['generation']); dispose_outer = s['error'] is not None or s['cancel']; late_value = s['event_generation']!=s['generation']

split: open-access